Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
21st May 2013, 01:49 | #1 | Link |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
Advices on "hard scenes" encoding for DVD
I have a video stream (filmed with my miniDV camcorder ) that I want to encode for DVD-video. But when I try to encode it (I use HCEnc 0.26), some scenes look very ugly, especially the forest ones, which have many "textures" (Here's a sample pic). This happens even at 9200 kbps, so I made a quick encoding with these scenes to see if I was doing something wrong.
So I did a 1.00 CQ encoding with a max bitrate of 40 mbps, and realized that the "perfect" bitrate for the scenes were about 17-18 mbps. So I concluded that an acceptable quality would be around 10-12 mbps anyway, which surpasses the upper limit of DVD compliancy. So I'm asking for tricks and hints (on filters for AVISynth, VirtualDub, etc.) to adequate the picture for a better compression and encoding, while keeping a "good watching" to the eyes. Here's a sample vid for testing (Lagarith, 157 MB) Thanks! |
21st May 2013, 10:34 | #3 | Link |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
I'm not sure what you mean by textures, but if you mean the fine leaf detail that appears messed up by interlacing, that's one thing you don't need to worry about, assuming you're encoding interlaced. The hardware DVD player will take care of deinterlacing, and just make sure your software player does also.
Chances are that your camera records luma to the [16,255] range, which seems confirmed looking at the bright areas in the screen grab. Measure this with ColorYUV(analyze=true).Blur(1.0). If you see occasional values below 16, those will be legal undershoots you need not concern yourself with. RGB conversion in your workflow will clip luma to [16,235] causing clipped whites (if you want to do any processing in VirtualDub, you'd have to convert to RGB32, since VirtualDub messes up the chroma of interlaced YV12). If you take care to use the Avisynth PC conversion matrices you may avoid some of the clipping, but best is to normalise luma with something like Levels(0, 1.0, 255, 2, 235, coring=false) or ColorYUV(gain_y=-18, off_y=-2, gamma_y=0, cont_y=0). YLevels() also works. Beware that Levels() also modifies the chroma range (see the documentation). For my DV camera I use ColorYUV() - it just looks better to me. For scenes with large difference between background and foreground exposure as in your sample screen grab, you could also try HDRAGC() and/or Local Contrast Enhancement. Do any luma and/or chroma manipulation like these after normalising levels. PS. If you are prepared to put some effort into ensuring best encoding quality, read up and play with all HCEnc settings, one at a time*. Note which ones improve quality at the same bitrate, and intelligently combine those into your final encoding configuration. *Note that some settings may need to be enabled by another before taking effect Cheers, Francois Last edited by fvisagie; 22nd May 2013 at 12:53. Reason: Corrected "Local Contract Enhancement" to "Local Contrast Enhancement"! |
21st May 2013, 12:03 | #4 | Link |
Registered User
Join Date: Mar 2009
Location: Germany
Posts: 5,769
|
That's the interlace "artifact".
If you don't see it on TV if you connect your camcorder to it, chances are that you won't see it from the DVD player either.
__________________
Born in the USB (not USA) |
22nd May 2013, 06:06 | #5 | Link |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
No, I'm not talking about interlace artifact.
I leave you the resulting MPEG-2 file for better understanding. It's about MPEG-2 artifacts. And here's the HCEnc INI file: Code:
*INFILE f:\iframe\marquez caceres\postprocessed\encode.avs *OUTFILE F:\Iframe\MARQUEZ CACERES\DVD1\test.m2v *BITRATE 9200 *MAXBITRATE 9600 *FRAMES 164400 164900 *PROFILE best *AUTOGOP 18 *AQ 3 *DC_PREC 10 *INTERLACED *BFF *CLOSEDGOPS *INTRAVLC 2 *MATRIX mpeg *LUMGAIN 3 |
22nd May 2013, 10:42 | #6 | Link |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
You mean the blocking, e.g. on the backpack? That's usually from bitrate starvation. Two-pass encoding should help a lot. Beyond that, I'm not familiar with configuring HCEnc so can't help with that.
You may also find that blocking behaviour changes once you've done dynamic range corrections for luma and/or colour. |
22nd May 2013, 12:28 | #7 | Link |
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Try a different quant matrix in HCenc. The "MPEG" matrix you are using is rather bitrate-hungry. I recommend "KVCD notch" matrix for your purpose (in HCenc this matrix is simply called "NOTCH").
You can also try other matrices, generally the higher the numbers the higher the compression but that doesn't mean a matrix with very high numbers will look good for your video... A had a look at your video and yeah, it's definitely a very bitrate demanding one. Also your highlights are most likely clipped like fvisagie mentioned. Edit: If you can't get rid of the blocking on the dark part of the backpack, I suggest you set "dead zone settings" to a fixed value of 1 or 2 for both. Also I noticed the GOP structure of the video is constantly like IBPBPBP... You may be able to reduce the overall blocking by unticking "Autogop" which will result in a GOP like IBBPBBPBB... Make sure the GOP length is set to 18 frames in Settings 1. Why are you using closed GOPs? That will eat valuable bitrate for no reason! Last edited by TheSkiller; 22nd May 2013 at 12:45. |
28th May 2013, 20:13 | #8 | Link |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
First, I want to thank all your replies .
I tested several settings, following your suggestions: NOTCH matrix, dead zone settings and Autogop off with 18 frames of GOP length. Though the video is improved, it still shows many artifacts. I think I'll definitely have to smooth it a little. About closed GOPs: I understand this is mandatory for DVD compliancy. About clipped whites: I do all editing and filtering through AVISynth (with Cedocida DV codec). I only use VirtualDub for intermediate encoding (with YV12 Lagarith) and configured output and input as YV12. I never convert to RGB in my workflow. On the other hand, I already set the values for HDRAGC and NonLinUSM, but by your words, I guess it's not enough. But after all, do I check any other related settings? In the last tests, I realized this scene doesn't demand the bitrate it needs, that means if I set a max bitrate of 9500 kbps, it's never reached in any part of the stream. Am I doing something wrong or is there something I'm not doing? |
28th May 2013, 22:58 | #9 | Link | ||
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Quote:
For chapter points you need one closed GOP before the I frame of a chapter point – in other words if you want to use chapters you need to define them in HCenc. Quote:
I haven't ever tried this but maybe you can hit the desired bitrate better when using the new "1 pass VBR" mode which can be ticked in the main settings. Edit: Tomorrow I will try and encode your sample myself. Last edited by TheSkiller; 28th May 2013 at 23:07. |
||
29th May 2013, 10:23 | #10 | Link | |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
Quote:
As mentioned, you can use ColorYUV(analyze=true).Blur(1.0) to measure the need for luma and/or chroma normalisation. Histogram("classic") and Histogram("levels") display luma and chroma values graphically. The link above also mentions tools for checking legal YUV combinations (while Y, U and V values may be within range individually, their combination may still result in out-of-gamut RGB values). However, this is getting a little esoteric, in the sense that once normalisation e.g. Levels() and dynamic range adjustment e.g. HDRAGC() have been done, output is either within range or close to it and any remaining clipping will be hard to spot, except for the fanatic. Last edited by fvisagie; 29th May 2013 at 10:28. |
|
29th May 2013, 17:59 | #11 | Link | |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
Quote:
By chance, last night I did some tests regarding the luma range issue and must say that it looks better. I added Ylevels(0, 1.0, 255, 2, 235) and then applied HDRAGC settings which resulted in better overall luminosity. I hope to test compression with these new values today. However, I would like to return on the first line: Does this mean that luma range must always be stretched to the [16-235] interval? And if it does, why is low output set to 2 on the Levels settings you suggested? Shouldn't it be set to 16? Last edited by Alex-Kid; 29th May 2013 at 19:20. |
|
30th May 2013, 08:02 | #12 | Link | ||
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
Quote:
Quote:
By the way, do yourself the favour of comparing Levels() and ColorYUV() before deciding which to use. Levels() also shrinks the chroma range, unnecessarily in the case of my DV footage that has valid chroma. With ColorYUV() and YLevels() you can operate on luma alone. The effect on my footage of ColorYUV() + HDRAGC() is far more attractive than Levels() + HDRAGC(), no matter how I tweak Levels or HDRAGC to try compensate. Cheers, Francois |
||
30th May 2013, 11:58 | #13 | Link |
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Simply using the PC matrix will result in washed out blacks (unless the camcorder stores black at 0 which I highly doubt any camcorder does).
The issue is simply the camcorder stores it's whitest white at 255 because it doesn't need to bother compressing it to 235 or clipping it. You don't have to fix that, but it's advisable to do to make sure the video looks the same regarless of where it is played back. Whether you use Code:
Levels(0, 1.0, 255, 2, 235, false) Code:
Levels(16, 1.0, 255, 16, 235, false) Alternatively you can wrap Levels() inside MergeLuma() or MergeChroma() to affect only the luma. Example Code:
MergeChroma(Levels(16, 1.0, 255, 16, 235, false), last) Last edited by TheSkiller; 30th May 2013 at 12:05. |
31st May 2013, 07:06 | #14 | Link |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
Are you sure that's what you meant? Can you show an example? As I understand it, the whole point behind behind using PC matrices (and coring=false) is to directly map [0,255] to [0,255], therefore none of the grey balance shifting that you mention.
PS. While generally true preferences may vary. My camera, for instance, produces perfectly legal undershoot in dark scenes and clipping that visibly reduces accentuation. Alex-Kid may want to play around with some dark clips before deciding which handling is preferred for his camera. Last edited by fvisagie; 31st May 2013 at 08:14. |
10th June 2013, 23:46 | #15 | Link |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
Thanks fvisagie & TheSkiller, your posts helped me a lot.
But I have to say I give up with MPEG-2 DVD encoding. Though the video has been enhanced, the encoding artifacts are still there, even with "close-to-top" bitrate, and I ran out of ideas to increase compressibility without hurting quality too much. The best results I got was using x264 encoder. Maybe the video still have some issues that can affect MPEG-2 encoding. Maybe noise, contrast, sharpness, etc., but at this point I feel I got stuck. I think this has became very challenging and it would be good that someone can use the sample posted some time ago and do the appropriate video processing to get a good MPEG-2 DVD encoding. |
11th June 2013, 07:23 | #16 | Link |
Registered User
Join Date: Aug 2008
Location: Isle of Man
Posts: 588
|
Unfortunately I have very little experience with HCenc. In case you would like to compare results, these are the two-pass ffmpeg command lines I use for DVD MPEG-2 encoding ('-top 0' = BFF):
Code:
ffmpeg -y -top 0 -async 0 -i input.avi -muxrate 10080000 -acodec ac3 -ab 128000 -flags ildct+ilme+mv0 -g 15 -mbd 2 -trellis 1 -bufsize 1835000 -strict 0 -bf 2 -b_strategy 1 -mbcmp 6 -preme 2 -precmp 2 -pre_dia_size 2 -cmp 2 -dia_size 2 -subcmp 6 -last_pred 2 -mv0_threshold 0 -maxrate 9000000 -vcodec mpeg2video -b:v 6090000 -pass 1 output.mpg ffmpeg -y -top 0 -async 0 -i input.avi -muxrate 10080000 -acodec ac3 -ab 128000 -flags ildct+ilme+mv0 -g 15 -mbd 2 -trellis 1 -bufsize 1835000 -strict 0 -bf 2 -mbcmp 6 -preme 2 -precmp 2 -pre_dia_size 2 -cmp 2 -dia_size 2 -subcmp 6 -last_pred 2 -mv0_threshold 0 -maxrate 9000000 -vcodec mpeg2video -b:v 6090000 -pass 2 output.mpg |
15th June 2013, 11:57 | #17 | Link | |
Registered User
Join Date: Dec 2007
Location: Germany
Posts: 632
|
Quote:
I did some encoding tests with your sample. In addition to HCenc I also used ProCoder – as to be expected with this particular kind of video ProCoder delivers the least artefacts and most pleasant to look at video (of course fully DVD compliant). The script I used was very basic, I just corrected the levels so that the luma is in the 16-235 range. Interestingly the brightest white in your video is not at 255 but rather around 243. There also is stuff below 16 which seems to come from the camcorder's contouring (edge enhancement) overshooting, i.e. it's not important and can/should be clipped. So I used this Code:
SmoothLevels(16,1,243, 16,235, chroma=0, limiter=2) ProCoder 1.5 result (mastering quality setting): http://www28.zippyshare.com/v/84023600/file.html HCenc_026_beta result: http://www67.zippyshare.com/v/24331625/file.html As you can see there is a small improvement over your own HCenc encoded version due to better settings but compared to ProCoder there's a huge difference. Every encoder has it's strong and weak sides. I'm afraid to say it but with this kind of video HCenc is being pushed over the edge. If it's of any consolation to you I can assure you that ProCoder looks rather bad with other kinds of video material. HCenc settings Code:
*INFILE c:\neu avisynth script (6).avs *OUTFILE C:\test_hcenc.m2v *BITRATE 9600 *MAXBITRATE 9600 *FRAMES 0 499 *PROFILE best *GOP 18 2 *AQ 4 *DEADZONE 0 1 *INTERLACED *BFF *INTRAVLC 2 *MATRIX hclow *LUMGAIN 1 *WAIT 0 Last edited by TheSkiller; 15th June 2013 at 12:31. |
|
18th June 2013, 07:06 | #18 | Link |
Antronio's DV ambassador
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
|
@TheSkiller: thank you!
I watched the two samples and I must say that both look great, but Procoder's looks better. I used Procoder some time ago, but I found that the output was too soft. And now that is an advantage! On these days I tested HCEnc with a little softer input (used Unfilter, didn't test any others) but didn't like the output. I think I'll follow your advice |
Tags |
advices, dvd, hard, scenes |
Thread Tools | Search this Thread |
Display Modes | |
|
|