Web optimizing MKV for Roku playback with FFMPEG?

Server Version#: 1.21.3.4021
Player Version#: 6.7.9.6822-21ea6a8da-Plex

MP4 files can be web optimized by applications like Handbrake or Plex’s own Optimize tool. They do this by relocating the file’s metadata from the back of the file to the front of the file. This decreases the amount of time it takes the client to begin streaming the file. I’m trying to do this for an MKV file using FFMPEG, but I’ve run into a problem.

I ran the following command:

ffmpeg -i input.mkv -map 0 -c copy -reserve_index_space 50k output.mkv

Its purpose is to take “input.mkv,” streamcopy all video/audio/subtitle tracks (-map 0 -c copy), reserve 50kB at the front of the file for the metadata (-reserve_index_space 50k), and package the new file as “output.mkv.” Supposedly, 50kB is a safe amount for an hour of 1080p content; the input MKV file is only 40 minutes long, so this should be safe.

The command successfully executed after ~30 seconds. The output file contains all the tracks of the input file (as it should). All seems well and good. However when the output file is uploaded to Plex and I click “Get Info,” the file is not described as “web optimized.” In the past, I have web optimized media content with both Handbrake and Plex, so I know Plex can and does tag optimized content as such. Furthermore, the file does not appear to initially stream any faster to my Roku Stick+ than it did before I “optimized” it. These facts lead me to believe the FFMPEG command did not successfully web optimize the video.

I was wondering if anyone had any experience with this? Perhaps this question would be better suited for a forum dedicated to FFMPEG.

I don’t know the answer to your question, but Plex “optimize” is not quite the same thing.

Plex optimize actually transcode the video and or audio to the configured bit rate. It’s not a lossless/copy process.

If you’re trying to optimize the raw file so it can be played without Plex and streamed directly instead of fully downloading first →

ffmpeg -i input.mp4 -movflags faststart -c copy output.mp4

This is a two-pass operation:

  1. Performs the analysis of what to write
  2. Performs the copy of input to output after writing all the fast start info at the front of the file.

On a Roku, this may not provide any relief. The contents of the file determines what must happen.

1 Like

Just looking up my batch of miscellaneous ffmpeg commands, but you beat me to it.

I could be wrong, but there’s no need to web-optimize an MKV file. Web optimizing is just an mp4/m4v thing as far as I know.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.