VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 6 of 6
Thread
  1. Member
    Join Date
    Nov 2016
    Location
    scotland
    Search PM
    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.

    for example

    Click image for larger version

Name:	Untitled.png
Views:	263
Size:	61.0 KB
ID:	39606

    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
    Quote Quote  
  2. First thing you gotta do is to make Windows Explorer show the file extensions:
    https://www.file-extensions.org/article/show-and-hide-file-extensions-in-windows-10

    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]"
    Quote Quote  
  3. Batch script to extract/split audio and video
    Code:
    @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.
    Batch script to merge/mux audio and video
    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 to ffmpeg path to the actual path on your computer.
    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.
    Quote Quote  
  4. Great post, raffriff42!
    Quote Quote  
  5. Member
    Join Date
    Aug 2013
    Location
    Argentina
    Search Comp PM
    @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.
    Quote Quote  
  6. Member
    Join Date
    Nov 2016
    Location
    scotland
    Search PM
    Thanks for the help everybody, I'm going to try out some of your suggestions.
    Quote Quote  



Similar Threads