-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ffmpeg IF condition #4
Comments
Hi, I am no expert, and I don't have access to a Windows machine for the time being, I can not test a full bat script easily... But I will do my best. I don't think you can make ffmpeg tell whether you have a stereo or a 5.1 audio track, but you can ask ffprobe (which should be shipped alongside the ffmpeg executable) for the amount of audio channels in a track (which i think is 6 for a 5.1 versus 2 for stereo). For example: ffprobe -i "inputFile.ext" -show_entries stream=channels -select_streams a:0 -of compact=p=0:nk=1 -v 0
I guess you could format your script like this: for /f %%a in ('ffprobe -i %~1 -show_entries stream=channels -select_streams a:0 -of compact=p=0:nk=1 -v 0') do set channels=%%a
if %channels% LEQ 2 (
REM Run ffmpeg job for <= 2 channels
) else (
REM Run ffmpeg job for > 2 channels
) Basically, store ffprobe's query in a variable. And run the appropriate ffmpeg command depending on whether ffprobe found a value <=2. You might need to use trickeries to correctly parse the ffprobe command in the for loop. I can't test it now, but you can check the "alternative to escaping" part in this post answer. Let me know how it goes. |
Okay thank you. I think I would need something like
output of the 2nd:
I don't know if this makes any difference |
Hi I have a .bat file to convert and change channel volume (with ffmpeg) from 5.1 Audio to Stereo, and a different .bat for Stereo/Mono Audio that doesn't change loudness.
Now I have to manually look if a movie is 5.1 or Mono/Stereo and decide which .bat to run. I would like to make one .bat with a condition so it looks what the channel layout is and then decide which profile to run. I hope this makes sense. It has to check also the language tag, because sometimes (in my case) german is 2.0 but English is 5.1 or vice versa.
Thank you for any advice
5.1
2.0/Mono
This is the whole .bat
The text was updated successfully, but these errors were encountered: