Moiré pattern after encode

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
tony30
Posts: 2
Joined: Tue Jun 01, 2010 5:57 am

Moiré pattern after encode

Post by tony30 » Tue Jun 01, 2010 6:22 am

Hi. I am trying to convert some DVDs to h264 in a Matroska container. The results are mostly impressive, but I am seeing some annoying Moiré patterns in the output. The source is interlaced (PAL), and I assume it's the deinterlacing that is doing it. The pattern is visible in the source, but it looks much worse after conversion.

Here are some examples (look at the shirt)
Before http://img291.imageshack.us/i/before1.png/
After http://img16.imageshack.us/i/after1.png/

Before http://img709.imageshack.us/i/before2o.png/
After http://img295.imageshack.us/i/after2.png/

This conversion was done with the Normal profile with Decomb set to Default. I have experimented with different settings, but none have helped. Is there anything I can do to improve the result?

Code: Select all

### Windows GUI 0.9.4 2009112300 
### Running: Microsoft Windows NT 5.2.3790 Service Pack 2 
###
### CPU: Intel(R) Xeon(R) CPU            5130  @ 2.00GHz 
### Ram: 2047 MB 
### Screen: 1920x1200 
### Temp Dir: C:\Documents and Settings\tjp\Local Settings\Temp\ 
### Install Dir: C:\Program Files\Handbrake 
### Data Dir: C:\Documents and Settings\tjp\Application Data\HandBrake\HandBrake\0.9.4.0 
#########################################

### CLI Query:  -i "H:\VIDEO_TS" -t 1 --angle 1 -c 3 -o "C:\Documents and Settings\tjp\Desktop\HandBrake\OFAH_SERIES_2_DISC_2-1.m4v" -f mp4 --strict-anamorphic  --decomb -e x264 -q 20 -a 1 -E faac -6 dpl2 -R 48 -B 160 -D 0.0 --subtitle 1 --subtitle-burn=1 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1

### User Query: False

#########################################

[14:54:05] hb_init: checking cpu count
[14:54:05] hb_init: starting libhb thread
HandBrake 0.9.4 (2009112300) - MinGW i386 - http://handbrake.fr
2 CPUs detected
Opening H:\VIDEO_TS...
[14:54:05] hb_scan: path=H:\VIDEO_TS, title_index=1
[14:54:05] scan: trying to open with libdvdread
libdvdnav: Using dvdnav version 4.1.3
libdvdread: Encrypted DVD support unavailable.
libdvdread: Could not open input: Permission denied
libdvdread: Can't open H: for reading
libdvdread: Device (null) inaccessible, CSS authentication not available.
NAME OPEN FAILED
libdvdnav: Unable to find home directorylibdvdnav: DVD disk reports itself with Region mask 0x00000000. Regions: 1 2 3 4 5 6 7 8
libdvdread: Encrypted DVD support unavailable.
libdvdread: Could not open input: Permission denied
libdvdread: Can't open H: for reading
libdvdread: Device (null) inaccessible, CSS authentication not available.
[14:54:06] scan: DVD has 7 title(s)
[14:54:06] scan: scanning title 1
[14:54:06] scan: opening IFO for VTS 1
[14:54:06] pgc_id: 1, pgn: 1: pgc: 0x157d7f0
[14:54:06] scan: vts=1, ttn=1, cells=0->5, blocks=0->506284, 506285 blocks
[14:54:06] scan: duration is 00:29:28 (1768000 ms)
[14:54:06] scan: checking audio 1
[14:54:06] scan: id=80bd, lang=English (AC3), 3cc=eng ext=0
[14:54:06] scan: checking subtitle 1
[14:54:06] scan: id=20bd, lang=English, 3cc=eng
[14:54:06] scan: title 1 has 6 chapters
[14:54:06] scan: chap 1 c=0->0, b=0->57228 (57229), 190259 ms
[14:54:06] scan: chap 2 c=1->1, b=57229->135664 (78436), 231425 ms
[14:54:06] scan: chap 3 c=2->2, b=135665->240739 (105075), 319682 ms
[14:54:06] scan: chap 4 c=3->3, b=240740->323910 (83171), 351387 ms
[14:54:06] scan: chap 5 c=4->4, b=323911->430785 (106875), 397768 ms
[14:54:06] scan: chap 6 c=5->5, b=430786->506284 (75499), 277476 ms
[14:54:06] scan: aspect = 0
[14:54:06] scan: decoding previews for title 1
[14:54:06] scan: title angle(s) 1
[14:54:06] scan: audio 0x80bd: AC-3, rate=48000Hz, bitrate=256000 English (AC3) (2.0 ch)
Scanning title 1...
[14:54:06] scan: 10 previews, 720x576, 25.000 fps, autocrop = 2/0/14/10, aspect 4:3, PAR 16:15
[14:54:06] scan: title (0) job->width:704, job->height:544
[14:54:06] libhb: scan thread found 1 valid title(s)
+ title 1:
  + vts 1, ttn 1, cells 0->5 (506285 blocks)
  + angle(s) 1
  + duration: 00:29:28
  + size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps
  + autocrop: 2/0/14/10
  + chapters:
    + 1: cells 0->0, 57229 blocks, duration 00:03:10
    + 2: cells 1->1, 78436 blocks, duration 00:03:51
    + 3: cells 2->2, 105075 blocks, duration 00:05:20
    + 4: cells 3->3, 83171 blocks, duration 00:05:51
    + 5: cells 4->4, 106875 blocks, duration 00:06:38
    + 6: cells 5->5, 75499 blocks, duration 00:04:37
  + audio tracks:
    + 1, English (AC3) (2.0 ch) (iso639-2: eng), 48000Hz, 256000bps
  + subtitle tracks:
    + 1, English (iso639-2: eng) (Bitmap)
[14:54:06] 1 job(s) to process
[14:54:06] starting job
[14:54:06] work: sanitizing track 0 mixdown Dolby Pro Logic II to Stereo
[14:54:06] job configuration:
[14:54:06]  * source
[14:54:06]    + H:\VIDEO_TS
[14:54:06]    + title 1, chapter(s) 3 to 3
[14:54:06]  * destination
[14:54:06]    + C:\Documents and Settings\tjp\Desktop\HandBrake\OFAH_SERIES_2_DISC_2-1.m4v
[14:54:06]    + container: MPEG-4 (.mp4 and .m4v)
[14:54:06]  * video track
[14:54:06]    + decoder: mpeg2
[14:54:06]      + bitrate 9780 kbps
[14:54:06]    + frame rate: same as source (around 25.000 fps)
[14:54:06]    + strict anamorphic
[14:54:06]      + modulus: 0
[14:54:06]      + storage dimensions: 720 * 576 -> 696 * 574, crop 2/0/14/10
[14:54:06]      + pixel aspect ratio: 16 / 15
[14:54:06]      + display dimensions: 742 * 574
[14:54:06]    + filter
[14:54:06]      + Decomb (default settings)
[14:54:06]    + encoder: x264
[14:54:06]      + options: ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0
[14:54:06]      + quality: 20.00 (RF)
[14:54:06]  * subtitle track 1, English (id 20bd) Picture [VOBSUB] -> Render/Burn in 
[14:54:06]  * audio track 0
[14:54:06]    + decoder: English (AC3) (2.0 ch) (track 1, id 80bd)
[14:54:06]      + bitrate: 256 kbps, samplerate: 48000 Hz
[14:54:06]    + mixdown: Stereo
[14:54:06]    + encoder: faac
[14:54:06]      + bitrate: 160 kbps, samplerate: 48000 Hz
libdvdnav: Using dvdnav version 4.1.3
libdvdread: Encrypted DVD support unavailable.
libdvdread: Could not open input: Permission denied
libdvdread: Can't open H: for reading
libdvdread: Device (null) inaccessible, CSS authentication not available.
NAME OPEN FAILED
libdvdnav: Unable to find home directorylibdvdnav: DVD disk reports itself with Region mask 0x00000000. Regions: 1 2 3 4 5 6 7 8
libdvdread: Encrypted DVD support unavailable.
[14:54:06] decomb thread started for segment 0
[14:54:06] decomb thread started for segment 1
libdvdread: Could not open input: Permission denied
libdvdread: Can't open H: for reading
libdvdread: Device (null) inaccessible, CSS authentication not available.
[14:54:06] yadif thread started for segment 1
[14:54:06] yadif thread started for segment 0
[14:54:06] encx264: encoding with stored aspect 16/15
[14:54:06] encx264: Encoding at constant RF 20.000000
x264 [info]: using SAR=16/15
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile Main, level 3.0
No accelerated IMDCT transform found
[14:54:06] sync: expecting 8017 video frames
[14:54:08] reader: first SCR 37980146 id 224 DTS 38002254
[14:54:09] output track 0: ac3 in sync after skipping 96 bytes
[14:54:09] mpeg2: "" (3) at frame 0 time 3600
[14:54:09] sync: first pts is 3600
[15:01:46] reader: end of chapter 3 (media 3) reached at media chapter 4
[15:01:46] reader: done. 1 scr changes
[15:01:48] sync: got 7990 frames, 8017 expected
[15:01:48] work: average encoding speed for job is 17.389013 fps
[15:01:51] mux: track 0, 7989 frames, 88004289 bytes, 2202.86 kbps, fifo 64
[15:01:51] mux: track 1, 14978 frames, 5056593 bytes, 126.57 kbps, fifo 256
[15:01:51] mpeg2 done: 7991 frames
[15:01:51] render: lost time: 0 (0 frames)
[15:01:51] render: gained time: 0 (0 frames) (0 not accounted for)
x264 [info]: frame I:51    Avg QP:18.51  size: 79326  PSNR Mean Y:44.21 U:47.27 V:47.97 Avg:45.07 Global:44.98
x264 [info]: frame P:3459  Avg QP:21.56  size: 19225  PSNR Mean Y:41.37 U:44.65 V:45.82 Avg:42.31 Global:42.18
x264 [info]: frame B:4479  Avg QP:24.59  size:  3899  PSNR Mean Y:40.39 U:43.55 V:45.11 Avg:41.32 Global:41.14
x264 [info]: consecutive B-frames:  1.9% 53.9% 44.2%
x264 [info]: mb I  I16..4:  9.9%  0.0% 90.1%
x264 [info]: mb P  I16..4:  0.8%  0.0%  4.5%  P16..4: 58.1% 20.1% 11.4%  0.0%  0.0%    skip: 5.2%
x264 [info]: mb B  I16..4:  2.6%  0.0%  0.5%  B16..8: 21.8%  1.3%  0.9%  direct:17.6%  skip:55.2%  L0:24.9% L1:49.6% BI:25.6%
x264 [info]: coded y,uvDC,uvAC intra: 74.0% 91.0% 60.9% inter: 25.1% 41.0% 8.4%
x264 [info]: i16 v,h,dc,p: 34% 17% 26% 23%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 18% 14%  6%  8%  9%  9%  7%  8%
x264 [info]: Weighted P-Frames: Y:1.4%
x264 [info]: ref P L0: 62.8% 14.6% 22.5%
x264 [info]: SSIM Mean Y:0.9720270
x264 [info]: PSNR Mean Y:40.841 U:44.051 V:45.438 Avg:41.770 Global:41.580 kb/s:2203.20
[15:01:51] decomb: deinterlaced 3480 | blended 1253 | unfiltered 3256 | total 7989
[15:01:51] libhb: work result = 0

Rip done!
HandBrake has exited.


 ############ End of Log ############## 

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Moiré pattern after encode

Post by jbrjake » Wed Jun 02, 2010 3:02 pm

This is due to the very limited and noisy chroma (color) information available in older TV video sources. Even in the best of situations, color resolution is half as detailed as luma (black and white) resolution. With interlaced material, it halves again. That exaggerates any errors.

You may want to try using the advanced parameters to decomb to enable mcdeint or EEDI2 or both. It's possible that these more advanced interpolators will do a better job on your source than yadif alone. There's also an off chance that denoising might help.

creamyhorror
Regular User
Posts: 134
Joined: Mon Jan 04, 2010 2:00 pm

Re: Moiré pattern after encode

Post by creamyhorror » Wed Jun 02, 2010 5:42 pm

To really fix problems like these, you're going to want a full-fledged video processing system like Avisynth, which offers a few filters that specifically target rainbows and moire artifacts. People on Doom9's Avisynth Usage forum should be able to help you with this. Of course, the time commitment may be significant and not be worth it to you. (And I don't think Avisynth feeds directly into Handbrake, so you'll probably have to use something else.)

VirtualDub may or may not have filters to deal with this also, but I'm not too familiar with using it for corrective filtering.

tony30
Posts: 2
Joined: Tue Jun 01, 2010 5:57 am

Re: Moiré pattern after encode

Post by tony30 » Fri Jun 04, 2010 8:11 am

Thanks for your help. I had experimented with the advanced parameters. I copied the defaults from the comments in the source and modified the first parameter. I left all the others alone. Should I also try tweaking one or more of the other parameters?

Also, I think I remember reading a reply of yours (jbrjake) that mentioned that HB does not set the interlaced flag if you do not deinterlace the source, and that a future version would set the flag. Would this solve the problem by leaving the video interlaced?

Avisynth isn't worth the effort in this case as it would take me too long to learn it. A 2 TB disk will hold all my DVDs without re-encoding, so I will go with that option if it gets too difficult. The smaller files are convenient, but the cost savings are negligible.

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Moiré pattern after encode

Post by jbrjake » Fri Jun 04, 2010 4:07 pm

tony30 wrote:Thanks for your help. I had experimented with the advanced parameters. I copied the defaults from the comments in the source and modified the first parameter. I left all the others alone. Should I also try tweaking one or more of the other parameters?
No, just the first one, which controls the filtering mode. Adding in EEDI2 (8) and/or mcdeint (EDIT 16, not 32, thanks Rodeo) might improve things somewhat...
Also, I think I remember reading a reply of yours (jbrjake) that mentioned that HB does not set the interlaced flag if you do not deinterlace the source, and that a future version would set the flag. Would this solve the problem by leaving the video interlaced?
Well, the problem then becomes finding a decoder with good support for interlaced h.264 encodes. Certainly a better idea than leaving it interlaced but encoding in default progressive mode. This should be possible by sending something like mbaff=1 to x264 in the option string, although it's possible more backend work needs to be done or the command needed has changed (x264's cli has an interlaced flag but I don't think it's in the API-parseable option list).

User avatar
Rodeo
HandBrake Team
Posts: 12274
Joined: Tue Mar 03, 2009 8:55 pm

Re: Moiré pattern after encode

Post by Rodeo » Fri Jun 04, 2010 4:16 pm

jbrjake wrote:
tony30 wrote:Thanks for your help. I had experimented with the advanced parameters. I copied the defaults from the comments in the source and modified the first parameter. I left all the others alone. Should I also try tweaking one or more of the other parameters?
No, just the first one, which controls the filtering mode. Adding in EEDI2 (8) and/or mcdeint (32) might improve things somewhat...
In current code, mcdeint is 16, not 32. Minor detail but still, better get the number right for it to work :-)
jbrjake wrote:
Also, I think I remember reading a reply of yours (jbrjake) that mentioned that HB does not set the interlaced flag if you do not deinterlace the source, and that a future version would set the flag. Would this solve the problem by leaving the video interlaced?
Well, the problem then becomes finding a decoder with good support for interlaced h.264 encodes. Certainly a better idea than leaving it interlaced but encoding in default progressive mode. This should be possible by sending something like mbaff=1 to x264 in the option string, although it's possible more backend work needs to be done or the command needed has changed (x264's cli has an interlaced flag but I don't think it's in the API-parseable option list).
Last time I checked x264_param_parse could parse interlaced (old option), tff and bff (new options).

Also, x264 does not suport MBAFF yet (may be one of this year's GSOC projects, can't remember for sure). No sign of any mbaff option in x264 --fullhelp

jbrjake
Veteran User
Posts: 4805
Joined: Wed Dec 13, 2006 1:38 am

Re: Moiré pattern after encode

Post by jbrjake » Fri Jun 04, 2010 4:31 pm

Rodeo wrote:Last time I checked x264_param_parse could parse interlaced (old option), tff and bff (new options).
Ah..then it was that it had to be inputted as interlaced=1 but showed up in the SEI header as mbaff=1.
Also, x264 does not suport MBAFF yet (may be one of this year's GSOC projects, can't remember for sure). No sign of any mbaff option in x264 --fullhelp
Err...x264's supported MBAFF for a really long time, that's what interlaced=1 enabled back in 2006. It just isn't a complete implementation. http://git.videolan.org/?p=x264.git;a=c ... 2e3d1f5992

User avatar
Rodeo
HandBrake Team
Posts: 12274
Joined: Tue Mar 03, 2009 8:55 pm

Re: Moiré pattern after encode

Post by Rodeo » Fri Jun 04, 2010 4:48 pm

jbrjake wrote:
Also, x264 does not suport MBAFF yet (may be one of this year's GSOC projects, can't remember for sure). No sign of any mbaff option in x264 --fullhelp
Err...x264's supported MBAFF for a really long time, that's what interlaced=1 enabled back in 2006. It just isn't a complete implementation. http://git.videolan.org/?p=x264.git;a=c ... 2e3d1f5992
I see, thanks for the clarification.

Looks like the adaptive part has been accepted as a GSOC project this year: http://socghop.appspot.com/gsoc/student ... 7230764311

Post Reply