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.

«1

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 2017

    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 2017

    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 2017

    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.

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

    Thanks in advance for your feedback!

     

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

  • Thank you for replying so quickly and thoroughly!

    I'll try both of your workarounds to see which one works best for me. I'll also be watching the Handbrake support site and forum for the quirk/bug fix.

    Thanks again!

  • Hi  NormanPCN, I came across a video about editing 4k video on a old computer. the boy imports the video into the project and then saves it and closes the editor. then converts the 4k files to smaller files and then renames the 4k files and uses the smaller files with the same name, when he starts up the editor it uses the small files and he is able to fly through the editing. When done he saves the project again, closes the editor and renames the files again. Then when he restarts the editor it uses the 4k files for the rendering and output, he says it should work with any editor. Anyway its worth watching. Edit HD/4K/8K Video on a SUPER SLOW PC - Improve Video Editing Speed on an OLD PC!

     
  • If plain editing is the only thing happening, that would probably work. However, if any of the footage is moved off-center, or any composite work is done, this process wouldn't work once the footage is swapped back to 4K from the smaller resolution proxy files.

  • @lostcowboy This has nothing to do with a fast decode AVC transcoding so it should be in its own thread topic. Proxy workflow is a different subject.

    Yes a proxy workflow can work. Better in Vegas since Vegas defaults to auto scaling media to project frame size. Other editors have this as well. This meaning you can take HD media and use it in a 4k project. Also Vegas uses relative coordinates so any effect coordinates and masks and moves will scale from 1080 to 4k. It will of course not be pixel accurate going from a proxy resolution project to full resolution. For that you need to have proxy media in a 4k project and the viewer showing 4k. This is something Hitfilm is unable to do.

    I did notice that in the Vegas example in the video the project was HD resolution using 4k media. In that situation you don't run into pixel accuracy issues.

    In Hitfilm you could create HD proxy media but then your project must be HD as well. Then the media will fill the viewer. This step is not necessary in Vegas or other editors.

    You can't just scale the media for the viewer in Hitfilm because that would mess with the move to a full resolution project in Hitfilm. You would have to rescale back down with full resolution media. That is a lot of fiddling around.

    So in Hitfilm you have to change the project size with the proxy/full media which causes problems with moves and scaling pixel accuracy. NLE edits like cuts and transitions only is easy.

    Changing the editor project size is easy in Hitfilm but Hitfilm has this whole workflow with composite shots. Now you have to edit every comp to change its project size. Again, pixel accuracy can be a problem when changing a project/comp from HD to 4k. With critical masking and such comp would probably need to stay 4k.

    As stated Vegas uses relative coordinates. It is actually obvious. If you center an effect in the frame the coordinates in Vegas are 0.5, 0.5. Percentage of frame. Not pixels. The Hitfilm UI shows us absolute pixel coordinates but as I write this for some reason I think I once very briefly tested this years ago and under the covers Hitfilm may be using relative coordinates. At least for some thing(s). I would have to do a proper test to be really sure.

    Ultimately the apps shown like Vegas have an easier to use proxy workflow than shown in the linked video. Call it smart proxy or optimized media or whatever. Just the flick of a menu item and you are using the proxy (created by the app) or using the original media. No muss no fuss. This is what Hitfilm needs.

     

  • So, I am a complete newbie when it comes to any video editor. I am pretty sure that the main subject here is transcoding to improve the editing performance in the editor, which I thought was what this kid was doing also. The only thing I saw him doing different was going back to the original files for the final rendering. It sounded like a good trick which is why I posted it here .

    Norman you say that is Proxy, but it doesn't sound like the way Hitfilm talks about proxy files in the reference manual, Also in the manual they say that Hitfilm uses a media cache to caches the media files to improve performance.  How is that related to what you are doing , if we end up transcoding twice is that not bad?

  • Triem23Triem23 Moderator

    @lostcowboy what Hitfilm calls "Proxy" is a misnomer. In every other program a proxy is a low res version of a file (so, creating a 720p file to edit in 4k) for faster editing, then swapping back to the full res file for final render. 

    Hitfilm's proxies are full-quality, full-res files intended to collapse a Composite Shot to a video clip for embedding in other comps or quick performance on the Editor Timeline. Other software calls this something like "Prerender" or "Render Subclip."

    Cache files... Y'know, what those store depends on software. I think in Hitfilm cached items are thumbnails for timeline and media bin, and maybe audio waves. @DannyDev (I tagged Cedric last three times--your turn!) care to clarify? 

    Transcoding for editing performance--long story short, formats like AVC/mp4 go for maximum compression at the cost of slow editing performance. Recommended editing codecs are faster performing, but larger files.

    Will transcoding twice hurt you? Depends on the final output. Let's go with YouTube... They stream 1080p video at about 10mbps. Let's argue you're staying in mp4 for this example. Mp4 is lossy, so retranscoding can degrade data, but if you're doing those transcodes to something like 35mbps then quality is being maintained at a far better quality than how the audience will see it, so nothing to worry about. 

  •  Yes, as I write this (current version of HitFilm is 7.1), HitFilm proxies are full resolution renders. As @Triem23 wrote above, it is very useful for heavy comps as it removes the need to render it again.

    We want to add the more traditional "low resolution" proxies to HitFilm to be able to speed up media decoding but we haven't had time yet. Be patient and it will definitely come ;)

    The media cache contains audio conformed to the sample rate of the timeline, audio peak files to speed up generation of audio waveforms and the last type of file in that folder is variable frame rate look up tables. All of these files are there to speed up HitFilm UI and/or playback but they can be removed from the options dialog.

  • @Triem23

    Just to further clarify Cedric's reply, caching (as referred to in the Options panel tab) in HF is limited to:

    • audio conformance files (HF requires all audio streams to be converted to the project bit rate before they can be used)
    • waveform peak files (to improve performance when creating waveform graphs)
    • variable frame rate look up tables (to make VFR media usable for a single frame rate)

    Media bin thumbnails and filmstrip previews are NOT cached because it turned out to be quicker to regenerate them as required.

  • Triem23Triem23 Moderator

    @DannyDev @CedricBonnier thanks, gents, good to know! 

  • edited April 25

    Sorry but i don't understand:

    If i have both the optin of using CBR and VBR Hitfilm sould perform the same right? The upside of CBR is that the file size is known and also its quality when VBR enables me to have a smaller file size: Am i getting this correctly?

  • Also, some says Vegas is Necessary to complement this but honestly i'm totally fine with trimming everything, ordering the scenes and only at the end put effects, crossfades etcetera.

    This said, it would be really nice to have from a video editor software to have a smooth crossfade between two parts of the same file :/

    I really hope you guys fix this because if you do that Vegas doesn't stand a chance, exept from the UI that most of us grew to love ...at least me  but that could be nostalgia as it is the first software with which i made my first amazing and cringy projects :D

Sign in to comment