Transcoding to fast decode AVC for timeline edit performance

As typically encoded, AVC has a high decode overhead. AVC is commonly found in MP4 and MOV file containers. Most cameras like DSLRs, digicams, action cameras, phones and web cams encode to a higher overhead AVC. AVC can be encoded to a lower overhead configuration.

I created some settings using the x264 AVC/H.264 encoder that creates files that have much better decode performance in your editor. Those settings are duplicated and scattered about this forum. Lets just say this is the "official" thread on the topic.

Fast decode AVC (Norman AVC) will not perform as well as things like Cineform, DNxHD/HR or Prores in quickly scrubbing the timeline back and forth. However, it is not too far off. It does perform quite well in Hitfilm in most other aspects.

What it does offer is much smaller file sizes that those intermediate codecs. GoPro/action cam users and video game users can end up with very long and thus large video files. Most of which gets edited out. If you have a 3GB file and transcode to one of these intermediates you can end up with a 12GB file. That can be a lot of backup. This low overhead AVC provides an alternative with very good performance.

I use ffmpeg (free), a technical command line tool, to do these fast decode AVC conversions. The Handbrake (free) utility is a nice GUI for something with a user interface to do these transcodes.

Here is a screenshot of Handbrake settings. Video tab.

Critical items are checking the "fast decode" option and the extra options "keyint=10:bframes=0". edit I now use keyint=8.

The constant quality setting is something that is debateable. For me 20 seems fine and compares favorably to common intermediate codecs. Smaller x264 quality value/settings generate larger files. Those who more concerned about quality loss in the transcode might try a value of 17. It's a little more conservative than 20. Moving by values of 3 will give large reasonable bitrate differences and greater chance of seeing any difference. Choosing smaller values most certainly increases quality retention but while software/machines can measure the difference, can you actually see any difference (human eyes watching a video).

Remember we are transcoding to increase editing performance. With the same settings (aka fast decode) then smaller files will decode faster.

Also, remember that with the constant quality setting we have no idea what the result bitrate of our video will be. If you transcode a talking head type interview the bitrate can be shockingly low but the quality is the still the same as a first person moving, shaking jiggling camera like a GoPro mounted to a mountain bike that has 10 times the bitrate.

In something like the talking head, or a Hitfilm video tutorial, the video encoder is finding lots of static and/or predictable movement of objects and this stuff compresses, for lack of a better word, visually "perfectly". The encoder encodes it once and just copies the static or predictable movement to the next frames. In my example, the bike video does not get much of this so the encoder has to encode nearly whole frames for every frame.

The Medium encoder preset is the x264 default and affects encoder speed and file size some. You can try Fast or Faster if you want to experiment. They will not speed things up as much as you think, do to the fast decode settings turning various things off.

Here is a screenshot of the audio tab. Choose AAC audio and a bitrate of 192.

After you have these items setup you can save a Handbrake preset to easily set all these separate settings the next time you do a transcode. In the screenshots you can see I have a "fast decode" user preset created.

Here is a link for a ZIP file with a set of fast decode AVC ffmpeg windows scripts. These are the ones that I created for my use. The ZIP file has a readme with some instructions. These scripts allow drag and drop of media files onto them to easily transcode files. You can also put a shortcut link to them in your "SendTo" menu item for easy use. Any questions, post them in this thread.

For tech heads only. What is the fast decode doing? AVC is a very large and feature rich video codec. It is designed to be capable of high compression (low bitrates like Youtube) and still retain reasonable quality. All these fancy features take time for the encoder to compute what to use and when, where and how to use each feature. There are some AVC features that do affect the video decoder speed. It is these that we are turning off.

CABAC. This is a lossless encoder used in the spec. It saves about 14% over the CAVLC encoder also in the spec. However, CABAC is very compute intensive to decode. This is the biggest decode speed boost of the fast decode settings.

Loop deblocking filter. This really comes in and is designed for low bitrates. At high bitrates it really does little/nothing to the image. Generally you may not want this off, but with high bitrate intermediate/edit files you are unlikely to miss it. Most editors that have a draft/preview mode are turning this off in those modes to boost their performance. Hitfilm has no such mode. Keeping the bitrate high effectively neutralizes the function of the filter and we want high bitrates because we want to preserve the quality of our source media.

We turn b-frames off. I don't know if this really helps or how much but we are simplifying the video frame stream to make it more like an All-I frame codec. Also, it does speed up the transcode process and that is nice. Temporal compression (inter frame) can still be effectively utilized with P-frames. Finding temporal compression does reduce resultant bitrate.

keyint=10. edit I now use 8. This creates a very short GOP. Group of pictures. This speeds up timeline scrubbing, especially backwards, and seeking to specific frames in the file (like timeline thumbnails).

There are some items I don't understand so I will just mention them in passing. Weighted P-frames and weighted B-frames off.

If your machine cannot keep up and encode at your specified output frame rate, e.g. 30 or 60, then the effective frame rate will be lower. The output file will always be your specified frame rate but the encoder will duplicate frames to fill in the gaps where it could not keep up.

tune = fastdecode. the most important item.

Current versions of OBS seem to default to constant frame rate (CFR). This acknowledges that editors want CFR. Do not check/enable the variable frame rate (VFR) option if your version has such a setting.

keyint= 8 or 10 just shortens the keyframe interval to 8/10 frames. Can help Hitfilm edit performance scrubbing and transitions.

bframes=0 this will speed encodes (less app overhead) and works well with keyint.

bitrate = ?. choose something reasonable for your target output. 30000 should be editable on most hardware and still be very high quality. Maybe a little higher for 50/60 fps. Experiment with your source material to get best the option.

keyframe interval = 1. 1 second is the shortest we can choose so use that. We would prefer something like 1/2 second but that is not available to us.

preset = default. choosing other items will override some of the other encoder settings. Most presets will override rate control. You can experiment with other settings if you want.

The low latency presets might be worth trying if Default has performance issues or the resulting effective frame rate is less than the recorded rate. High quality can be used if your machine can keep up. High performance is always CBR (constant bitrate output)

If your machine cannot keep up and encode at your specified output frame rate, e.g. 30 or 60, then the effective frame rate will be lower. The output file will always be your specified frame rate but the encoder will duplicate frames to fill in the gaps where it could not keep up.

profile = baseline. This is the important item. This lowers the decode overhead for the editor. aka Hitfilm

Check the two pass option. If you have performance issues, or output frame rate issues, then uncheck this item.

bframes = 0 The value of this item does not really matter since choosing Baseline profile turns bframes off, but set it to zero anyway.

Current versions of OBS seem to default to constant frame rate (CFR). This acknowledges that editors want CFR. Do not check/enable the variable frame rate (VFR) option if your version of OBS has such an option.

When using the x264 encoder in OBS then yes. Really the same when using the same settings. In OBS you are likely to use one of the faster profiles, e.g. veryfast/fast, to keep/minimize the encoder from interfering with the app you are recording.

I configured OBS as you recommended. My game is not impacted at all, but my recording looks like it is in 20 FPS, even though I set it to record at 60FPS, and my game has a minimum of 60-70FPS when I'm playing.

MediaInfo is a free utility that lists the specs of a video media file. MediaInfo can list specs in many formats. Text is one of those. Full means don't delete any info MediaInfo reports. Google is your friend.

I just tried your Handbrake method to convert some cellphone footage at 30 fps to 23.976 fps. When I import both clips into Hitfilm Express 2017, the converted footage looks smoother; however, Hitfilm says the new footage is at 24fps, NOT 23.976. Is that a problem? I want to mix it with .MOV footage shot with a DSLR at 23.976. Thanks.

@Evildad Handbrake has a bug with 23.976 media. Technically it always outputs variable framerate for that particular framerate. What it is actually doing is outputting an alternating frame rate that averages to 23.976. In other words the odd numbered frames are a little under 23.976 and the even frames are a little over 23.976. This will never cause audio sync issues.

As for Hitfilm identifying such media as 24.0 frames per second you probably should contact support about that. They should get that right. It is probably their variable frame rate code getting this wrong.

Two workarounds for now.

You can use my ffmpeg scripts to do your transcode(s). You will have to edit the script to force 23.976. ffmpeg will not screw up the 23.976 constant frame rate. VirtualDub is a GUI program that can do the transcode with fast decode settings for x264 and it will not screw up the framerate.

Lastly in Hitfilm you can right click the media properties and change the transcoded file framerate from 24.0 to 23.976. I'm not sure doing this will stop Hitfilm from identifying the file as VFR. I would think yes, but I cannot know for sure. Again, something you can ask support.

But really you want the transcode to be correct in the first place, and as of now, Handbrake screws up 23.976.

Hi All. I'm using Handbrake (latest version) to code my 1080p/60 m2ts VFR footage to CFR 59.94 for editing. I'm using the NormanPCN settings from this thread. Post processing, MediaInfo on the processed file shows that the file is still VFR at 59.94!

Under the Video tab in Handbrake I have the following settings:

Video Codec: H.264(x264)

Framerate (FPS): 59.94 Constant Framerate radio button is selected. (I also tried it set to Same As Source.)

I've searched both the Handbrake and MediaInfo support sites for possible bugs to no avail.

Curiously, I'm not having any problems editing the footage in that it scrubs well and looks okay. However, I'm trying to get better at this and so want to understand as well as have fully optimized files for editing.

So, I was wondering, Am I perhaps doing something wrong or might this be a MediaInfo bug?

I just tried a 59.94 GoPro source file with Handbrake and this apparently is another framerate that Handbrake has a bug with. Some might say it is a "quirk". I'll say bug.

Handbrake is incapable of generating proper true 59.94 or 23.976 constant frame rate files. What it generates is an alternating frame rate. One frame just under the target and the next just over the target. The pattern repeats exactly. Audio will never go out of sync with this.

Hitfilm 2017 tries to handle VFR files. It should not should not have a problem with this but I have seen reports where the Hitfilm VFR code made things worse. Those circumstances may have been fixed. Just be mindful of this possibility.

I'll copy and edit the text from a previous post in this thread related to the 23.976 frame rate problem. Handbrake has the same problem with 59.94.

-

Two workarounds for now.

You can use my ffmpeg scripts to do your transcode(s). You will have to edit the script to force 23.976 or 59.94. ffmpeg will not screw up the 23.976 or 59.94 constant frame rate. VirtualDub is a GUI program that can do the transcode with fast decode settings for x264 and it will not screw up the framerate.

Lastly in Hitfilm you can right click the media properties and change the transcoded file framerate from XXX to 23.976/59.94. I'm not sure doing this will stop Hitfilm from identifying the file as VFR. I would think yes, it will stop it from a VFR id, but I cannot know for sure. Again, something you can ask support.

But really you want the transcode to be correct in the first place, and as of now, Handbrake screws up 23.976 and 59.94 frame rates.