All Projects → yuanqing → ffmpeg-cheatsheet

yuanqing / ffmpeg-cheatsheet

Licence: other
📼 A cheatsheet for common video processing operations in FFmpeg

Projects that are alternatives of or similar to ffmpeg-cheatsheet

R Web Scraping Cheat Sheet
Guide, reference and cheatsheet on web scraping using rvest, httr and Rselenium.
Stars: ✭ 207 (+35.29%)
Mutual labels:  cheatsheet
Rl Cheatsheet
RL Notation and Pseudocode for Udacity's MLND program
Stars: ✭ 245 (+60.13%)
Mutual labels:  cheatsheet
8086-cheatsheet
8086 Microprocessor Cheat sheet with Programs
Stars: ✭ 81 (-47.06%)
Mutual labels:  cheatsheet
Command Mobile Penetration Testing Cheatsheet
Mobile penetration testing android & iOS command cheatsheet
Stars: ✭ 221 (+44.44%)
Mutual labels:  cheatsheet
Cli Debugging Cheatsheets
🔥 Collection of command-line debugging cheatsheets for multiple languages and runtimes
Stars: ✭ 239 (+56.21%)
Mutual labels:  cheatsheet
Nginx Cheatsheet
A quick reference to common server configurations from serving static files to using in congruency with Node.js applications.
Stars: ✭ 247 (+61.44%)
Mutual labels:  cheatsheet
Awesome Ctf Cheatsheet
CTF Cheatsheet
Stars: ✭ 204 (+33.33%)
Mutual labels:  cheatsheet
vue-unit-testing-cheat-sheet
🔬 My cheat sheet for testing vue components with jest and vue-test-utils
Stars: ✭ 101 (-33.99%)
Mutual labels:  cheatsheet
Cobalt Strike Cheatsheet
Some notes and examples for cobalt strike's functionality
Stars: ✭ 241 (+57.52%)
Mutual labels:  cheatsheet
ruuand.github.io
Wiki for stuff
Stars: ✭ 30 (-80.39%)
Mutual labels:  cheatsheet
Angular Awesome List
Список ресурсов по Angular на русском
Stars: ✭ 224 (+46.41%)
Mutual labels:  cheatsheet
Matplotlib Cheatsheet
Matplotlib 3.1 cheat sheet.
Stars: ✭ 2,806 (+1733.99%)
Mutual labels:  cheatsheet
Huge Collection Of Cheatsheet
Share of my Huge Collection of Cheatsheet (Coding, Cheat, Pinouts, Command Lists, Etc.)
Stars: ✭ 250 (+63.4%)
Mutual labels:  cheatsheet
Rust Cheatsheet
A type-based Rust cheatsheet
Stars: ✭ 220 (+43.79%)
Mutual labels:  cheatsheet
docker-cheat-sheet
Important Docker Commands Ordered by Compute (Services), Network, Storage then by Docker CLI, Dockerfile, Compose, and Swarm
Stars: ✭ 21 (-86.27%)
Mutual labels:  cheatsheet
Es6 All The Things
Collection of ES6 goodies for next-level dev 🤓💻
Stars: ✭ 206 (+34.64%)
Mutual labels:  cheatsheet
Stanford Cme 106 Probability And Statistics
VIP cheatsheets for Stanford's CME 106 Probability and Statistics for Engineers
Stars: ✭ 242 (+58.17%)
Mutual labels:  cheatsheet
hackthebox
Notes Taken for HTB Machines & InfoSec Community.
Stars: ✭ 286 (+86.93%)
Mutual labels:  cheatsheet
quickref
Git quick reference application for android
Stars: ✭ 111 (-27.45%)
Mutual labels:  cheatsheet
Bootstrap4 Cheatsheet
Bootstrap 4 Cheat Sheet
Stars: ✭ 254 (+66.01%)
Mutual labels:  cheatsheet

FFmpeg Cheatsheet

A cheatsheet for common video processing operations in FFmpeg

Operations

Use the -y flag to override the output file if it exists.

Audio-video sync

Reference

# Delay audio by 3 seconds
$ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 0:v -map 1:a -codec:a copy -codec:v copy output.mov

# Delay video by 3 seconds (ie. advance audio by 3 seconds)
$ ffmpeg -i input.mov -itsoffset 3 -i input.mov -map 1:v -map 0:a -codec:a copy -codec:v copy output.mov
  • The second -i flag must come immediately after the -itsoffset flag.

Crop

Reference

# Crop to width 360, height 640
$ ffmpeg -i input.mov -filter:v 'crop=360:640:0:0' -codec:a copy output.mov

# Crop to width 360, height 640, starting from coordinates (10, 20)
$ ffmpeg -i input.mov -filter:v 'crop=360:640:10:20' -codec:a copy output.mov

Format

Reference

# Convert to GIF
$ ffmpeg -i input.mov output.gif

# Convert from GIF
$ ffmpeg -i input.gif output.mov

# Convert between non-GIF formats
$ ffmpeg -i input.mov -codec:v copy -codec:a copy output.mp4

Frame rate

Reference

# Change the frame rate to 12
$ ffmpeg -i input.mov -filter:v 'fps=fps=12' -codec:a copy output.mov

Strip audio

Reference

# Remove audio
$ ffmpeg -i input.mov -codec:v copy -an output.mov

Resize

Reference

# Resize to width 360, height 640
$ ffmpeg -i input.mov -filter:v 'scale=360:640' -codec:a copy output.mov

# Resize to width 360, maintaining the aspect ratio
$ ffmpeg -i input.mov -filter:v 'scale=360:-1' -codec:a copy output.mov

# Resize to height 640, maintaining the aspect ratio
$ ffmpeg -i input.mov -filter:v 'scale=-1:640' -codec:a copy output.mov
  • Set either width or height to -1 to maintain the aspect ratio.

Reverse

Reference

# Reverse
$ ffmpeg -i input.mov -filter:v 'reverse' -filter:a 'areverse' output.mov

Rotate

Reference

# Rotate 90 degrees clockwise
$ ffmpeg -i input.mov -filter:v 'transpose=1' -codec:a copy output.mov

# Rotate 90 degrees counter-clockwise
$ ffmpeg -i input.mov -filter:v 'transpose=2' -codec:a copy output.mov

# Rotate 180 degrees
$ ffmpeg -i input.mov -filter:v 'transpose=1,transpose=1' -codec:a copy output.mov

Speed

Reference

# Quarter the speed
$ ffmpeg -i input.mov -filter:v 'setpts=4*PTS' -filter:a 'atempo=0.5,atempo=0.5' output.mov

# Halve the speed
$ ffmpeg -i input.mov -filter:v 'setpts=2*PTS' -filter:a 'atempo=0.5' output.mov

# Double the speed
$ ffmpeg -i input.mov -filter:v 'setpts=0.5*PTS' -filter:a 'atempo=2' output.mov

# Quadruple the speed
$ ffmpeg -i input.mov -filter:v 'setpts=0.25*PTS' -filter:a 'atempo=2,atempo=2' output.mov
  • Use the formula 1 ÷ speed to compute the value of setpts.

    • Half the speed: setpts=2*PTS since 1 ÷ 0.5 = 2.
    • Double the speed: setpts=0.5*PTS since 1 ÷ 2 = 0.5.
  • The value of each atempo filter must be between 0.5 and 2.

    • Quarter the speed: atempo=0.5,atempo=0.5 since 0.5 × 0.5 = 0.25.
    • Quadruple the speed: atempo=2,atempo=2 since 2 × 2 = 4.

Subtitles

Reference

# Write subtitles into video
$ ffmpeg -i input.mov -filter:v 'subtitles=subtitles.srt' -codec:a copy output.mov

# Write subtitles into video, with custom subtitle styles
$ ffmpeg -i input.mov -filter:v "subtitles=subtitles.srt:force_style='FontName=Menlo Bold,Fontsize=18'" -codec:a copy output.mov

Trim

Reference

# Trim from 0:05 to 0:10
$ ffmpeg -ss 0:05 -to 0:10 -i input.mov -codec:v copy -codec:a copy output.mov

# Trim from 0:05 to the end of the video
$ ffmpeg -ss 0:05 -i input.mov -codec:v copy -codec:a copy output.mov
  • The -ss and -to flags must come before the -i flag.

Volume

Reference

# Halve the volume
$ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=0.5' output.mov

# Double the volume
$ ffmpeg -i input.mov -codec:v copy -filter:a 'volume=2' output.mov

Relevant CLI flags

Reference

ffmpeg
  -an
  -ss <timestamp>
  -to <timestamp>
  -itsoffset <offset>
  -i <input>
  -map <stream>
  -codec:a <codec>
  -codec:v <codec>
  -filter:a <filtergraph>
  -filter:v <filtergraph>
  -y
  <output>

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].