Thursday, 23 November 2017

ffmpeg animated gif one-liner


Commandline to make a quick demo easy and to just by default make it autoplay in for example facebook. sorry if you have seen this all before, but this blog is my braindump.

.\bin\ffmpeg.exe -i .\cbc.wmv -b:v 50k -r 2 -y -ss 2.000 -t 11.000 .\cbc_T.gif

-r 2 = 2 frames per second
-b:v 50k = 50kbits bitrate need to add the k, and need to be specific that the rate is a video rate with :v
The bitrate did not have a significant impact on file size.
-ss = start from
-t = duration to convert

Hope this helps the next person. note, there are loads of similar blog posts, but had to capture some of the more salient parameters, because ffmpeg command parser often just ignores a parameter it cannot parse, so beware typos.

Joining clips

To join 2 clips -is a bit problematic in windows because the ffmpeg separator | character has a special meaning in dos, so I found the easiest was to create a response file.

file y:\20171122_173829.mp4
file y:\20171122_170515.mp4
file y:\20171122_173829.mp4


Save this text as files.txt (note that this file expects the path separator "/" not "\" , for some reason the [drive:\] protocol is fine with a "\", but paths must use a "/".

and then use the concat argument

C:\Tools\ffmpeg\bin>ffmpeg.exe -f concat -i .\files.txt -an -c copy -y .\20171122_173829all.mp4

notice use of -an to kill the audio track off

Add Audio

Lastly, to add and use an audio track using -shortest
ffmpeg.exe -i .\20171122_173829all.mp4 -i elevatormusak.mp3 -c copy -shortest -y .\20171122_173829final.mp4

No comments:

Post a Comment