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.

Encoder Profile = High and Encoder Level = auto. Medium preset and constant quality of 20.

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.

Fast Decode AVC Windows scripts

A short video demoing how the ffmpeg scripts can be used. Drag and drop and via SendTo.

https://www.youtube.com/watch?v=9zkhXdHoliA

---------------------------------------

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.

Comments

  • @NormanPCN Awesome write up, sir!  I'm sure that's going to help some folks out.  Bookmarked!

  • I added a windows script to the ffmpeg ZIP download to deal with cameras that output superwhites, 16..255 range. Readme updated.

    The transcode preserves the superwhites for Hitfilm import. The low end remains unchanged.

  • Thanks for this.  I tried it and it totally works.

    I first tried DNxHD, but I do not have the hard drive space for that.

     

    My general frustration level thanks you.  :)

  • edited September 2

    Here are some sample OBS studio  settings for fast decode with x264.

    CRF = 20 or 23. choose something reasonable for you. lower numbers result in higher bitrates. 20/23 are good starting points. Experiment with your source material to get the best option.

    profile = high or main. high might have a little extra overhead but will result in slightly smaller files.

    preset = veryfast, faster or superfast. this depends on your computer speed and also minimizing OBS overhead which might possibly slow down your app/game playback speed.

    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.

    192k for audio bitrate should be fine.

  • edited September 2

    Here are some OBS setting for fast decode with the NVENC option.

    rate control = VBR

    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.

    192k for audio bitrate should be fine.

  • I know this thread is a couple months old, but I just had to say thank you!! scrubbing is nearly identical to DNxHD, but the file size is no where near as large. 

    thanks again!!

  • Yes, thanks very much : )

    BTW, Handbrake and OBS, the end result is mostly the same, right?

    Cheers.

  • 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.

    With NVENC mostly the same.

  • Guess this is not possible with Intel QSV, right? : )

    Tried the Cineform option the other day (via HF export), the performance is much better but the file is also HUGE.

    Handbraked videos (according to your suggestions) work better than the originals but not as smooth as Cineform, which is expected.

    If OBS is better then perhaps I'd give it a try later.

    Cheers.

  • Hey,

    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.

    Any idea why this happens?

  • No idea without more information. Provide a full text MediaInfo report of your capture file. Also, I listed a couple of different OBS settings (x264, NVENC). Which one did you use.

    You should start that in a new thread so as to not clutter this thread with unrelated posts.

     

  • I tried both.. What is a full text Media info?

  • 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.

  • edited September 2

    Updated the screenshots of OBS settings for x264 and NVENC using the current OBS version 20. Updated the NVENC recommended settings. Also fixed a typo or two.

  • 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.

Sign in to comment