Skip to content

Instantly share code, notes, and snippets.

@Aldaviva
Created January 10, 2015 08:21
Show Gist options
  • Save Aldaviva/c0a4eb968246e69da969 to your computer and use it in GitHub Desktop.
Save Aldaviva/c0a4eb968246e69da969 to your computer and use it in GitHub Desktop.
Join multiple MOV files into a single MP4 without reencoding (useful for video cameras that split files every 4GB)
@echo off
if "%1"=="" (
echo usage example: join.bat video1.mov video2.mov video3.mov
echo this will create joined.mp4 in the same directory
exit /B 1
)
ffmpeg -version >nul 2>&1 || (
echo ffmpeg missing, install from http://ffmpeg.zeranoe.com/builds/
exit /B 1
)
set filenamesconcat=
set pipe=:
:convertfile
if "%1"=="" goto convertfileend
if not "%filenamesconcat%"=="" (
set "filenamesconcat=%filenamesconcat%%pipe%"
)
set filenamesconcat=%filenamesconcat%%1.ts
ffmpeg -i "%1" -c:v copy -c:a aac -strict -2 "%1.mp4"
ffmpeg -i "%1.mp4" -c copy -vbsf h264_mp4toannexb "%1.ts"
del "%1.mp4"
shift
goto convertfile
:convertfileend
ffmpeg -i concat:"%filenamesconcat::=|%" -c copy -absf aac_adtstoasc "joined.mp4"
for %%A in (%*) do (
del "%%A.ts"
)
@Aldaviva
Copy link
Author

Derived from Jim Watters' ConCatMovies.bat, which has a broken download link (even after logging in), so I wrote my own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment