[FFmpeg-user] Converting H.264 High L5.0 to H.264 High L5.1

Mark Thompson sw at jkqxz.net
Wed Jan 20 15:01:50 EET 2021


On 19/01/2021 14:47, alfonso santimone wrote:
> Hi all,
> how can i convert a H.264 High L5.0 .mov video to a H.264 High L5.1 or L4.0
> .mov video without loosing to much quality?
> I've tried...
> 
> ffmpeg -i input.mov -c:v libx264 -profile:v high -level:v 4.0 -c:a copy
> output.mov
> 
> but from a 02:46 (mm:ss) movie 1.8Gb big i get a 90Mb movie.
> So I guess a lot of quality is lost.
> How can I improve it?

What is the end-goal here?

The level of an H.264 stream is an indication set by the encoder of the resources which will be required to decode it.  For example, level 4 at high profile indicates that it should be usable by a decoder which supports frames of at least 2097152 pixels and can process 62914560 pixels per second and 25000000 coded input bits per second - that's enough for 1920x1080 at 30fps, but not larger or at higher framerate.

If your input stream does conform to the level you want to set (whether higher or lower than the current level) then you can rewrite just the level field while copying everything else by doing:

ffmpeg -i input.mov -c:v copy -bsf:v h264_metadata=level=4 -c:a copy output.mov

This will still work if your stream doesn't actually conform to the lower level, but it might confuse some players so you should be careful with testing in that case.

If you actually do need to conform to a lower level than your input stream currently does then you will need to reencode as you've already suggested - in that case, you will want to look at the bitrate or crf options to libx264 to improve the quality.

- Mark


More information about the ffmpeg-user mailing list