Convert MKV Files for Apple TV
MKV (or Matroska) is a container format usually used for video which isn’t directly playable on an Apple TV without special software. Rather than transcoding MKV files with ffmpeg
or front-end apps like Handbrake, one can simply copy the video and audio streams into a new MP4 file. Here’s the command that does just that:
ffmpeg -i video.mkv -c:v copy -c:a copy -movflags +faststart video.mp4
Notice we state copy
for both -c:v
(video) and -c:a
(audio) streams. We also set +faststart
as a -movflag
which isn’t strictly necessary but makes loading the whole file unnecessary before play starts. As Apple TV devices stream everything over the network rather than store things locally, this tends to cut down on the time between hitting “Play” and actually having the file play.
If the above doesn’t work, it is likley the video or audio is encoded in some format that isn’t nativly supported by Apple TV. Use ffprobe
to see what the formats of all the streams are. (Remember, MKV is a container format, not a video encoding format.)
ffprobe video.mkv
You’ll see something like this:
Input #0, matroska,webm, from 'video.mkv':
Metadata:
encoder : libebml v1.3.9 + libmatroska v1.5.2
creation_time : 2022-10-12T05:14:01.000000Z
Duration: 01:08:12.01, start: 0.000000, bitrate: 14028 kb/s
Chapters:
Chapter #0:0: start 0.000000, end 921.712456
Metadata:
title : Opening Credits
Chapter #0:1: start 921.712456, end 1228.518956
Metadata:
title : "Last one across the line"
Chapter #0:2: start 1228.518956, end 1771.227789
Metadata:
title : "The finish"
Chapter #0:3: start 1771.227789, end 2633.422456
Metadata:
title : Made for TV
Chapter #0:4: start 2633.422456, end 2910.115533
Metadata:
title : The Goodbye
Chapter #0:5: start 2910.115533, end 3068.398667
Metadata:
title : A grandfather clock
Chapter #0:6: start 3068.398667, end 4339.042000
Metadata:
title : End Credits
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn (default)
Metadata:
BPS-eng : 13385946
DURATION-eng : 01:08:12.010000000
NUMBER_OF_FRAMES-eng: 120009
NUMBER_OF_BYTES-eng: 8933516493
_STATISTICS_WRITING_APP-eng: mkvmerge v40.0.0 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2022-10-12 05:14:01
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
Metadata:
BPS-eng : 640000
DURATION-eng : 01:08:12.010000000
NUMBER_OF_FRAMES-eng: 136821
NUMBER_OF_BYTES-eng: 425061760
_STATISTICS_WRITING_APP-eng: mkvmerge v40.0.0 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2022-10-12 05:14:01
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2(eng): Subtitle: subrip (srt) (default)
Metadata:
BPS-eng : 74
DURATION-eng : 01:08:12.010000000
NUMBER_OF_FRAMES-eng: 1352
NUMBER_OF_BYTES-eng: 45169
_STATISTICS_WRITING_APP-eng: mkvmerge v40.0.0 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2022-10-12 05:14:01
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:3: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 120x176, 90k tbr, 90k tbn (attached pic)
Metadata:
filename : small_cover.jpg
mimetype : image/jpeg
Stream #0:4: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 213x120, 90k tbr, 90k tbn (attached pic)
Metadata:
filename : small_cover_land.jpg
mimetype : image/jpeg
Stream #0:5: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 600x882, 90k tbr, 90k tbn (attached pic)
Metadata:
filename : cover.jpg
mimetype : image/jpeg
Stream #0:6: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 1067x600, 90k tbr, 90k tbn (attached pic)
Metadata:
filename : cover_land.jpg
mimetype : image/jpeg
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
[mp4 @ 0x134804730] track 1: codec frame size is not set
Output #0, mp4, to 'video.mp4':
Metadata:
encoder : Lavf61.1.100
Chapters:
Chapter #0:0: start 0.000000, end 921.712456
Metadata:
title : Opening Credits
Chapter #0:1: start 921.712456, end 1228.518956
Metadata:
title : "Last one across the line"
Chapter #0:2: start 1228.518956, end 1771.227789
Metadata:
title : "The finish"
Chapter #0:3: start 1771.227789, end 2633.422456
Metadata:
title : Made for TV
Chapter #0:4: start 2633.422456, end 2910.115533
Metadata:
title : The Goodbye
Chapter #0:5: start 2910.115533, end 3068.398667
Metadata:
title : A grandfather clock
Chapter #0:6: start 3068.398667, end 4339.042000
Metadata:
title : End Credits
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 16k tbn (default)
Metadata:
BPS-eng : 13385946
DURATION-eng : 01:08:12.010000000
NUMBER_OF_FRAMES-eng: 128009
NUMBER_OF_BYTES-eng: 8933516493
_STATISTICS_WRITING_APP-eng: mkvmerge v40.0.0 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2022-10-12 05:14:01
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
Metadata:
BPS-eng : 640000
DURATION-eng : 01:28:58.272000000
NUMBER_OF_FRAMES-eng: 166821
NUMBER_OF_BYTES-eng: 427061760
_STATISTICS_WRITING_APP-eng: mkvmerge v40.0.0 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2022-10-12 05:14:01
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Press [q] to stop, [?] for help
[mp4 @ 0x134804730] Starting second pass: moving the moov atom to the beginning of the file
[out#0/mp4 @ 0x6000003c0000] video:8724137KiB audio:417052KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.054081%
size= 9146133KiB time=01:08:12.010000000 bitrate=14035.5kbits/s speed= 176x
Take a look through that to figure out what might be wrong. Worst case, transcode the file with ffmpeg
instead. Handbrake is a great app to make that easy and has good defaults forApple TV.