FFmpeg Video Segmentation Method

Source: Internet
Author: User

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:

  
 
 
  1. 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:

  
 
 
  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.