Friday, 10 July 2015

Use FFMPeg to concatenate mp4 files

# ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
# ...
# ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
$ffmpeg = "c:\tools\ffmpeg\bin\ffmpeg.exe"
$s = ("MAH00383.MP4|MAH00384.MP4|MAH00385.MP4|MAH00386.MP4|MAH00387.MP4") -split "\|"
# yes a list of files with '|' char separator is bizarre, but it's what I had at hand.
$s | % { & "$ffmpeg" -i $_ -c copy -bsf:v h264_mp4toannexb -f mpegts "$((ls $_).basename).ts"}
$inputs = ($s | %{"$((ls $_).basename).ts"}) -join "|"
& "$ffmpeg" -i "concat:$inputs" -c copy -bsf:a aac_adtstoasc output.mp4

Compress the frames (update Oct 2017)

This commandline to drop the frame-rate and shrink a file
ffmpeg -y -i source.mp4 -r 10 -s 1920x1080 -c:v libx264 -vcodec copy -b:v 3M -strict -2 -movflags faststart destination.mp4

No comments:

Post a Comment