Search code examples
ffmpegvideo-processing

Comparison of two ffmpeg commands for video segment


I have two commands for making video segments in android ffmpeg

  • -ss startTime -i inputVideo -f segment -segment_time segmentDuration -reset_timestamps 1 -vcodec copy -b:v2 097152 -b:a 48000 -ac 2 -ar 22050 outputPath
  • -ss startTime -i inputVideo -f segment -segment_time segmentDuration -reset_timestamps 1 outputPath

I have tried them both and noticed that first command is very very fast than second

Since I am new to ffmpeg , i really don't know them meaning of every argument in these commands

Can anyone plz explain me why first command is better and will it cause any errors in future


Solution

  • In command #1 you are using -vcodec copy which enables stream copy mode for the video. This copies the video instead of encoding the video. Stream copying is much faster than encoding.

    Downside is that the segment muxer by default can only cut on keyframes when using stream copy. So -segment_time may not be accurate when using stream copy.

    If accuracy is super important then remove -vcodec copy as in command #2. This will encode the video instead of stream copy the video: much slower but cuts are accurate.