FFmpeg can be said to be a versatile encoder. I listed all ffmpeg commands in the ffmpeg command details, but he re-encoded the video when I split the video, it is obviously a copy, but it becomes an encode.
The command I used is as follows:
- ffmpeg -vcodec copy -acodec copy -ss 01:00:00 -t 00:00:30 -i input_file_h264.mp4 output_file.mp4
I only wanted to split a video, but I re-encoded the separated video, and the image quality became terrible. Many people on the Internet say it is a problem with the FFMPEG version. After that, I switched to the old version and used the same command to split the video. Isn't it possible to split the new version?
I still felt uncomfortable when I used the MOD version for a while, so I checked some foreign materials and found the problem.
In the FFMPEG manual, codec is written as follows:
'-C [: stream_specifier] codec (input/output, per-stream )'
'-Codec [: stream_specifier] codec (input/output, per-stream )'
Select an encoder (when used before an output file) or a decoder (when used before an input file) for one or more streams. codec is the name of a decoder/encoder or a special value copy (output only) to indicate that the stream is not to be re-encoded.
This means that if you put-Codec in front of the output file, it will be treated as an encoder and decoder before the input file ). Let's take a look at the commands I used.-codec is at the beginning, that is, before the input file, copy is treated as a decoder, this is why many people encounter unknown decoder 'copy. Copy is a special encoder, So-codec must be placed before the output file.
There is also an explanation of the-s option:
'-SS position (input/output )'
When used as an input option (before-I), seeks in this input file to position. when used as an output option (before an output filename), decodes but discards input until the timestamps reach position. this is slower, but more accurate.
Position may be either in seconds or in HH: mm: ss [. xxx] form.
This means that if-SS is used as the input option, it should be placed before-I and before the output file as the output option. We want to capture a video and use it as an input option. Therefore,-SS must be valid before-I. Otherwise, it will take a long time to search for-ss.
The command for splitting the video is changed:
- ffmpeg -ss 01:00:00 -i input_file_h264.mp4 -vcodec copy -acodec copy -t 00:06:00 output_file.mp4
Sure enough, FFMPEG of the latest version can also be used for separation. From the above, we can find that the order of some options is very important, and the wrong order may sometimes lead to very different results, not only FFMPEG, x264, mencoder, and so on.
FFmpeg Video Segmentation Method