Page MenuHomePhabricator

Enhancement: TimedMediaHandler: don't transcode to higher bitrate
Open, LowPublicFeature

Description

Feature summary (what you would like to be able to do and where):

Sometimes, the transcodes end up larger than the source files. This is unnecessary and wasteful.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

Avoid transcoding is already sufficiently small files/low bitrate files.

Example https://wiki.tnonline.net/w/File:20230509-1938_Moose_calf.mp4
Original file is a 1920x1080 H.264 file in a MP4 container encoded at ~2.7Mbit/s

The transcoded VP9 file is encoded at double the bitrate for no gain.
Though, I could see that some browsers might have issues with the source file, and so would still benefit for the alternative. Not sure what the best way to handle such cases would be. Possibly by trying to match the source bitrate?

Benefits (why should this be implemented?):
Saves storage space and CPU usage.

Event Timeline

Note that the problem here is that the source file is at *MUCH* too low a bitrate and is thus full of encoding artifacts. The transcode then spends a normal amount of bits replicating all the encoding artifacts as closely as possible.

The fact is we'll *always* transcode, because we're deliberately producing a consistent format (which by the way will be changing soon to better support native iOS playback using VP9 in an HTTP Live Streaming structure). Knowing the format, size, frame rate, keyframe intervals, and cues-data structure are within sensible limits helps with ensuring playback is consistent and functional.

What we could do, perhaps, is detect when an input file is *ridiculously low bitrate* and maybe constrain our output bitrate so we produce similar artifacts at a lower bitrate instead of nearly identical artifacts at the normal bitrate. But this feels pretty low priority to me, and it might not get gotten to.

(More generally, the version of TMH you're running might still have the old dreadful encoding params for VP9 which bias it towards using a high bitrate on complex input -- which is what "noisy" encoding artifacts look like!)