Is there a quick way to determine the type of a file?

  • Dust

    Dust - 2013-04-02


    Is there a quick way to determine if a file is video or audio with mediainfo, without reading all the properties? So I could write

    if [ file is video ]
      mediainfo --video-options file
    elif [ file is audio ]
      mediainfo --audio-options file
  • Jerome Martinez

    Jerome Martinez - 2013-04-02

    Some "magic":
    mediainfo "--Inform=General;%VideoCount%" file
    mediainfo "--Inform=General;%AudioCount%" file

    return a value superior or egal to 1 if there is a video (or an audio) stream, else empty.
    You need to "transform" yourself such returned value to true/false

  • Jerome Martinez

    Jerome Martinez - 2013-04-02

    Add --ParseSpeed=0, it is fast parsing and you don't need "advanced" values, so what is not present in the output (e.g. GOP size) is not a problem for you.

  • Dust

    Dust - 2013-04-02

    Ok, it works a bit faster. Thank you.

    For about a hundred files

    mediainfo --Output='General;%VideoCount%'

    mediainfo --Inform='General;%VideoCount%'

    mediainfo --ParseSpeed=0 --Inform='General;%VideoCount%'

    But these options are not documented in mediainfo --help. =)
    I have v0.7.61. Is there any other documentation?

  • Jerome Martinez

    Jerome Martinez - 2013-04-02

    --Output and --Inform are same, sorry, I forgot to trash "inform" word.
    I am a bit disappointed about speed improvement, it does not help a lot with your files.

    Documentation definitely sucks, I'll write it when people stop to request new features for yesterday.

  • Dust

    Dust - 2013-04-04

    The speed impact is really not large. Bug generally I'm quite satisfied with the performance. Anyway, your program works very fast.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks