Skip to content

Instantly share code, notes, and snippets.

@Telematica
Last active June 25, 2023 17:55
Show Gist options
  • Save Telematica/d65c9b8c9928d00778e497f470431c94 to your computer and use it in GitHub Desktop.
Save Telematica/d65c9b8c9928d00778e497f470431c94 to your computer and use it in GitHub Desktop.
FFmpeg - Scripts, tips, tutorials
# Cutting the videos based on start and end time using ffmpeg
# https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg
# https://superuser.com/questions/138331/using-ffmpeg-to-cut-up-video
ffmpeg -ss 00:11:00.0 -i vid.mp4 -t 00:00:20.0 a.mp4
# How can I use ffmpeg to split MPEG video into 10 minute chunks?
# https://unix.stackexchange.com/questions/1670/how-can-i-use-ffmpeg-to-split-mpeg-video-into-10-minute-chunks
ffmpeg -i input.mov -threads 3 \
-vcodec copy -f segment -segment_time 10:00 -reset_timestamps 1 \
cam_out_h264_%02d.mp4
# Remove audio from video file with FFmpeg
# https://superuser.com/questions/268985/remove-audio-from-video-file-with-ffmpeg
input_file=example.mkv
output_file=example-nosound.mkv
ffmpeg -i $input_file -c copy -an $output_file
# The most efficient way to generate mp4 video containing looped boomerang-alike video file?
# https://stackoverflow.com/a/57247676/1391803
ffmpeg -i input_loop.mp4 -filter_complex "[0]reverse[r];[0][r]concat,loop=5:250,setpts=N/55/TB" output_looped_video.mp4
# https://www.bogotobogo.com/FFMpeg/ffmpeg_select_scene_change_keyframes_tile_Creating_a_mosaic_of_screenshots_from_a_movie.php
# FFMPEG - CREATING A MOSAIC OF SCREENSHOTS FROM A MOVIE : SCENE CHANGE DETECTION AND KEYFRAMES - 2020
ffmpeg -ss 00:00:05 -i file.mp4 -frames 1 -vf "select=not(mod(n\,400)),scale=160:120,tile=4x3" tile.png
ffmpeg -i file.mp4 -vf select='gt(scene\,0.4)',scale=160:120,tile -frames:v 1 file.png
ffmpeg -i file.mp4 -vf select='gt(scene\,0.2)',scale=160:120,tile -frames:v 200 file.png
# https://stackoverflow.com/questions/12026381/ffmpeg-converting-mov-files-to-mp4
# ffmpeg - Converting MOV files to MP4
ffmpeg -i input.mov -q:v 0 output.mp4
# @todo
# https://stackoverflow.com/questions/42255139/ffmpeg-merge-two-videos-into-one-with-side-by-side-same-quality-output
# https://unix.stackexchange.com/questions/233832/merge-two-video-clips-into-one-placing-them-next-to-each-other
# How can I get the resolution (width and height) for a video file from a linux command line?
# https://stackoverflow.com/questions/684015/how-can-i-get-the-resolution-width-and-height-for-a-video-file-from-a-linux-co/27831698#27831698
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment