Hi there, im a total noob to using ffmpeg im wondering if anyone can help me to write a script for a .bat file that will batch extract the audio tracks from all the video files in a folder.
i also want to write a script that will take those audio files and batch join them to video files that are the named the same.
for example if an video file was named "serial experiments lain S01E01" and the audio file was named the exact same the script would join both those files together.
and it would do that for all the files in a folder.
i want to do this without re encoding, just removing and re adding the files
+ Reply to Thread
Results 1 to 6 of 6
First thing you gotta do is to make Windows Explorer show the file extensions:
Then you gotta look inside the files to see what kind (format), how many and in which order the tracks are to see which ones you still need and what number they have. Otherwise you cannot write a batch file. You can use MediaInfo for that (I recommend setting View->Text for the text view).
Btw, I often find using mkvmerge for this easier. There are also GUIs for batch use: https://www.videohelp.com/software/MKVBatch
for %%a in (*.[VIDEO_FILE_EXTENSION]) do mkvmerge -o "output\%%~na.mkv" "%%a" "%%~na.[AUDIO_FILE_EXTENSION]"
Batch script to extract/split audio and videoCode:
@echo off :: set paths (no quotes) set ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe set outfolder=D:\VideoProjects\work\_temp\split @echo. @echo on for %%f in (*.mp4) do "%ffmpeg%" -y ^ -hide_banner ^ -i "%%~dpnxf" -c:v copy -an ^ "%outfolder%\%%~nf-xtract.m4v" @echo off if errorlevel 1 pause @echo. @echo on for %%f in (*.mp4) do "%ffmpeg%" -y ^ -hide_banner ^ -i "%%~dpnxf" -vn -c:a copy ^ "%outfolder%\%%~nf-xtract.m4a" @echo off if errorlevel 1 pause @echo.Code:
@echo off :: set paths (no quotes) set ffmpeg=C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe set outfolder=D:\VideoProjects\work\_temp\joined @echo. @echo on for %%f in (*.m4v) do "%ffmpeg%" -y ^ -hide_banner ^ -i "%%~dpnxf" -i "%%~dpnf.m4a" ^ -c:v copy -c:a copy ^ -map 0:0 -map 1:0 -shortest ^ "%outfolder%\%%~nf-remux.mp4" @echo off if errorlevel 1 pause @echo.
Change outfolder to wherever you want.
Change the file extensions as needed.
Delete the -y if you want to get a warning before a file is overwritten.
I assumed output is to a temp folder and you don't care about that.
Great post, raffriff42!
♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪ You're the champion, my friend ♫♪.ılılıll|̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅|llılılı.♫♪
Last edited by remanyao; 20th Nov 2016 at 13:40.
Thanks for the help everybody, I'm going to try out some of your suggestions.