« Back to Index

[ffmpeg examples]

View original Gist on GitHub

Tags: #ffmpeg #crop #video #concat #split #resize

Example extract then concat.bash

# see the individual 'extract' and 'concat' examples below to understand this 'one liner' version.

ffmpeg -i 1989.02.20\ -\ Chi-Town\ Rumble\ 1989.mp4 -to 00:00:30 1.mp4 -ss 00:02:53 -to 00:05:07 2.mp4 -ss 00:26:53 -to 00:47:55 3.mp4 -ss 01:10:04 -to 01:11:46 4.mp4 -ss 01:29:09 -to 01:42:13 5.mp4 -ss 01:43:53 6.mp4 && printf "file '1.mp4'\nfile '2.mp4'\nfile '3.mp4'\nfile '4.mp4'\nfile '5.mp4'\nfile '6.mp4'" > concat.txt && ffmpeg -f concat -safe 0 -i concat.txt -c copy 1989.02.20\ -\ Chi-Town\ Rumble\ 1989--new.mp4 && rm {1,2,3,4,5,6}.mp4 && rm concat.txt && say all done

Split video into 10 minute chunks.bash

# https://unix.stackexchange.com/questions/1670/how-can-i-use-ffmpeg-to-split-mpeg-video-into-10-minute-chunks
#
ffmpeg -i input.mp4 -c copy -map 0 -segment_time 00:20:00 -f segment -reset_timestamps 1 output%03d.mp4

ffmpeg concat videos.bash

# https://ffmpeg.org/ffmpeg-formats.html#concat-1

cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

ffmpeg crop video and convert to a gif.bash

ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:20 -vf "fps=15,scale=480:-1:flags=lanczos" output.gif

ffmpeg crop video.bash

ffmpeg -i 2019-hack-week-vol1.mp4 -ss 00:05:36 -t 00:11:18 -async 1 cut.mp4

# note: -t represents the duration you want the new video crop to last for
#
#       we can also use -to to specify a specific finish time (which is much more practical to use)
#       $ ffmpeg -i foo.mp4 -ss 00:26:42 -to 00:32:11 -async 1 cut.mp4

ffmpeg extract segments from a video.bash

# https://superuser.com/questions/681885/how-can-i-remove-multiple-segments-from-a-video-using-ffmpeg
#
# the following command will generate three new videos (a.tvshow, c.tvshow, e.tvshow) from the single abcdef.tvshow
#
# we can then use the `concat` filter (shown earlier) to rejoin them together.
ffmpeg -i abcdef.tvshow -t 5 a.tvshow -ss 10 -t 5 c.tvshow -ss 20 -t 5 e.tvshow

ffmpeg resize video.bash

ffmpeg -i example.mov -vf "scale=2200:-1" resized.mov