#!/bin/sh ## ## SCRIPT: 00_ffmpeg_mp4_CLIP.sh ## ## PURPOSE: Clip a section out of a '.mp4' movie file --- based on a user-specified ## start time and a user-specified end-time of the clip. ## ## Example start and end times: ## 00:00:16 and 00:01:10 ## ## METHOD: ## 1) Put this script in the directory of '.mp4' movie files ## that you want to clip. ## 2) Edit this script to set the input filename and start & end times. ## 3) Run the script in a terminal window positioned at the directory ## that holds this script and the movie files. ## ## REFERENCE: ## https://trac.ffmpeg.org/wiki/Seeking ## ## Examples: ## ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4 ## ffmpeg -i video.mp4 -ss 00:01:00 -to 00:02:00 -c copy cut.mp4 ## ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4 ## ## ffmpeg -ss 00:03:00 -i video.mp4 -t 60 -c copy -avoid_negative_ts 1 cut.mp4 ## ## Script started: 2021jul10 ## ## NOT GOOD: (dark for ~14 secs) # ffmpeg \ # -ss 00:00:16 \ # -i input.mp4 \ # -to 00:01:10 \ # -c copy \ # -copyts \ # 00_temp.mp4 ## FAIR: (BUT start-stop times not exact) # ffmpeg \ # -ss 00:00:16 \ # -i input.mp4 \ # -to 00:00:50 \ # -c copy \ # 00_temp.mp4 ## GOOD: ## NOTE: ## If a few seconds at beginning are black, ## increase the '-ss' time a few seconds. ffmpeg \ -i input.mp4 \ -ss 00:04:20 \ -to 00:05:00 \ -c copy \ 00_temp.mp4 # totem 00_temp.mp4 # ffplay 00_temp.mp4 exit