VideoHelp Forum




+ Reply to Thread
Results 1 to 7 of 7
  1. Hi. I'm looking for a utility that would look at a specified video file and return the number of channels in the audio stream. Ideally, I would like to be able to use it in a batch file in such a way that if it returned a result of "mono" (1-channel) it would execute a certain command, but if it returned 2 channels it would execute a different one. Is there such a utility, that can return these results this way? Thanks.
    Quote Quote  
  2. mediainfo should do that i would guess.

    edit: Yeah it works for 1st part of what you said:

    Code:
    ezcapper@ezcapper-X501A1:~$ mediainfo save4.avi
    General
    Complete name                            : save4.avi
    Format                                   : AVI
    Format/Info                              : Audio Video Interleave
    File size                                : 152 MiB
    Duration                                 : 14 s 933 ms
    Overall bit rate                         : 85.3 Mb/s
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High 4:4:4 Predictive@L4.2
    Format settings, CABAC                   : No
    Format settings, ReFrames                : 1 frame
    Codec ID                                 : h264
    Duration                                 : 14 s 933 ms
    Bit rate                                 : 80.4 Mb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:10
    Frame rate                               : 30.000 FPS
    Original frame rate                      : 60.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 1.292
    Stream size                              : 143 MiB (94%)
    
    Audio
    ID                                       : 0
    Format                                   : PCM
    Format settings, Endianness              : Little
    Format settings, Sign                    : Signed
    Codec ID                                 : 1
    Duration                                 : 14 s 933 ms
    Bit rate mode                            : Constant
    Bit rate                                 : 1 536 kb/s
    Channel(s)                               : 2 channels
    Sampling rate                            : 48.0 kHz
    Bit depth                                : 16 bits
    Stream size                              : 2.73 MiB (2%)
    Alignment                                : Aligned on interleaves
    Last edited by ezcapper; 19th Jan 2017 at 16:57.
    Quote Quote  
  3. I believe ffprobe can do that too (comes with ffmpeg).
    Quote Quote  
  4. use this: https://forum.videohelp.com/threads/377677-Video-batch-files?p=2470418&viewfull=1#post2470418

    not sure how you orient yourself in batch script, that script above in that #26 post gives you that data into batch script variable, then you compare them

    you can get a list of mediainfo cli parameters in txt file running that script that is right below that example in that same #26 input
    Quote Quote  
  5. Originally Posted by jagabo View Post
    I believe ffprobe can do that too (comes with ffmpeg).
    it works with ffprobe too, then you can create a batch file using autohotkey. Create a macro that transports the information to notepad and then does what you want it to do. If my eyes were better, I'd do it for you it is very simple. You can probably have someone do it for you by posting on the autohotkey forums.
    Quote Quote  
  6. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    You can use the show_streams and select_streams options of FFprobe to save audio stream metadata into a file. Then you search the file with the For /F command until you find "channels=n" and grab the RHS value. If 1 then execute Command 1; if 2 then execute Command 2. All quite do-able in a batch file.
    Quote Quote  
  7. Thanks, everyone. MediaInfo seems to be easiest for my purposes. Here's the approach I settled on. It uses MediaInfo to check the number of audio channels in a file (the file in the example here is called "test.mp4"), outputs the answer into a temporary file, then assigns the contents of that temporary file to a variable and deletes the no-longer-needed temp file.

    Code:
    MediaInfo --Inform=Audio;%%Channels%% test.mp4 > tempVAR.txt
    set /p tempVAR= < tempVAR.txt
    del tempVAR.txt
    echo %tempVAR%
    pause
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!