Hi I have a .bat file to convert and change channel volume levels (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 for a specific language 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.
From my understanding I would need ffprobe which gives me the channel count and language for every audio track
So I have kinda all the pieces but I don't know how to put them together in a .bat scriptCode:ffprobe -i %~1 -v error -select_streams a -of csv=p=0 -show_entries stream=channels,index:stream_tags=language
Thank you for any advice
Profile A: 5.1
Profile B: Stereo/MonoCode:ffmpeg ^ -i "%~1" ^ -af "pan=stereo|c0=c2+0.6*c0+0.6*c4+c3|c1=c2+0.6*c1+0.6*c5+c3" -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^ "G:\%~n1.mkv"
Code:ffmpeg ^ -i "%~1" ^ -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^ "G:\%~n1.mkv" This is the whole .batCode:@echo off :again ffmpeg ^ -i "%~1" ^ -map 0:v:0 -c:v copy -map 0:a:m:language:ger -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^ "G:\%~n1.mkv" if NOT ["%errorlevel%"]==["0"] goto:error echo [92m%~n1 Done![0m shift if "%~1" == "" goto:end goto:again :error echo [93mThere was an error. Please check your input file or report an issue on github.com/L0Lock/FFmpeg-bat-collection/issues.[0m pause exit 0 :end cls echo [92mEncoding succesful. This window will close after 10 seconds.[0m timeout /t 1
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 4 of 4
Thread
-
-
Hi.
I'ts been a while since I saw someone else using esc codes to change screen colours.
I occasionally use them myself.
I created a multi audio, multi subtitle MKV from a DVD using MakeMKV.exe (movie - The Fifth Element)
The following batch file has a line listing all the audio tracks found.
I left it in to help diagnose any problems. (Where I say tags, read it as parameters or arguments, as you wish.)
The batch file is written assuming all the tags in your videos are as listed and you are consistent with your conversions.
i.e. A missing language tag will mean the tag for the channel count moves from %%i to %%h.
(There are probably a better ways of getting and setting the variables %lang% and %channels%.)
My batch file is:
the 4th tag is the language (%%d). This should be consistent across all MKVs
the 9th tag is the channel count (%%i). This is a tag that showed as the 10th tag (%%j) on other MKVs I have.
All ffmpeg executables are echoed, and NOT run. Change when you're happy.
To_Stereo v01.cmd
Code:@echo off :loop ffmpeg.exe -i "%~1" -y nul 2>&1 | find /i "stream" | find "Audio" > "%~n1.txt" :: List all audio tracks, with tags. To use parentheses as delimiters, the order of the delimiters is important. echo These audio tracks were found. for /f "usebackq tokens=1-12 delims=,^:^#() " %%a in ("%~n1.txt") do echo A-%%a B-%%b C-%%c D-%%d E-%%e F-%%f G-%%g H-%%h I-%%i J-%%j K-%%k L-%%l echo. for /f "usebackq tokens=1-12 delims=,^:^#() " %%a in ("%~n1.txt") do set lang=%%d&& set channels=%%i&& call :channelcount shift if "%~1" neq "" goto :loop goto :end :channelcount if %channels% equ mono call :1channel "%~1" if %channels% equ 5.1 call :6channel "%~1" goto :eof :1channel echo Process mono echo ffmpeg -i "%~1" ^ -map 0:v:0 -c:v copy -map 0:a:m:language:%lang% -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^ "G:\%~n1.mkv" goto :eof :6channel echo Process 5.1 echo ffmpeg -i "%~1" ^ -af "pan=stereo|c0=c2+0.6*c0+0.6*c4+c3|c1=c2+0.6*c1+0.6*c5+c3" -map 0:v:0 -c:v copy -map 0:a:m:language:%lang% -codec:a ac3 -b:a 160k -ar 44100 -sn -dn ^ "G:\%~n1.mkv" goto :eof :end ::del "*.txt" pause
Last edited by pcspeak; 19th Mar 2024 at 13:10. Reason: Removed multiple spaces in the batch file. No biggie.
-
Avisynth functions Resize8 Mod - Audio Speed/Meter/Wave - FixBlend.zip - Position.zip
Avisynth/VapourSynth functions CropResize - FrostyBorders - CPreview (Cropping Preview) -
@pcspeak thank you for your reply. I will test this and give you feedback. It looks aswesome
I don't know what "using esc codes to change screen colours" means. all the credit goes to the author from github (github.com/L0Lock/FFmpeg-bat-collection) I just found his .bat scripts and started to build in my own commands ^^
@hello_hello you are right all the audio is usually 48k but my tv (usb) has real problems, and often glitches the video and audio streams so I started to make the audio as small as possible
Similar Threads
-
convert ffmpeg bat file to Linux shell script
By wiseant in forum LinuxReplies: 4Last Post: 2nd Sep 2023, 18:25 -
images to mkv and webp by using ffmpeg into a .bat file
By maudit in forum Video ConversionReplies: 2Last Post: 15th Aug 2023, 02:17 -
FFMpeg Auto output Name on .bat Script file
By Daringbaaz in forum Newbie / General discussionsReplies: 10Last Post: 6th Dec 2020, 08:44 -
ffmpeg in bat file
By windranger in forum Video ConversionReplies: 5Last Post: 25th Jul 2020, 02:27 -
ffmpeg bat to mux multible audio and video
By alkoon in forum Newbie / General discussionsReplies: 3Last Post: 5th Jun 2020, 11:20