Extract a portion from a video
$ ffmpeg -i input.mp4 -ss 00:37:50 -t 00:00:20 -c copy output.mp4
Quicker with -c copy
as the stream is copied as is without re-encoding.
Update: Even quicker if we put the -ss
option before the input (to skip directly to the needed part):
$ ffmpeg -ss 00:53:25 -i "$p" -c copy subset.opus
$ ffprobe input.mp4
The following should show two streams at the very bottom:
- Stream #0:0 for video stream
- Stream #0:1 for audio stream
Extract audio/video
$ ffmpeg -i input.mp4 -map 0:1 -c copy audio.mp3
$ ffmpeg -i input.mp4 -map 0:0 -c copy video.mp4
$ ffmpeg -i video.mp4 -i audio.aac -c copy -map 0:0 -map 1:0 video-with-audio.mp4
The videos must've been encoded with the same codec.
$ vim files.txt
file 'video1.mp4'
file 'video2.mp4'
$ ffmpeg -f concat -i files.txt -c copy video-concat.mp4
Below a scaling-down is followed with a box blurring of 10px:
$ ffmpeg -i video-in.mp4 -filter:v scale=640:480,boxblur=10 video-out.mp4
$ ffmpeg -i input.mp4 -ss 00:07:00 -t 00:00:05 -filter:v subtitles=input.srt output.mp4
$ ffmpeg -i input.mp4 -ss 00:00:02 -frames:v 1 screenshot.jpg
Audio files downloaded from Youtube, usually in opus format, can be encoded as mp3 with a bitrate of 128K (# of bits processed each second) and a sample rate of 44100 (# of audio samples taken by second).
$ ffmpeg -i file.opus -b:a 128K -ar 44100 file.mp3