ffmpeg-ing videos to actually run via QuickTime
Sometimes you have a video file in some ungodly format, and you just want to be able to it “normally” in, like, QuickTime on MacOS or whatever.
tl;dr
ffmpeg -i input_file.mkv -c copy -tag:v hvc1 output_file.mp4
The actually important part is the tag:v bit. See here for an Apple discussion thread about what and why and stuff.
The long way around
Let’s say it’s currently an .mkv file. If we frantically careen through Stack Overflow posts looking for The Answer, eventually we’ll arrive at someone telling us to invoke the following incantation:
ffmpeg -i input.mkv -c:a copy -c:v copy output.mp4
What does this mean? Who knows, ffmpeg is a fickle and arcane magick! But this works, right?
RTFM
Nope! It doesn’t. The file won’t play.
The real solution for me was to suck it up, sit down, and actually read the ffmpeg manual for once. It’s actually fairly understandable—although you do have to jump around a bit, it’s not accessible in a “crack it open from the start and read through it” kind of way.
Reading the manual helped me figure out lots of fun stuff like:
- You can have multiple simultaneous inputs and outputs! Which is why the explicit
-iflag is necessary—there's some implicit stuff going on with the order of input files passed and subsequent processing operations. - If you want to know what’s going on inside of a media file, you can use
ffprobeto get details about all the streams it contains, their metadata, etc. - Knowing the container file format and the codecs of the streams is generally sufficient to figure out if your media is able to run on a given device, provided you know the supported formats for that device.
The last two points are what helped me to figure out that the files I was working with had compatible audio and video codecs for QuickTime, but that something was off with the metadata. Apparently, there are scenarios where QuickTime needs you to spell out that the video is HEVC via a hvc1 tag on the video stream.
It felt really good to finally just go and read the manual myself, after several cumulative hours of skimming for quick solutions any time I’ve tried to do this before. Highly recommend.