Skip to content

Instantly share code, notes, and snippets.

@mathdroid
Last active April 11, 2019 01:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mathdroid/9ace5037550f9a011f95733969a898c2 to your computer and use it in GitHub Desktop.
Save mathdroid/9ace5037550f9a011f95733969a898c2 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# Requirements:
# - `primitive` @ https://github.com/fogleman/primitive,
# - `imagemagick` @ http://www.imagemagick.org/script/index.php,
# - `ffmpeg` @ https://ffmpeg.org/
# Make sure your input photo is named `input.jpg` (variable support later!)
# keep yo folder neat
mkdir profilevideo
# Facebook's Profile Video restricts video length @ max = 7s
# We want to have a 60fps, looping (boomerang style) video.
# 3.5 * 60 = 210 frames for the looped video.
primitive -i input.jpg -o profilevideo/input.gif -n 1050 -vv # n=1050 gives 210 frames
convert profilevideo/input.gif profilevideo/pv_%05d.png
ffmpeg -framerate 60 -i profilevideo/pv_%05d.png -c:v libx264 -r 60 -pix_fmt yuv420p profilevideo/input1.mp4
ffmpeg -i profilevideo/input1.mp4 -vf reverse profilevideo/input2.mp4
ffmpeg -i profilevideo/input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts profilevideo/intermediate1.ts
ffmpeg -i profilevideo/input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts profilevideo/intermediate2.ts
ffmpeg -i "concat:profilevideo/intermediate1.ts|profilevideo/intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment