What options are available to _losslessly_ trim mp4/m4v video on 10.8 or above? I have some DRM-free m4v video that I would like to edit by trimming here and there.


QuickTime X  ($0)


Pros:  free, built-in to OS X
Cons:  selector to choose 'start' and 'end' times is not very easy to use to get precise in/out

iMovie ($15, or free if you have bought a recent Mac)


Pros: free
Cons: can't handle mp4/m4v directly, has to be re-encoded [I believe]

QuickTime 7 Pro ($30)


Pros: Can make very precise (to the frame) edits
Cons: saves only as .mov not .mp4/.m4v 

SimpleMovieX ($40)


Pros: claims to be able to do this (although I tried the demo and found the UI so terrible I can't even verify if it works, and if it does, if it does anything that QuickTime X cannot)
Cons: appears to be 'abandonware' as it hasn't even seen a minor update in well over a year, MacUpdate reviews are nearly entirely negative, going back to 2009, including slow- or no- responses from the developer.



Are there other good options out there*? If so, what are they, and what are their pros/cons?

* I specified "good" because Google is useless for topic as the results are littered with sites offering “reviews” of software that by some mere coïncidence they also happen to sell. (Most of the sites and most of the software appear very similar as well.) There's clearly a lot of crap out there
iMovie (not lossless, but better than before)

iMovie v10 (released some time after the question was originally asked) now better handles more media types, so avoids the import re-encode for most H.264 (mp4, m4v, mov, AVHDC, mts, mt2s) content.

It will still, however, re-encode on export so cannot be technically lossless—another new feature, however, is the ability to customise the export quality, which can be closer-to-lossless. I suspect this part of the answer can apply equally to other 'project driven' video editing software (e.g. Premiere or Final Cut) because I think they all generally re-encode on output, though are usually very easy to use for precise trimming.

Personally, I generally think a single re-encode isn't a huge problem, but understand you did specifically ask for a lossless solution, so...

Lossless (but way more complicated!)

There are technical limitations as to how precisely you can cut a video without having to re-encode at least some part of it, and it basically depends on the i-frame frequency. If every frame is an i-frame, you can cut anywhere, but if they're only every few seconds, then you can only cut losslessly at those i-frames without losing content or having to re-encode (at least part of the stream) so it can start with an i-frame.

ffmpeg

This SO Q&amp;A specifically raises the question of how to cut between i-frames using ffmpeg. I don't know of any GUI apps to do this, but basically you run a command something like the following:

ffmpeg -i input.m4v -vcodec copy -acodec copy -ss 00:01:20.000 -t 00:37:50.000 output.m4v


The two times specified are start and duration, and can be specified either as seconds or hh:mm:ss.ss, and the -acodec copy and -vcodec copy tell ffmpeg not to re-encode.

I'm not exactly sure what happens if you cut too early, but I think the video is essentially blank (or maybe corrupt, depending on player) until it encounters an i-frame. So you'll probably want to find the nearest i-frame before your cut. This answer solves that problem using ffprobe and awk, albeit a little awkwardly. Essentially you use ffprobe to scan the frames and find the nearest keyframe (flags=K) before your ideal cut-point. Full output for each frame of the video can be seen like this:

ffprobe -select_streams v -show_frames &lt;INPUT&gt;


The linked answer supplies this command to find a keyframe before a specific time:

ffprobe -select_streams v -show_frames -v quiet INPUT.mp4 | 
awk -F= ' 
  /pict_type=/ { if (index($2, "I")) { i=1; } else { i=0; } } 
  /pkt_pts_time/ { if (i &amp;&amp; ($2 &gt;= 150)) print $2; }  
' | head -n 1


And finally, if you really need to cut somewhere between two i-frames, you can split the video and re-join. Based on the info from this answer, it should be something like:

ffmpeg -f concat -i list_of_videos.txt -c copy OUTPUT.mp4


Where list_of_videos.txt is a simple text file listing the files you want to concatenate.

Summary

iMovie is probably good enough for most cases (since v10), and very easy.

ffmpeg can do it losslessly (or very close to losslessly), with a bit of fiddling; level of difficulty depends on how picky you are about the precise starting point, and frequency of i-frames.