Thursday, October 1, 2015

Process video (or audio) with ffmpeg - trim, cut, join without transcoding.

The general command is

ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... 

The option -c stands for the "codec" to be used.

 -c copy means the file is not re-coded.

-ss
followed by time  (like  00:03:05.0 ) is the start time: all before that point is removed

-t
followed by time (like 00:03:05.0 ) stands for the duration of output: all after that is removed

 -to serves to specify the end time inside the input (sometimes simpler to use instead of -t)


So:

To keep data after a start point (up to the end):

ffmpeg -i INPUT -c copy -ss START_TIME -map 0 OUTPUT




To keep data between two time points:




ffmpeg -i INPUT -c copy -ss START_TIME -to END_TIME -map 0 OUTPUT


To keep data of a certain duration after a certain point:



ffmpeg -i INPUT -c copy -ss START_TIME -t DURATION_TIME -map 0 OUTPUT


To keep data of a certain duration after beginning:



ffmpeg -i INPUT -c copy -t DURATION_TIME -map 0 OUTPUT




To keep data from beginning up to a time point:

ffmpeg -i INPUT -c copy -to TIME_POINT -map 0 OUTPUT



---

To join mpeg files (including transport files)

 ffmpeg -i "concat:INPUT-1|INPUT-2" -c copy -bsf:a aac_adtstoasc OUTPUT


Or:

create a file called `join.txt` with the content

file 'path-to-INPUT1'
file 'path-to-INPUT2'
file...etc


then

 ffmpeg -f concat -i join.txt OUTPUT

No comments:

Post a Comment