Skip to content

Instantly share code, notes, and snippets.

@CornerSyrup
Last active April 5, 2025 10:26
Show Gist options
  • Save CornerSyrup/82125ac249b7a6558bca4a88ebbb24a8 to your computer and use it in GitHub Desktop.
Save CornerSyrup/82125ac249b7a6558bca4a88ebbb24a8 to your computer and use it in GitHub Desktop.
cli tools common options

FFmpeg

Check the integrity

It will encode video to null (or /dev/null).

ffmpeg -v error -i problem_video.mp4 -f null -

Add -c:v h264_nvenc to use NVIDIA GPU. Use 2>> error.log to pipe stderr to file.

Capture an image from video

ffmpeg -ss 01:23:45 -i input.mp4 -frames:v 1 -q:v 2 output.jpg

For JPEG output use -q:v to control output quality. Full range is a linear scale of 1-31 where a lower value results in a higher quality. 2-5 is a good range to try.

Extract video stream from video

ffmpeg -i source.mp4 -an -c:v copy output.mp4

Extract audio stream from video

ffmpeg -i source.mp4 -vn -c:a copy output.mp4

Zip video with audio

It will not re-encode the video and audio, so it will be done very fast.

ffmpeg -i "path/to/video.mp4" - i "path/to/audio.m4a" -c:a copy -c:v copy "path/to/output.mp4"

Play seperated audio and video

It will zip audio and video in AVI format and output to stdout pipe, then ffplay will play the stream from stdin

ffmpeg -i "path/to/video.pm4" -i "path/to/auido.m4a" -c copy -f avi - | ffplay -

Convert 2D video into SBS full size 3D video

ffmpeg.exe -i input.mp4 -filter_complex "[0:v][0:v]hstack[video]" -map "[video]" -map 0:a output.mp4

Covert 2D video into SBS full size 3D video with padding

It will convert a 720p vertical video into a 1080p horizontal video.

ffmpeg -i input.mp4 -filter_complex "[0:v]pad=1280:1280:(ow-iw)/2:0[left];[0:v]pad=1280:1280:(ow-iw)/2:0[right];[left][right]hstack[joined];[joined]scale=1920:1080:flags=lanczos[output]" -map "[output]" -map 0:a output.mp4

FFprobe

Check special video

$ ffprobe -v error -show_entries format_tags=com.apple.quicktime.spatial.format-version -of default=noprint_wrappers=1:nokey=1 video.mp4
# 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment