Useful ffmpeg Recipes

🔖 tools ⏲️ 1 minute to read

A few ffmpeg commands I find useful, so I don't need to keep reading the documentation.

Contents

  1. Convert to mp4
  2. Concatenate
  3. Speed Up
  4. Seek and Crop
  5. Resize

Convert to mp4

Converts the input to mp4 using libx264, using a quality of 35 (0-51, where o is lossless) and 256k audio compression (high quality). This video should be compatible with most devices.

ffmpeg -i "input.ext" -c:v libx264 -crf 35 -b:a 256k "output.mp4"

Concatenate

Concatenates the videos specified in file.txt

ffmpeg -f concat -safe 0 -i "file.txt" -c copy "output.ext"

The contents of file.txt (must be single quotes)

file 'path/to/file1.ext'
file 'path/to/file2.ext'
file 'path/to/file3.ext'
...

Speed Up

Speeds up the input video 256 times, and strips the audio with -an

ffmpeg -i "input.ext" -an -filter:v "setpts=PTS/256" "output.ext"

Seek and Crop

Do the following:

  • -ss 10 seek to 10 seconds
  • -t take 4 seconds of video
  • crop=w=1280:h=500:x=0:y=110 take a 1280×500 box at coordinate 0,110
ffmpeg -ss 10 -t 4 -i "input.ext" -filter:v "crop=w=1280:h=500:x=0:y=110" "output.ext"

Resize

Resize the video to 640 pixels wide, making ffmpeg calculate the height based on the aspect ratio of the input video.

ffmpeg -i "input.ext" -vf scale=640:-1 "output.ext"

🏷️ video convert mp4 seek resize input ffmpeg crop audio recipe command documentation libx264 0-51 lossless

⬅️ Previous post: Force Refresh Rocket.Chat Snap SSL Certificate via Caddy

➡️ Next post: Live GivEnergy PV Inverter Data in Home Assistant

🎲 Random post: Capturing and Uploading Screenshots in UE4

Comments

Please click here to load comments.