# Fun with HCenc

1. I am trying to dig a little into the guts of video encoding. Many of you have helped immensely by pointing me in the direction of debugmode frameserver and HCenc. These tools are incredible if for the only reason they expose so much information. Playing around with the following workflow:

1. DV-AVI (720x480i29.97 4:1:1 YUV 8-bit color)
3. Frameserve video only through DMFS
4. AVISynth frameserve to HCEnc (no additional tweaks)
4. HCenc to m2v 720x480i29.97 (DVD compliant with CBR and quant value of 5)

So using the framelog.txt output I come up with the following analysis of a 50 sec clip (this is a home movie, btw):

I set the max bitrate in HCenc to 9,000. From the chart above, the I frames (fields since this is interlaced) vary between 15,000 and 20,000. This is the light blue curve. Perhaps I am doing the calcs wrong on the framelog.txt file? Here is what I use:

kbit/sec = frame length (bytes) * 8 (bits/byte) / 1024 (bits/kbit) * 30000 / 1001 (frames per second)
e.g. kbit/sec = 65,802 * 8 /1024 * 30000 / 1001 = 15,407 kbit/s

But then maybe I am thinking about this wrong? If I calculate the bit rate over a GOP (setting is 15) I get the yellow curve which gives the "illusion" of never going over the 9K limit. By comparison, here is the bitrate viewer analysis which is very similar to the yellow curve. Bitrate viewer reports 28 samples so maybe it uses about 2 seconds per calc?

Thanks as always for your insights! Some real gurus on this forum
2. Default mode for calculation in Bitrate Viewer is based on seconds. If you click on the program icon in the top left (left of "bitrate viewer title) you can choose other options like frame based, GOP based, GOP enhanced based calculation.
3. Cool! Learn something new everyday. Now my graph looks very similar:

So I am wondering if I should be worried that the rate is peaking so high?
4. No, I don't think so.
5. Originally Posted by SameSelf

So I am wondering if I should be worried that the rate is peaking so high?

No.

DVD and blu-ray use a different definition of "maximum bitrate" . This is the max data rate that can enter the buffer, limited by optical disc transfer rates. In short, bitrate viewer isn't the correct tool to use for DVD or blu-ray, when looking at compliance issues because it doesn't take into account of the buffer level. You would look at a buffer analyzer that takes into account input / output and current buffer status
6. OK, good to know. Too bad there aren't any free tools that do this. But I guess it doesn't matter really. I assume once I bring the video into Encore to author the DVD, if there are issues with buffer overrun, Encore would alert me.
7. those I frames get even higher readings generated by MainConcept mpeg2 encoder, I tested that in Sony Vegas - generating DVD compliant m2v DVD Architect video stream, but it is perhaps all the same in Encore, if Encore generates DVD compliant file , so it should be fine
8. Originally Posted by _Al_
those I frames get even higher readings generated by MainConcept mpeg2 encoder
Wow, you are absolutely right. Here is the exact same clip out PPro using MainConcept mpeg2 set to CBR with target 8.5K bitrate. The I frames are peaking higher. But, MainConcept seems to do a better job at hitting the target bit rate versus HCenc. Not as much variability, but I only have a chart to go by versus hard numbers. Probably some settings within HCenc that I need to play around with some more.

9. HcEncoder does not have CBR, just VBR or CQ, so you perhaps used CQ, which distributes that max bitrate if it has to, but goes lower if it does not need to, that is a major advantage, waste of bitrate is not happening, but in DVD world I guess it does not matter if video length content is 1hour 5-10 min long, or shorter (together with 192-256kbps audio track).
Example, if the video length is 1hour 20 minutes and video content is very calm, pictures etc, it is save to use CQ as well , while setting 8000kbps or so as max.
To simulate CBR in HcEncoder you can set min and max very close to each other, it'll keep bitrate between, but it is 2pass.

correction: average and max to set close to each other, Hcenc does not set min bitrate for 2pass
10. OK that is good to know. I was using CQ with a setting of 5 but with max bitrate checking enabled at 9000. Although at this point I am beginning to question what CBR even means because none of the charts I have seen exhibit a CBR. So makes sense that HCenc does not have CBR. Personally I despise two pass encoding. I prefer to keep my DVDs to an hour length. Of course I have that luxury since I am making home DVDs versus trying to fit a theatrical release like LOTR on one.
11. The bitrate alone doesn't matter too much. The crucial factor is the usage of the decoder buffer (VBV). You can have a very volatile bitrate distribution with GOP bitrate peaks way beyond 10 Mbps, and a DVD player may still playit without issues; and then there may be a quite smooth part nicely below 9 Mbps and still cause "VBV underflow" errors in a professional DVD authoring tool.
12. I have not heard that HcEncoder would produce m2v that hardware players would have problems with. As for myself not really seen any problem, stuttering on burned DVD's and I use CQ 3 that is yet more generous with bitrate distribution and those I-frames as was shown above gets higher, something like those mainconcept readings (encoding CBR).

What I did, years back, I loaded m2v's into DVDMaestro, not for the reason of making DVD but just to test it if that authoring software accepted those files. Just to be sure. I'm sure I did some tests after switching to HcEncoder. That software, DVD Maestro was for me indicator, that things are all right. Even later, accepting progressive m2v as I remember was a sign for me that it should be ok to burn on DVD.

CBR is just padding data so one has constant bitrate stream, it had its purpose like 10 years ago, I remember, NLE encoders could have a problem during cross-fade etc, when bitrate changed abruptly from photo image, encoders were worse than nowadays, but today it seamed to not be as much as problem, discovering HcEncore years back, I have DVD length hour and 10-15 minutes I use CQ , done, there seem to always be room on DVD for it encoding old DV avi. Now it seems to be even more relaxed because of encoding 29.97 progressive content on DVD if I have to have DVD, which is more compressible than interlace content.

Statistics