Here's a pretty rookie attempt at creating a shell script to squeeze videos into Twitter's 140s limitation:

for f in "$@"
    /Applications/ffmpeg -i $f -filter_complex "[0:v]setpts=140 / \ 
  $(/Applications/ffprobe -i $f -show_entries format=duration -v quiet -of csv="p=0") \
  * PTS[v];[0:a]atempo= \
  $(/Applications/ffprobe -i $f -show_entries format=duration -v quiet -of csv="p=0") \
  / 140[a]" -map "[v]" -map "[a]"  "${f%.*}_twitter.mp4"

It works, but it's pretty badly written. Can you help me improve it?

  1. How can I run ffprobe only once?
  2. Do I need ffprobe at all, or does ffmpeg have the duration of the input amongst its arguments?
  3. Will it encode faster with other settings (e.g. HW acceleration)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.