Producing small H.264 files with Adobe Media Encoder vs ffmpeg/libx264 I am a terrible ignoramus in the subject, but the coronavirus has thrown me in the business of producing videos with my lectures. I care a bit for video quality and a bit more for small size. My source is probably seen as abysmal from professionals: it is a screen capture (4K) by Zoom, heavily compressed. It still looks fairly decent and I import clips in Adobe Premiere Pro 2020 and edit them. The problem is in encoding the final sequences.

I lazily started by using the default preset for H.264 ("Match Source - High bitrate). Unsurprisingly, files are very big but visual quality as good as it gets. Good enough for me at first.

Then a student suggested I use this to compress the videos with this


  ffmpeg -i input.mp4 -vf scale=1920:-1 -vcodec libx264 -crf 20 output.mp4


I did not run myself but he sent me an example and my 1.4 GB file went down to 74 MB without any particularly noticeable quality loss (note that most of the videos are slides and completely static for minutes, so it stands to reason that they compress very well). Here an example of typical frames:



Great, but, of course, I thought that I would not reencode with libx264 and rather produce similarly small files directly from Adobe Media Encoder. Firstly, I reduced the resolution to 1920x1080 during the export. Then, I spent an inordinate amount of time with the default H.264 encoder ("Hardware Encoding") to explore what happens reducing the only control I thought I should focus on (Target Bitrate). I would not manage to go below 650 MB with the smallest target bitrate (0.19 Mbps) but could reach 420 MB with a target bitrate of 1 Mbps. This makes little sense to me, but then I read somewhere to use the "Software Encoding" to get small files. I tried (also exploring blindly different profiles: Main, High, High10) and set the target and maximum bitrate also to the minimum (0.19 Mbps again). Size went down to 112 MB and, although not as small as the libx264 file, I thought it would be ok. The problem is that the quality degraded very noticeably. Here are a couple of examples:





Clearly, I must be missing something pretty fundamental here, but what? Is it possible that Adobe Media Encoder is so much inferior to libx264? Did I miss some key encoding parameter? (There do not seem to exist many in AME, nor they look like those of libx264.)

Any help would be much appreciated!

p.
Adobe licenses its H.264 encoder from Mainconcept, which doesn't do that well at low bitrates. x264 is pretty much the frontier when it comes at low size output for a given quality target, or quality for a given bitrate target. x264 is what's used by platforms like Youtube / Vimeo ..etc to encode user videos.

One thing you could try is to increase the keyframe interval. Default for x264 is 250 frames. Mainconcept will be something around 30-60 frames. If you can get them similar, I expect this to provide a moderate benefit in AME's encoding.

It is possible to use x264 with Adobe tools via VFW - https://sourceforge.net/projects/x264vfw/files/. But I don't recommend it. It's not maintained and there were stability issues.

My recommendation is to export a lighly compressed 1080p encode from AME - possibly DNxHD/HR codec in MOV or MXF container format, and then run the following ffmpeg command:

ffmpeg -i input.mov -c:v libx264 -crf 20 -movflags +faststart output.mp4


The faststart flag helps with quick playback start for web viewers.