… for Codecs & Media

Tip #907: Why Can’t I Subclip H.264 Media?

Larry Jordan – LarryJordan.com

Extracting media from compressed files almost always requires recompression.

I-frame (top) vs. GOP compression. Edits can only be made on the green I-frames.

Topic $TipTopic

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!

6 Comments
  1. Loren
    Loren says:

    Agh! H.264 is a very very good acquisition (camera) and highly scalable delivery (export) format, but it’s just as Larry indicates. Never ever do I use it to edit. If my machine is challenged, I’ll transcode and import as ProRes LT (light) or Proxy– which is not a very large size file. That’s why Apple developed these “laptop flavors” of ProRes.

    If I am stuck editing in a H.264 timeline, I will at least set the timeline render codec to ProRes.

    Editing with GOP codecs like H.264 not only saps computer cycles needed to reconstitute image from essentially air (which includes bits of changed image frame to frame), and needed for renders, but it can also weak havoc with multiple-track work like superimposed titles, transitions, and effects. This is not a vertical editing codec. GOP was simply not designed for editing!! 95% of the time, it pays off handsomely to transcode to a workable flavor of ProRes and enjoy your craft.

    Best, as always,
    Loren

    Reply
  2. Alan Nesbitt
    Alan Nesbitt says:

    Hi Larry, Is it better,then, to convert to ProRes 422, find the material that is needed in FCPX and then export out to H.264 or as you often suggest make a ProRes Master and use Compressor to output to H.264?
    Thanks Alan N.

    Reply
    • Larry Jordan
      Larry Jordan says:

      Alan:

      First, where possible, I would simply import the entire clip and work with that.

      If that is not an option, convert it to ProRes and extract the segments you need. Transcoding is unavoidable for these formats, so transcode into something higher quality to preserve as much image quality as you can before it gets recovered to H.264.

      Larry

      Reply

Leave a Comment

Want to join the discussion?
Feel free to contribute!
All comments are moderated.

Leave a Reply

Your email address will not be published. Required fields are marked *