Skip to content

Instantly share code, notes, and snippets.

@simivar
Last active April 19, 2023 12:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simivar/3fa6f5764635fbf5aaed77b291dff109 to your computer and use it in GitHub Desktop.
Save simivar/3fa6f5764635fbf5aaed77b291dff109 to your computer and use it in GitHub Desktop.
ffmpeg - GIF timelapse with timestamp clock

ffmpeg - GIF timelapse with timestamp clock

First frame of our input movie: First frame of our Input movie

Add timestamp clock to video

ffmpeg -i input.mov -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:expansion=normal: text='%{pts \\: hms}': fontcolor=white:fontsize=48: x=(w-text_w)/2: y=h-th-10: box=1: boxcolor=black: boxborderw=5: line_spacing=32" -vcodec libx264 -vb 2600k -strict -2 -preset slower -f mp4 -an timestamp_clock.mp4

In the first step we take our input movie input.mov and add at bottom center a black box with white timestamp text on it.

First frame of video with the timestamp clock

Speed up the video

ffmpeg -i timestamp_clock.mp4 -an -vf "setpts=PTS/35" speedup_timestamp.mp4

Here, we speed up the video to make the "timelapse". We speed it up 35 times which you can easily change in the command.

First frame of speed up video with clock

Add speed-up information

ffmpeg -i speedup_timestampImage 03-11-2020 at 17.05.jpeg.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:expansion=normal: text='x35 speed': fontcolor=orange:fontsize=48: x=(w-text_w)/2: y=h-th-60" -vcodec libx264 -vb 2600k -strict -2 -preset slower -f mp4 timestamp_final.mp4

In the last step we add information about how much the video is speed up right above our clock.

First frame Timestamp final (speed-up version with clock and speed info)

Convert to GIF

ffmpeg -i timestamp_final.mp4 -loop -1 timestamp_final.gif

And at last we generate GIF out of our MP4. Here, you can change value of the -loop setting: use -1 for no loop, 0 for looping indefinitely (default).

Final GIF with timestamp clock and speed-up

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