accurate cutting of video (+ audio) with ffmpeg
The behavior of -ss
changes depending if it used as an input or output option, and is often slower but can be more accurate when used as an output option. See the answer to ffmpeg converts video from specified time period slowly for more details and examples.
To change output quality for source.mp4
use the -crf
option with a value between 18-28 (23 is default). See the CRF section of the FFmpeg and x264 Encoding Guide for examples.
Your trimming command can be simplified:
ffmpeg -ss 577.92 -i source.mp4 -ss 0 -t 11.98 -c copy -map 0 clip1.mp4
I replaced -codec:v copy -codec:a copy
with -c copy -map 0
. This will copy all streams instead of just the first video and audio streams--although the input only has two streams due to your previous command. Since you can not scale without re-encoding, therefore being mutually exclusive with -codec:v copy
, and since your input is already scaled to the set size I removed the filter options.
If it is still not accurate enough then try:
ffmpeg -i source.mp4 -ss 577.92 -t 11.98 -c copy -map 0 clip1.mp4
It will be slower, but probably more accurate. See the links in the answer in the first link I provided for a description of the differences of these two examples.
Lastly, you should run source.mp4
through qt-faststart
(located in the tools directory in ffmpeg source), or use the -movflags faststart
option. This will relocate some data to the beginning of the file so it can begin playback before it is completely downloaded.