… for Codecs & Media
Tip #907: Why Can’t I Subclip H.264 Media?
Extracting media from compressed files almost always requires recompression.
I got an email recently from a reader asking for a way to export subclips from an H.264 video without recompressing it, because he didn’t want to lose any image quality.
The problem is that this can’t be done. Here’s why.
In an ideal world, each frame in a video should be self-contained. This is called I-frame compression and is illustrated by the top line in the screen shot.
The benefit to I-frame compression is that each frame is fully self-contained, high-quality and very efficient to edit. The disadvantage is that the media files are very large. ProRes, GoPro Cineform and DNx are all I-frame formats.
However, many cameras, to save storage space and stay within the technical bandwidth of MicroSD camera cards, compress the media using GOP (pronounced “gop”) compression (the bottom line in the screen shot). H.264 and HEVC, use this format.
NOTE: Not all GOP groups are 15 frames, some use 7 frames or other frame counts. However, the overall concept is the same.
What a GOP group does is store a complete image on the first frame of the group, then only record the changes for each group of pixels, essentially as a text file, for each frame that follows in the group.
The benefit to GOP compression is that the media files are very small. But, in order to display an image the computer needs to find the I-frame at the start of the group, then calculate the changes for each succeeding frame until it gets to the frame you want to display. This additional calculation is why we describe this format as “inefficient.”
Every GOP clip MUST start with an I-frame. If I wanted to extract a portion of a GOP-compressed clip, say starting at frame 10, I would need to first, recreate an I-frame for frame 10, then rebuild the entire GOP structure during export for the rest of the clip. That means re-compressing the entire clip to rebuild the GOP structure.
This is why recompressing already compressed GOP media tends to look bad; the computer needs to rebuild and recompress every frame to recreate the GOP structure.
This is also the reason that working with I-frame media is faster with overall higher image quality, because the CPU needs to work far less to calculate and display images.
Please rate the helpfulness of this tip.
Click on a star to rate it!