AviSynth / AviSynthPlus

AviSynth with improvements
http://avs-plus.net
963 stars 73 forks source link

Deinterlaced content still showing interlaced #356

Closed ddfault closed 1 year ago

ddfault commented 1 year ago

Thank you for your work on this project! I used DGDecNV_248 to deinterlace content and feed it to ffmpeg. I noticed if I have interlaced content and run it through avisynth 2.6 32-bit I get Input #0, avisynth, from 'input.avs': Duration: 00:00:59.36, start: 0.000000, bitrate: 0 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080, 29.97 fps, 29.97 tbr, 29.97 tbn If i run this through AviSynthPlus_3.7.2_20220317 I get Input #0, avisynth, from 'input_x64.avs': Duration: 00:00:59.36, start: 0.000000, bitrate: 0 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv, bt709, top first), 1920x1080, 29.97 fps, 29.97 tbr, 29.97 tbn If I run the encoded content back through DGDecNV for previewing, it shows all content is now progressive..

Is there a Avisynth command I can include to prevent this interlace information from getting passed through? My input files sometime include Color range, Color primaries, Transfer characteristics, and Matrix coefficients so I still want to pass along this data to the output.

I this a bug and its passing along this data without checking if its true? DGDecNV is now free for anyone to use. I found example interlaced content which performed the same as mine https://forum.videohelp.com/threads/400431-In-need-of-a-a-decent-size-interlaced-sample

qyot27 commented 1 year ago

Recent builds of FFmpeg can read AviSynth+'s frame properties (which is also where it gets the Range, Primaries, Transfer, and Matrix information). This would have one of three places it could be resolved:

In plugin: A) It sounds like DGDecNV isn't changing the _FieldBased frame property after it deinterlaces. There's a post from last year stating that frame properties for pulldown have been added, but I'm not entirely sure whether that meant unique frameprops were added (therefore _FieldBased wasn't touched after being populated at the time the video was opened), or if it specifically only referred to pulldown removal and not deinterlacing.

In script: B1) If you know the video has been deinterlaced but the frame property hasn't been changed to reflect that the video is now progressive, you can change the frameprop yourself by using propSet("_FieldBased", 0) (0 = progressive, 1 = bottom field first, 2 = top field first).

B2) Alternatively to just changing a known-progressive script to report that it is progressive, you could just delete that frameprop with propDelete("_FieldBased").

In client: C) If you want to control which frame properties FFmpeg reads, you can use the -avisynth_flags parameter. So you can tell FFmpeg to just ignore the _FieldBased frameprop. Compare with:

ffmpeg -avisynth_flags -field_order -i input.avs
ddfault commented 1 year ago

Thank you very much for this information! I would not have found these solutions without you!

propDelete("_FieldBased") produces Input #0, avisynth, from 'input.avs': Duration: 02:28:00.47, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv), 1920x872, 29.97 fps, 29.97 tbr, 29.97 tbn

propSet("_FieldBased", 0) produces Input #0, avisynth, from 'input.avs': Duration: 02:28:00.47, start: 0.000000, bitrate: N/A Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p(tv, progressive), 1920x872, 29.97 fps, 29.97 tbr, 29.97 tbn

My other content looks like propSet output so I'll probably go with that one for now.

ddfault commented 1 year ago

Rocky was able to slipstream changes to fix this moving forward:

OK, slipstreamed another change into build 248. The _FieldBased variable is now doing this instead of the older Avisynth semantics:

_FieldBased [int] Describes the composition of the frame: 0=frame based (progressive), 1=bottom field first, 2=top field first. Note that for DGSource() the GOP progressive flag is used to determine whether the frame is progressive. If deinterlacing is enabled in DGSource() then _FieldBased is overridden as progressive. If DGBob() or PVBob() are invoked, then _FieldBased is overridden as progressive; if neither is invoked then _FieldBased is passed through from DGSource().

It requires Avisynth+ version 8 or greater. The changes for DGSource() are implemented for Vapoursynth also. DGBob() and PVBob() do not currently support Vapoursynth. https://www.rationalqm.us/board/viewtopic.php?f=8&t=1237