nem.ec

Programming Information Security Recipes Personal Code Snippets

Convert video to a Twitter-friendly format

Twitter does not support some video encodings

Simple, but with minimum modification:

ffmpeg -i "$INPUT_FILE" -pix_fmt yuv420p -vcodec libx264 "$OUTPUT_FILE"

Complex, but resizes the video and may better support odd encodings:

ffmpeg -i "$INPUT_FILE" \
  -pix_fmt yuv420p -vcodec libx264 \
  -vf scale=640:-1 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" \
  -acodec aac -vb 1024k \
  -minrate 1024k -maxrate 1024k -bufsize 1024k \
  -ar 44100 -ac 2 -strict experimental -r 30 \
  "$OUTPUT_FILE";
Copied!

Use your own input

If you have values you'd like to use instead of the provided variables, type or paste your data into the variable inputs below. If Javascript is enabled, your text will automatically be added to the command and you can click to copy.