Skip to content

Commit dc86fee

Browse files
committed
options: Automatically set H.264 level 4.2 if needed
If the macroblocks/s exceed 245760, override the level option to "4.2". Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 29f3943 commit dc86fee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/video_options.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ struct VideoOptions : public Options
144144
if ((split || segment) && output.find('%') == std::string::npos)
145145
LOG_ERROR("WARNING: expected % directive in output filename");
146146

147+
// From https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels
148+
double mbps = ((width + 15) >> 4) * ((height + 15) >> 4) * framerate.value_or(DEFAULT_FRAMERATE);
149+
if ((codec == "h264" || codec == "libav") && mbps > 245760.0)
150+
{
151+
LOG(1, "Overriding H.264 level 4.2");
152+
level = "4.2";
153+
}
154+
147155
return true;
148156
}
149157
virtual void Print() const override

0 commit comments

Comments
 (0)