When encoding with libx264
, you can set the H.264 profile and level with:
-profile:v
– one ofhigh
,main
, orbaseline
(and others, but this is irrelevant here)-level:v
– as defined in Annex A of the H.264 standard, e.g.,4.0
.
For example:
ffmpeg -i input.mp4 -c:v libx264 -profile:v high -level:v 4.0 -c:a copy output.mp4
Here we've just copied the audio stream since it won't be affected.
The output will have the correct profile and level set in its metadata. You can check this while encoding, where x264
says something like:
[libx264 @ 0x7fb26103a000] profile High, level 4.0
MediaInfo can also help you analyze container and codec details.
Of course, reencoding the video will degrade its quality to some extent, given that you're applying a lossy conversion again. Try setting the -crf
option to influence the constant quality parameter. The default value here is 23, while values between 18 and 28 are considered sane. Lower means better quality. If your input has a bit rate of up to 65,000 kBit/s, chances are it'll still look pretty good after conversion though.