Skip to content

Instantly share code, notes, and snippets.

@zachselby
Last active September 9, 2022 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachselby/f341605a3735424948a5f33ff2bb9497 to your computer and use it in GitHub Desktop.
Save zachselby/f341605a3735424948a5f33ff2bb9497 to your computer and use it in GitHub Desktop.
ffmpeg Helper Script (Fade In or Out, Clip Trimming, Frame Rate Adjustments, Playback Rate)
#!/bin/bash
# Adjust Frame Rate
#
# Input File | Video Filter | Output File
ffmpeg -i "video-001.mov" -vf "fps=12" "video-001.mp4"
# ^ Lower framerate for smaller file
# Trim From Start and End Times
#
# Input File | Starting Timecode | Output Length | Output File
ffmpeg -i "video-002.mov" -ss 00:00:00 -t 00:02:53 "video-002.mp4"
# ^ Start at 0 sec ^ Output 2 min 53 sec after start point
# Fade In
#
# Input File | Video Filter | Output File
ffmpeg -i "video-003.mov" -vf "fade=t=in:st=0:d=1" "video-003.mp4"
# ^ Fade In from 0 sec for duration of 1 sec
# Fade Out
#
# Input File | Video Filter | Output File
ffmpeg -i "video-004.mov" -vf "fade=t=in:st=10:d=1" "video-004.mp4"
# ^ Fade Out from 10 sec for duration of 1 sec
# Fade In and Fade Out
#
# Input File | Video Filter | Output File
ffmpeg -i "video-005.mov" -vf "fade=t=in:st=10:d=1,fade=t=out:st=74:d=1" "video-005.mp4"
# ^ Fade In from 0 sec for 1 sec, Fade Out from 74 sec for 1 sec
# Combined: Trim Start and End, Fade In and Out, and Change Framerate
#
# Trim beginning at 10 sec
# Output 1 min 5 sec from start point
# Fade In for 1 sec at 10 sec start point
# Fade Out for 1 sec at end (start + output time = 75 - 1 for fade = 74 sec start for 1 sec fade)
# Convert to 12 frames per second (fps) for smaller filesize
# Convert from MOV to MP4 with defaults, for better compression
ffmpeg -i "video-006.mov" -ss 00:00:10 -t 00:01:05 -vf "fps=12,fade=t=in:st=10:d=1,fade=out:st=74:d=1" "video-006.mp4"
# Boost Playback Rate of Video and Audio
#
# Input File | Video Filter - 1.3x rate (1/1.3) | Audio Filter - 1.3x rate | Output File
ffmpeg -i "1.mov" -vf "setpts=0.7692307692*PTS" -af "atempo=1.3" "2.mp4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment