I've got an H264 video (Stored in an MP4 file). Each GOP is approx 10s long. I want to trim the first couple开发者_如何学Go of seconds off the video, which means I need to split the first GOP. Is there a way to do this without re-encoding the entire video?
I've got FFmpeg and x264 available. I'm happy to use either the FFmpeg command line, or my own program linked against ffmpeg of x264 libraries.
Thanks in advance!
I think you realize that some re-encoding is unavoidable. You may be able to avoid re-encoding the entire video using the following approach:
- Split the video into two parts: the first GOP and the rest of the video. You should be able to do this without re-encoding (use
-vcodec copy
) - Convert the first GOP into something that you can easily cut, such as YUV
- Cut the YUV file
- Re-encode the cut file using the same parameters as the original video (you can get these from
ffprobe
. - Join the re-encoded cut file with the rest of the video (from step one). Again, you would use
-vcodec copy
to ensure no re-encoding is performed.
I've never had to do this, but the FAQ seems to have a section on joining video files.
精彩评论