VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Hi, but sorry I'ma c*a*t*

    I try to understand if is there a unique commandline to extract alwais channel 1 and channel 2 from a source file (or left and right) even if it is mono or stereo, 1 or multiple audiochannel, or surround 5.1 and eventually other various audio formats, provided of at least 1 audio.

    My target is to get alwais a standard stereo L+R audio PCM 48Khz .wav file

    So if, e.g., source is a MXF xdcamHD422 video source (xdcamhd422 have, if I don't mistake, 8 MONO audio inside) I need to use:

    Code:
    ffmpeg.exe  -i SOURCE.MXF -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le OUTPUT.WAV
    If the source is a MXF IMX (IMX is alwais SD and have, if I don't mistake, 2 stereo L+R inside) I need to use:

    Code:
    ffmpeg.exe -i INPUT.MXF  -af "pan=stereo:c0=c0:c1=c1" -c:a pcm_s16le -ar 48000  OUTPUT.WAV
    or (it get the same result)
    Code:
    ffmpeg.exe -i INPUT.MXF -map_channel 0.1.0 -map_channel 0.1.1 OUTPUT.WAV
    If the source is a MP4 with audio stereo L+R:

    Code:
    ffmpeg.exe -i INPUT.MP4 -af "pan=stereo:c0=c0:c1=c1" -c:a pcm_s16le -ar 48000 OUTPUT.WAV
    I wonder if is there a way to tell to ffmpeg to extract alwais the first and second audio of a source, and generate alwais an output stereo L+R whatever it's the input source, mono or stereo or multi MONO, dual MONO, dual stereo etc..

    thanks
    Quote Quote  
  2. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    From the 4 or 5 post you have currently in the RECENT posts, I'm assuming you actually want a batch file (always a batch file) that tells whether a video has audio, even if it is PCM, automatically extracts it to a WAV file and always makes it stereo.

    I really do not mean to be derogatory but Curiosity is killing me... What can you POSSIBLY use so many different Automatic batch files on, why always batch files, how many videos can you have that require batch files for multiple files, and do you have a batch file to sort the batch files when you need them?

    To try to be helpful though and to answer your question, one way is, Again, to use MediaInfo CLI that will give the necessary information which can be imported as a variable and interrogated with if/then statements to use your multiple methods above.
    Quote Quote  
  3. Dear sir please tell how to use ffmpeg

    Sent from my P4 using Tapatalk
    Quote Quote  
  4. I only have and use 8/10 batch in total, even if each have more function selectable.

    For example if I apply:

    Code:
    ffmpeg.exe  -i SOURCE.MXF -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le OUTPUT.WAV
    to a MP4 source that have a standard stereo audio inside, I get an error an no output. Because the correct procedure is (or can be):

    Code:
    ffmpeg.exe -i INPUT.MP4 -af "pan=stereo:c0=c0:c1=c1" -c:a pcm_s16le -ar 48000 OUTPUT.WAV
    I wonder if is there a way in ffmpeg to extract audio with target stereo L+R 16bit 48Khz, for every source, independently from audio mapping channels. If is there a "universal" commandline that extract alwais the first and second audio of a source, even if is there is only one mono audio track, and if more of 2 audio --> ignore all except first and second
    Quote Quote  
  5. Member DB83's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by Budman1 View Post
    {Catsnipped}
    I really do not mean to be derogatory but Curiosity is killing me...
    {SnippedCat}
    .
    Nah. Curiosity Killed The Cat.

    That must be 8/10 batch files a week
    Quote Quote  
  6. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    No, there's no way to make a single command work for all the variations. You need a script that calls FFprobe to inspect the audio stream(s) and then fashion the correct FFmpeg command line.
    Quote Quote  
  7. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Learn (on your own) how to use "for..." and variables (environmental or otherwise).

    Scott
    Quote Quote  
  8. So take those ffprobe reading or mediainfo reding in txt form. Then look at them what video gives you what result. What is the difference between two mono channels, stereo channel. Then take that txt file and check for those differences.
    then you have some alternatives how to get information from that txt file based on analysys

    to take line by line in that file to look for certain keywords, that returns the whole line:
    Code:
    findstr /c:"keyword"  "mediainfo.txt > "line.txt"
    if %errorlevel%==0 set /p new_variable= < "line.txt"
    it errorlevel is zero then line exists, get that text into variable and work with it further
    delete spaces from that variable:
    Code:
    set new_variable=%new_variable: =%
    see empty space is replaced with nothing

    or delete everything from that variable that is before colon (character between quotes":")
    Code:
    set new_variable=%new_variable:*: =%
    that star means wild card, so whatever before colon and that space character after is deleted (as you know that is a common format in mediainfo listing)

    so you have that variable as a word or number, then you compare it:
    Code:
    if [%new_variable%]==[something] (do something here) else ( do something here)
    characters "[" and "]" are there in case variable is empty for some reason so you do not crash script

    or if you need variable that mediainfoCLI can give you directly, just get it into variable right away, like:
    Code:
    "MediainfoCLI.exe" --Inform=Video;%%FrameRate%% "%~1" > "temp.tmp"
    set /p fps=<"temp.tmp"
    echo Mediainfo reports: fps=%fps%
    you can print a list of all possible parameters that mediainfo can look for you like that, just run this script and save that notepad text in your computer:

    Code:
    @echo off
    SETLOCAL
    "MediainfoCLI.exe" --Info-Parameters > "parameters.txt"
    START  "notepad.exe" "parameters.txt"
    ENDLOCAL
    Quote Quote  
  9. Originally Posted by JVRaines View Post
    No, there's no way to make a single command work for all the variations. You need a script that calls FFprobe to inspect the audio stream(s) and then fashion the correct FFmpeg command line.
    There is possibility to ignore non existing components within ffmpeg so in theory "universal" script should be doable...
    Quote Quote  
  10. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by pandy View Post
    Originally Posted by JVRaines View Post
    No, there's no way to make a single command work for all the variations. You need a script that calls FFprobe to inspect the audio stream(s) and then fashion the correct FFmpeg command line.
    There is possibility to ignore non existing components within ffmpeg so in theory "universal" script should be doable...
    I don't see how the question-mark syntax will help with some scenarios, such 1 mono ==> dual mono.
    Quote Quote  
  11. Originally Posted by JVRaines View Post
    I don't see how the question-mark syntax will help with some scenarios, such 1 mono ==> dual mono.
    IMHO this can be done with https://ffmpeg.org/ffmpeg-filters.html#pan-1 - target is stereo not dual mono.
    Quote Quote  
  12. What can you POSSIBLY use so many different Automatic batch files on, why always batch files, how many videos can you have that require batch files for multiple files, and do you have a batch file to sort the batch files when you need them?
    Quote Quote  
  13. Difficult to explain that unless you have workflow based on those scripts. It could really click. But it could be constant upkeep and corrections, op should design them himself already with ease.
    Quote Quote  



Similar Threads

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