Trimming and editing h.264 mp4 video files without re-encoding - Eric Cheng

Trimming and editing h.264 mp4 video files without re-encoding

Articles

Simple video editing can be frustrating for content creators whom aren’t familiar with the process, and even people who work with video every day can struggle to find the right tools to accomplish quick edits. One issue is that most video editors force video re-encoding upon export, which results in potentially-long render times as well as degradation in quality. Higher-end tools like Adobe Premiere Pro CC can export in ways that minimize re-encoding; Adobe calls this Smart Rendering, and it only works with certain codecs and containers (for example, ProRes in Quicktime). This does little to help causal editors who might only want to do things like trim a long clip before sharing the video to social media, or quickly cut a few clips together into an edited video.

For simple trimming (and much more), I recommend downloading the free app, MPEG Streamclip, which is available in both Mac and Windows versions. MPEG Streamclip allows quick trimming of videos by setting of In and Out points.

Once you’ve set In and Out points, select Edit->Trim from the menu, or press ⌘-T (on a Mac) to trim the video, and you’re left with a video that contains only the part of the clip you want. From here, you can either Export to a variety of different formats (the various File->Export options), but you can also select File->Save As… (⌘-S) to save the clipped video without re-encoding (be sure to select MP4 as the filetype). MPEG Streamclip is an especially useful tool because it works well with video files encoded in H.264, which is the most popular video codec used in smartphones, cameras, and on the web. You can trim and save very quickly without any loss in quality.

Another thing that MPEG Streamclip does is save trimmed videos back into MP4 files. In my current work with 360 videos, this is essential because tools that inject the required metadata into edited videos (like Spatial Media Metadata Injector) only work well with MP4 files (and don’t work, for example, with Quicktime movies).

Trimming videos is useful for quick sharing, but it can also be useful to do quick editing using multiple video clips without needing to re-encode the edited video. Apple’s old Quicktime 7 Pro is still the best tool for this, at least, on OS X. Using Quicktime 7 Pro, you can set In and Out points to identify segments of video, and then copy and paste those video segments into a new video (you can create a new destination video in Quicktime 7 Pro by selecting File->New Player). Then, using File-Save As… and making sure “Save as self-contained video” is selected, you can save the edited video into a new file. Although you can also cut/copy/paste video segments in MPEG Streamclip, you can only open one video at a time, which means you can’t insert clips from other videos.

Quicktime 7 Pro is extremely powerful, but it’s no longer considered to be “modern” by Apple, which suggests that it won’t be around forever (it essentially hasn’t been touched since OS X 10.6 Snow Leopard). Also, when saving edited videos using Quicktime 7 Pro, you end up with a Quicktime movie (.mov), which plays well in the Apple ecosystem, but might not work well in others. For example, when working with 360 videos, I often need to insert spatial media metadata into quickly-edited videos saved using Quicktime 7 Pro, but because they are saved as MOV files, I need to run MPEG Streamclip to re-wrap the videos into MP4 files before running Spatial Media Metadata Injector.

The 360 video editing workflow ends up looking like this:

Edit in Quicktime 7 Pro; save to MOV -> Re-wrap to MP4 using MPEG Streamclip -> Inject metadata using Spatial Media Metadata Injector

Of course, when doing complicated edits that comprise more than just placing a bunch of clips next to each other, I use non-linear editors like Adobe Premiere Pro CC. When working with 360 videos, Premiere Pro CC 2015.03 and later include a “Video is VR” checkbox that injects the appropriate metadata into MP4/H.264, HEVC and Quicktime MOV files. But unless you’re working entirely with video files that support Adobe’s Smart Rendering, the videos will be re-encoded, resulting in quality loss and potentially-long rendering times.

I’ve discovered some other Mac apps that support re-wrapping video files without re-encoding, which are listed below.

  • MPEG Streamclip: supports trimming, in-single-video copy/cut/paste, and re-wrapping of H.264 video content (MOV, MP4) into both MOV and MP4 files
  • Quicktime Pro 7: supports copy/cut/paste to/from multiple videos and re-wrapping of H.264 video content into MOV files
  • CinePlay: supports trimming and re-wrapping of video content (MOV, MP4) into MOV files
  • Subler: supports re-wrapping of video content (MOV, MP4) into MOV files
  • ClipWrap: supports re-wrapping of AVCHD (m2t, m2ts) and HDV (m2t) into Quicktime MOV files*

Note that the all of these apps do much more than what I’ve noted here—I only write what is relevant for trimming and re-arranging H.264 video in MP4 and MOV containers. Also, this is by no means a complete list; if you know of others, please leave a comment and let everyone know! 

*ClipWrap isn’t useful for moving between MP4 and MOV files, but it is extremely useful for allowing normal Mac video players like Quicktime to play AVCHD and HDV video content. When they are wrapped in .m2t and .m2ts files (how they often come out of the camera), they can’t be played by Quicktime. When re-wrapped in Quicktime, they play fine.

If you got this far, you get a bonus! Here’s the clip of schooling sharks I used for this example. 😉