Log in

View Full Version : How to disable de-interlace in ffms2 source


t_2
24th June 2024, 17:01
Searched, but couldn’t find an answer to what must be a silly question. I have an archival .avi file (mjpeg/wav) that has become corrupted after 25 years. Nothing worked, (neither AviSource, DirectShowSource, nor LSMASHsource) until I was finally able to open it correctly in AviSynth using ffms2 source (ffms2-5.0-msvc). Hurray! Now I can save to lossless HuffyUV! Unfortunately, I have one more problem: ffms2 de-interlaces the video by default, but I want to preserve the original de-interlacing (Pal 50i). What’s more, the de-interlacing has introduced some artifacts that distort the video. Can ffms2 pass a command from an avs scripy to disable de-interlacing? My sincere thanks in advance to anyone who can help me with this problem. This video is very dear to me, and I’d hate to lose it.

Sharc
24th June 2024, 19:08
Searched, but couldn’t find an answer to what must be a silly question. I have an archival .avi file (mjpeg/wav) that has become corrupted after 25 years. Nothing worked, (neither AviSource, DirectShowSource, nor LSMASHsource) until I was finally able to open it correctly in AviSynth using ffms2 source (ffms2-5.0-msvc). Hurray! Now I can save to lossless HuffyUV! Unfortunately, I have one more problem: ffms2 de-interlaces the video by default, but I want to preserve the original de-interlacing (Pal 50i). What’s more, the de-interlacing has introduced some artifacts that distort the video. Can ffms2 pass a command from an avs scripy to disable de-interlacing? My sincere thanks in advance to anyone who can help me with this problem. This video is very dear to me, and I’d hate to lose it.
ffms2 does not deinterlace by default. I understand that you want to preserve the original interlaced format. Are you sure that your mjpeg sources are interlaced at all?

t_2
24th June 2024, 21:43
My film was archived in 28 separate .avi files each about 500MB on a single layer writable DVD. Only the first file is corrupt. The other 27 files open in VirtualDub2 and show clearly, in high motion areas, the interlaced fields. Please see the attached jpeg named “VirtualDub2.jpeg.” Compare this to a frame named “ffms2.jpeg,” which was from the corrupted file that I managed to open in AviSynth+ with ffms2 source. All the fields have been de-interlaced.

Sharc
25th June 2024, 10:30
Can you upload short snippets (few seconds) of the 2 original files?
(Maybe upload to a file hoster like Mega or similar).
Were the 2 clips shot with the same camera? MJPEG is poorly standardized. It can be progressive or interlaced depending on codec/camera or camera setting options.
Any video processing in place when the files were archived to the DVD?

Edit: Try to set the framerate in ffms2(), something like ffms2("your_source",fpsnum=25,fpsden=1). Maybe it picks only fields from the corrupted .avi

t_2
25th June 2024, 16:54
Sorry about the long post! The corrupted avi is named “001.avi”. The weird thing is that I can open it in VirtualDub2, where it plays perfectly. I can even grab a frame using “export” command. See “VirtualDub2_001.jpeg.” There you can see that the fields have not been de-interlaced. But when I try to save “001.avi” in VirtualDub2 (using direct stream copy or some compression codec), I get the error message: “File format is incompatible.” AviUtl will open, play and save the file, but the output looks like: “AviUtl.jpeg.” The video looks the same as “AviUtl.jpeg” when I open the file in AviSynth+ using the following script:

A=LWLibavAudioSource("001.avi")
V=LWLibavVideoSource("001.avi")
AudioDub(V,A)

The weird thing is that half the time, when I open the file with this script, it looks and plays normally and doesn’t de-interlace the video in VirtualDub2’s playback window, then a frame grab looks like: “VirtualDub2_001.jpeg” – i.e., no de-interlacing! Even then, however, when I save the file in VirtualDub2, (regardless of whether it’s a direct stream copy of video/audio, or compressed with some codec), the output video always looks like: “AviUtl.jpeg.” The other half of the time, the above avi script even looks like “AviUtl.jpeg” in VirtualDub2’s playback window!

I tried your “fpsnum=25,fpsden=1” in ffms2 source and the output was still de-interlaced. When I saved the film in 28 parts to 4 DVD-R disks, I simply cut the film in the timeline of Adobe Premier and exported each section separately as an avi file, which I simply copied to the root of the DVD-R disk.

Do you have a Gmail account? If so, I have uploaded the corrupted file, “001.avi” as well as a non-corrupted file from the same camera/capture board, called: “003.avi” Please find the two links below!

JFYI, the file was recorded with a PAL MiniDV camcorder, but because my tech advisor was afraid that our Pentium III workstation couldn’t handle the editing demands, we imported the video into the workstation using the camera’s analog SVHS- PAL output port. That way, playback in the timeline was accelerated by the hardware capture card. The original DV footage, was, I believe progressive PAL 25p, (720x576) but I no longer have the cassettes to verify. I believe the camcorder interlaced the progressive video when it outputted via its SVHS port.

Links to Google Drive:

001.avi – corrupted file – opens, plays but doesn’t save properly.

https://drive.google.com/file/d/17XbDs-oYtUenC3Fi6qxGiuQjckuC7lrm/view?usp=sharing

003.avi – good file – opens, plays and saves/compresses properly.

https://drive.google.com/file/d/1wISmRW4UA0guJvnHXRYYdpDl8cE4aTHK/view?usp=sharing

Sharc
25th June 2024, 20:51
Something is strange.
Here a workaround. Reencoding it with x264 into .mp4 container seems to work. It is encoded interlaced.
https://mega.nz/file/6R1HgJ6K#LL1zOqqc_U-Vyc35-HL5GySjPqjGxU4vAaJV-Me_J9Y

(You can encode lossless with x264 as well, just set --crf 0)

Edit:
It works using the ffmpeg Huffyuv codec. Here the Huffyuv interlaced lossless file
https://mega.nz/file/nQFgHBgR#o61KPAIVF33okwDjUgRrh6ObZ2m37iVv2EXxOdZ3jT4

ffms2 as a source filter seems to fail. You need to install the Picvideo codec and open the file with AviSource() rather than with ffms2.

Here the Picvideo codec (trial version):
https://mega.nz/file/TINWgZrA#z2vzacLtM5EpVGrG4JSRjV9ajqeRpZJn80LxB-kds0E

It also works with Virtualdub2.

hello_hello
26th June 2024, 04:29
ffms2 r2390 and ffms2 version 5.0 and lsmash opened the AVI in Avisynth for me. BSVideoSource didn't know what to make of it.
There was a lot of aliasing when ffms2 was decoding as it appeared to be de-interlacing but not for LWLibavVideoSource. I'm not sure why, but VirtualDub2 often displays nothing but blank frames for a while when opening the AVI with the AVI Driver (taking a long time to display something, and it upsets AVIFile compatibility mode).

https://imgur.com/6Gm9dxk.png

It's over my head, but it's as if the fields are stored together at the beginning but separately later on. SMPlayer starts off displaying frames then switches to displaying fields as frames, I assume.

https://imgur.com/O9OXdwp.png

poisondeathray
26th June 2024, 04:45
I'm not sure why, but VirtualDub2 often displays nothing but blank frames when opening the AVI directly.

Depends on what decoder vdub2 is configured to use. If you have "prefer internal video decoders over installed third-party codecs (MJPEG...etc...)" enabled , it decodes ok .

With the file directly loaded, file=>file information will tell you what is being used to decode

t_2
26th June 2024, 06:40
@Sharc

Wow! That PICVideo MJPEG codec was the answer to all my problems! Thank you so much for taking the time to help me out! I really appreciate it! You are a life saver. I mean it! Unlike FFMpeg, the PicVideo codec even opens the corrupted file perfectly in AviSynth+, as you said. For that matter, VirtualDub2 also opens it correctly – wonder what it uses to do that?

I tried to buy the PICVideo codec, however, their web site says it’s no longer for sale! I notice that the trial version counts how many times you use it. So I did an end task on VirtualDub2 to save one instance of my limited uses. What a mistake! Unfortunately, after that the codec no longer works on my system. Whenever I click on continue, it counts another use, but won’t let the program access the codec. I have to do another end task to close VirtualDub2.

I tried uninstalling and reinstalling the PICVideo codec, but that didn’t solve the problem. Unfortunately, system restore was turned off on the computer that I am using, so I wasn’t able to roll back to an earlier restore point. No worries, I can use another computer to get my job done. I was, however, wondering what exactly the limitations are on the trial version? Is there any workaround to these limitations? Thanks again for solving my problem!

@hello-hello

With regard to that error message about a frame height of 272 vs 270, I noticed that VirtualDub2 opens the file and plays it well, but for some reason it opens it as with a file size of 720x544 when the original file is actually 720x540. VirtualDub2 also saves it with the same enlarged dimensions! Does that mean that it automatically resizes the fields? Since this copy is for archival purposes, I’d hate to suffer the slight quality loss that an unnecessary resize would occasion.

@poisondeathray

I do have “prefer internal video decoders” enabled in VirtualDub2. With the exception of the resize mentioned about, it opens and plays the avi files correctly, without de-interlacing and introducing all those nasty articacts. The PICVideo codec even leaves the file as is, i.e.: 720x540.

@everyone: Thanks for your help!

Sharc
26th June 2024, 08:23
@Sharc

I tried to buy the PICVideo codec, however, their web site says it’s no longer for sale! I notice that the trial version counts how many times you use it. So I did an end task on VirtualDub2 to save one instance of my limited uses. What a mistake! Unfortunately, after that the codec no longer works on my system. Whenever I click on continue, it counts another use, but won’t let the program access the codec. I have to do another end task to close VirtualDub2.

I tried uninstalling and reinstalling the PICVideo codec, but that didn’t solve the problem. Unfortunately, system restore was turned off on the computer that I am using, so I wasn’t able to roll back to an earlier restore point. No worries, I can use another computer to get my job done. I was, however, wondering what exactly the limitations are on the trial version? Is there any workaround to these limitations? Thanks again for solving my problem!

Uninstall PicVideo using the Revo Uninstaller. Then re-install Picvideo.
Even the free version of Revo Uninstaller seems to reset the Picvideo counter (use the "Scan" for a complete uninstall).
https://www.revouninstaller.com/de/revo-uninstaller-free-download/
https://www.snapfiles.com/get/revouninstaller.html

Sharc
26th June 2024, 09:29
... and ffms2() seems to work as well when you just trim (cut) the first 564 frames of your 001.avi. There seems to be something odd is going on at the beginning of the clip which fools most codecs, so

ffms2("001.AVI")
trim(564,0)
assumeTFF()


seems to solve the issue as well.

Edit:
Here a workaround for the full 001.avi file, splitting it into 2 parts:
v1=ffms2("001.AVI")
v2=ffms2("001.AVI")
v1=v1.trim(0,563)
v2=v2.trim(564,0)
v=v1++v2
v=v.assumeTFF()
return v
https://mega.nz/file/3BlwxJqI#mbGeCPhsHlndlKLd6RtCVdOeqY-JZw8hRCXpY3HVmBM

t_2
26th June 2024, 22:44
That's amazing. I added audio to your script and was able to save to HuffyUV (YUY2) / Wav in avi container! Hurray! This is especially welcome as the PICVideo curse has settled upon all my software. I tried to install the codec on my personal workstation only to find that the same abortive behavior was reproduced there as had occurred on the first computer. The only think I can think of is that I migrated by copying the same installer via USB drive to the second computer. Alas, the super uninstaller didn't work its magic for me. I even set a restore point on my workstation, but the curse was upon it even after the roll-back. Therefore, your second solution is every bit as welcome as your first. Thanks again!

Edit: Like VirtualDub2, (which allegedly uses FFmpeg), AviSynth+ (Using FFms2 Source) opens "001.avi" with a frame size of 720x544, whereas the actual frame size of the saved avi file is 720x540. On the other hand, PICVideo's MJPEG codec preserves the original frame size. 1) Do you know why the frame size is enlarged when opening with FFMpeg? 2) Also, do you know how this is accomplished?

Sharc
27th June 2024, 08:16
Edit: Like VirtualDub2, (which allegedly uses FFmpeg), AviSynth+ (Using FFms2 Source) opens "001.avi" with a frame size of 720x544, whereas the actual frame size of the saved avi file is 720x540. On the other hand, PICVideo's MJPEG codec preserves the original frame size. 1) Do you know why the frame size is enlarged when opening with FFMpeg? 2) Also, do you know how this is accomplished?
My best guess:
The recorded frame is actually 720x544 which is mod16, means 720/16=45 macroblocks horizonzally and 544/16=34 macroblocks vertically.
PICvideo seems to crop 4 pixels vertically in order to make the frame exactly DAR 4:3 (720:540 = 4:3).
If you compare the 2 variants you will see that the ffms 720x544 version has indeed 4 pixels more picture content at the bottom, but 720:544 is not exacly 4:3 but 1.32353.
Similar one sees with blu-ray: DAR 1920x1080 (16:9), but internally it is actually processed as 1920x1088.

P.S.
And add AssumeTFF() in your script. See my corrected post #11.

tebasuna51
27th June 2024, 13:21
... and ffms2() seems to work as well when you just trim (cut) the first 564 frames of your 001.avi. There seems to be something odd is going on at the beginning of the clip which fools most codecs, so

ffms2("001.AVI")
trim(564,0)
assumeTFF()


seems to solve the issue as well.

Edit:
Here a workaround for the full 001.avi file, splitting it into 2 parts:
v1=ffms2("001.AVI")
v2=ffms2("001.AVI")
v1=v1.trim(0,563)
v2=v2.trim(564,0)
v=v1++v2
v=v.assumeTFF()
return v
https://mega.nz/file/3BlwxJqI#mbGeCPhsHlndlKLd6RtCVdOeqY-JZw8hRCXpY3HVmBM

The first part is only black screen and silence.
With the PICVideo decoder do you obtain some audio/video in this first part?

Also ffms2 must output audio and video but I only get video without audio.

I obtain good deinterlacing with:

a=FFAudioSource("001.AVI")
v=FFVideoSource("001.AVI")
AudioDub(v,a).trim(564,0)
AssumeTFF()
QTGMC()

Let the fps to 50, to preserve the motion (like I make with many of my DV sources), and try with some QTGMC() parameters to improve the image.
Of course you can let it like 50i, without QTGMC, but I can't recommend recode it like 50i.

Sharc
27th June 2024, 19:44
The first part is only black screen and silence.
Yes, but with the title text "Nagyböjt" at the end. I think the first part is corrupted as I understand from the OP, but I rather think that the black frames are ok as the audio only starts together with the text "Nagyböjt". Only the OP t_2 can tell whether something is missing.
With the PICVideo decoder do you obtain some audio/video in this first part?

Unfortunately I deleted the PICvideo file already and uninstalled the codec, but I think to remember that there was black frames with 2 flashes only.

Also ffms2 must output audio and video but I only get video without audio.
Thanks for the hint. I didn't even care about the audio in my tests because I assumed that the audio can be easily remuxed later. My focus was on the correct interlaced decoding and (lossless) interlaced recoding using a working mjpec codec, or ffms2() alternative.

I obtain good deinterlacing with: ....

Sure, once we have a correct interlaced file we can apply a good deinterlacer. Personally, I keep my "archived" interlaced stuff always interlaced though. Well, that's perhaps just me.

t_2
10th July 2024, 17:29
Thank you to one and all! I managed to get QTGMC installed on my old Win7 workstation and the results are amazing!! I remember 50 years ago when I first heard about digital compression (PNGs, I think), I was amazed that you could compress close to 50% without losing quality. I experienced something of the same wonder after seeing the results of the QTGMC de-interlacer. The overall video quality (judged by apparent sharpness) seems to have increased dramatically over the original master copy! And the motion at 50p is so much smoother.

These results have caused me to ponder whether another grave limitation of our film could easily be corrected. The film is a 60 min drama produced by our Catholic high school. When I started the project, I didn't even know about XLR cables, focus, lighting, editing, etc. As a result, although we shot the film in one week (with a camcorder on autofocus), it was in post production for 2 years, while we dubbed most of it and learned to use all kinds of video special effects (Blackbelt System's WinImiges program) to clean up the video. One problem, I never got around to tackling was the exposure problems. Not only did we use auto-focus, we also shot the entire film without artificial lighting.

After this long explanation, my simple question is this: Does anyone know of a filter/plugin that can correct video that was poorly exposed. For example, some of our video was taken against the backdrop of a bus window, with the result that the window is properly exposed, while the faces of the actors in the foreground are underexposed. Thanks for considering this problem!

Edit: In the meantime, I found HDRAGC plugin, which does what I wanted, and am currently experimenting with it!

t_2
11th July 2024, 16:26
I'm trying to experiment with HDRAGC (High Dynamic Range Automatic Gain Control ) plugin, however it is 32 bit. After searching for hours, I finally managed to find an x86 binary for Media Player Classic which invoked a 32 bit instance of Avisynth+, however I'm not able to encode with this media player. Does anyone know where I can get 32 bit versions of VirtualDub2. I found a 32 bit binary for AviDemux but the install lacked the 32 bit version of the avsproxygui.exe. It has both 32 bit and 64 bit versions of the proxy itself but I don't know how to use the command line. Thanks in advance to anyone who can point me in the right direction. Is there some way (some command I can add to my avs script) of invoking a 32 bit version of Avisynth+ that would run in 64 bit VirtualDub2? Sorry, if this is a silly question, but I'm rather clueless.

Emulgator
11th July 2024, 16:42
https://sourceforge.net/projects/vdfiltermod/files/VirtualDub%20pack/version%2020/
44282 zip contains both 32 and 64 bit versions. You just run the 32bit version (VirtualDub.exe) 4008KB

StvG
11th July 2024, 17:08
I'm trying to experiment with HDRAGC (High Dynamic Range Automatic Gain Control ) plugin, however it is 32 bit. After searching for hours, I finally managed to find an x86 binary for Media Player Classic which invoked a 32 bit instance of Avisynth+, however I'm not able to encode with this media player. Does anyone know where I can get 32 bit versions of VirtualDub2. I found a 32 bit binary for AviDemux but the install lacked the 32 bit version of the avsproxygui.exe. It has both 32 bit and 64 bit versions of the proxy itself but I don't know how to use the command line. Thanks in advance to anyone who can point me in the right direction. Is there some way (some command I can add to my avs script) of invoking a 32 bit version of Avisynth+ that would run in 64 bit VirtualDub2? Sorry, if this is a silly question, but I'm rather clueless.

MP_Pipeline (https://github.com/pinterf/MP_Pipeline/tree/master/Documentation) can be use to load 32-bit plugins with 64-bit chain.
You can check the thread (https://forum.doom9.org/showthread.php?t=163281) for usage examples.

t_2
12th July 2024, 07:54
Many thanks to Emulgator for the link to the x86 binary of VirtualDub2. That solved my problem because now I can run the HDRAGC plugin in 32 bit environment and save to lossless and then import this video into my script that calls 64 bit version of Avisynth+.

Many thanks also to StvG for the MP_Pipeline Plugin! I have written the script below which I feed to VirtualDub2 x64. (I put the 4 files in the x64 folder of MP_Pipeline download into the plugins64+ folder of Avisynth+ and the 4 files from the x86 folder into the plugins+ folder of Avisynth+, But when I run the script in VirtualDub2 x64, I get the following error message:

Avisynth open failure
MP_Pipeline: Unable to create slave process. Message:
(C:\Users\password\Desktop\HDR\HDRx64.avs, line 18

Here is my avs script:

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

A=FFAudioSource("ivp2.mp4")
V=FFVideoSource("ivp2.mp4")
A=AudioDub(V,A).Trim(43549,50398).KillVideo()

MP_Pipeline("""
SetMemoryMax(3072)


FFVideoSource("ivp2.mp4")
ShowFrameNumber()
Trim(43549,50398)

HDRAGC()

### prefetch: 16, 0

### ###
""")

Final=AudioDub(A)
Return Final

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

In this script, I’m trimming out a portion of the film where the actors are filmed against the backdrop of a bus window. Their faces are very underexposed, so I use HDVAGC to lighten up the shadows. It gives very good results. I separated the audio from the video because I read in the Doom9 forum that MP_Pipeline, at least in its earlier versions couldn’t handle audio. I’m sure I’m committing the most rudimentary of errors, but can’t figure out what it might be. Any help would be much appreciated!

Sharc
12th July 2024, 08:51
You may also want to give RETINEX (for Avisynth) a try.
https://github.com/Asd-g/AviSynth-Retinex/releases/tag/1.0.3

Below links to demos of files which I "fixed" some time ago for other users
https://mega.nz/file/6QMQiYTK#oOI_R6emtrmu2BVcwwgn_M0euM7KVmeM95MdrsEnb2E
https://mega.nz/file/2EcTkDCQ#6CsCego-ECjWgkav51zvVfz0LGXCum61h1SoqewV_cY

StvG
12th July 2024, 12:12
...
Avisynth open failure
MP_Pipeline: Unable to create slave process. Message:
(C:\Users\password\Desktop\HDR\HDRx64.avs, line 18

Here is my avs script:

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

A=FFAudioSource("ivp2.mp4")
V=FFVideoSource("ivp2.mp4")
A=AudioDub(V,A).Trim(43549,50398).KillVideo()

MP_Pipeline("""
SetMemoryMax(3072)


FFVideoSource("ivp2.mp4")
ShowFrameNumber()
Trim(43549,50398)

HDRAGC()

### prefetch: 16, 0

### ###
""")

Final=AudioDub(A)
Return Final

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


1. You need to have installed both AviSynth+ x64 and AviSynth x86. (in case you don't have already)
2. You need HDRAGC plugin to be in the plugins/plugins+ folder.
3. You need ffms2 plugin to be in the plugins64/plugins64+ folder.

Try:SetMemoryMax(3072)

A=FFAudioSource("ivp2.mp4")

MP_Pipeline("""
### platform: win64

FFVideoSource("ivp2.mp4")
ShowFrameNumber()
Trim(43549,50398)

### ###
### platform: win32

HDRAGC()

### prefetch: 16, 0
### ###
""")

Final=AudioDub(A)
Return Final

t_2
12th July 2024, 20:38
Thanks to both of you! Retinex works great and the script also worked. I was able to run MP_Pipeline without further ado! Thanks again!

t_2
20th July 2024, 06:39
https://drive.google.com/file/d/1jtXIsrcrkAHDtajqny4h53vzIj2ZwGQx/view?usp=sharing


Please find above a Google Drive link to a 2 min video from our 25-year-old movie. It’s AVC (x264) with YUY2 color space because I’m working with MJPEG originals. Below you will find a script that opens the video and applies one or another of two separate luminance adjusting plugins. The scenes were all shot on a bus against the backdrop of a window. So the window is overexposed and the actors are underexposed. That, of course, is what I want to fix. I really like the appearance of Retinex plugin but sometimes the artifacts or a strobing of the background luminance caused me to opt for HDRAGC. I especially noticed this strobing in the close ups as indicated in the script notes. Does anyone know what might be causing this strobing or if there is some way to eliminate it?

I am very much indebted to Sharc for coming up with a workaround for opening my corrupted archive file of the movie. That was a life-saver! Also thanks for telling me about QTGMC. My original footage was 50i and now the file above is a pristine 50p – really amazing stuff! Also, thanks for telling me about Retinex. Thanks also, to Emulgator for the 32 bit version of VirtualDub2 and to StvG for telling me about MP_Pipeline ( V.0.23) which the script below utilizes. If someone knows how to tweak Retinex to solve the strobing problem, I would be much obliged. I have been experimenting with both plugins for weeks now but am at somewhat of a crossroads. I also, understand, if nobody has the time. We live in a busy world!

Here is a link to the AVS file, in case my copy and paste below doesn’t work:
https://drive.google.com/file/d/1kVcf9mopnnXm1yYu9PMw7AYexbbW5_Nq/view?usp=sharing

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

# This script will only work if you have the MP_pipeline plugin up and running on your system (and the other two plugins) First, I open the audio, upstream of the pipeline
# Then I open the video only within the 64 bit portion of the pipeline. Then I separate the 2 min video into 6 sceens. I do this three
# seperate times in the script. First the 64 bit Retinex (version 1.0.3) plugin either adjusts the luminance or it doesn't depending on whether it is turned
# on or off (by toggling "#") Downstream, in the 32 bit portion of the pipeline, the 32 bit HDRAGC (High Dynamic Range Automatic Gain Control) (version 1.8.7)
# plugin, either adjusts the luminance or it doesn't depending on whether this commend is turned on or off in the script. Every scene in this
# series of sceens was poorly illuminated, so I apply one or the other plugins to every sceen. However, the two plugins could both be disabled "#" in both
# the 64 and 32 bit portion of the script respectively, in which case the script would pass the unaltered sceen downstream, where it could be returned as
# Sceen001c, for example. Therefore, for example, Sceen002a, Sceen002b, and Sceen002c each contain the very same frames of the original luma.avi file. Normally,
# you would only want to return the "c" set of sceens. It's the only one with the audio, anyway. In this original version of the script, I have only opted for HDRAGC over Retinex at Sceen003 because Retinex
# was bright, but the resulting artifacts in Reka's hair were too much. So I preferred to live with the darkness rather than the hovering cloud like artifact. I prefer
# the visual appearance of the Retinex plugin, but the strobbing-background problem, especially in the close up sceens caused be to opt instead for HDRAGC. I have, however, left
# the Retinex on in this script, so that you can see for yourself the strobbing.

SetMemoryMax(3072)

AudioX=FFAudioSource("Luma.avi")

MP_Pipeline("""
### platform: win64

Video1=FFVideoSource("Luma.avi")

# Audio has been removed as MP_pipeline doesn't like it. This is where
# we apply 64 bit filters/plugins like Retinex, i.e. MSCCP(). I didn't get good results
# using just one plugin alond, so use the MP_pipeline so I can use both the 64 bit Retinex and the 32 bit HDRAGC plugins in the
# same script.

Sceen001a=Video1.Trim(0, 01801).ConvertToYUV444.MSRCP(sigma=150, fulls=true, fulld=true).ConvertToYUV422() # Two girls - Bogi and Reka are common Hungarian girl's names.
Sceen002a=Video1.Trim(01802, 02093).ConvertToYUV444.MSRCP(sigma=250, fulls=true, fulld=true).ConvertToYUV422() # Bogi - First close up
Sceen003a=Video1.Trim(02094, 02515)#.ConvertToYUV444.MSRCP(sigma=150, fulls=true, fulld=true).ConvertToYUV422() # Reka - First close up
Sceen004a=Video1.Trim(02516, 04705).ConvertToYUV444.MSRCP(sigma=150, fulls=true, fulld=true).ConvertToYUV422() # Two girls together.
Sceen005a=Video1.Trim(04706, 05855).ConvertToYUV444.MSRCP(sigma=150, fulls=true, fulld=true).ConvertToYUV422() # Reka - 2nd close up
Sceen006a=Video1.Trim(05856, 0).ConvertToYUV444.MSRCP(sigma=300, fulls=true, fulld=true).ConvertToYUV422() # Bogi - 2nd close up

UnalignedSplice(\
Sceen001a,\
Sceen002a,\
Sceen003a,\
Sceen004a,\
Sceen005a,\
Sceen006a)



### ###
### platform: win32

# Still no audio here. This is where we apply 32 bit filters
# like HDRAGC The video is repartitioned into the same 6 sceens
# so that different filters can be applied to each sceen as needed.
# I set max_sat=1.0, which causes the plugin to only adjust the Y channel
# When I tried to adjust the Color channels too, I was getting an line
# on the face of one of the girls. It seemed like the top half of the frame
# showed increased chroma but the bottom half didn't. This error, however,
# has proved intermittant on my system. Go figure!

Video2=Trim(0, 0)


Sceen001b=Video2.Trim(0, 01801) # Two girls together
Sceen002b=Video2.Trim(01802, 02093)#.HDRAGC(min_gain = 3.75, coef_sat = 0.75, max_sat=1.0).Levels(0, 0.8, 255, 0, 225) # Bogi - First close up
Sceen003b=Video2.Trim(02094, 02515).HDRAGC(min_gain = 3.25, coef_sat = 0.75, max_sat=1.0).Levels(0, 0.8, 255, 0, 255) # Reka - First close up
Sceen004b=Video2.Trim(02516, 04705) # Two girls together
Sceen005b=Video2.Trim(04706, 05855)#.HDRAGC(min_gain = 3.25, coef_sat = 0.75, max_sat=1.0).Levels(0, 0.8, 255, 0, 225) # Reka - 2nd close up
Sceen006b=Video2.Trim(05856, 0)#.HDRAGC(min_gain = 3.75, coef_sat = 0.75, max_sat=1.0)#.Levels(0, 0.8, 255, 0, 225) # Bogi - 2nd close up

UnalignedSplice(\
Sceen001b,\
Sceen002b,\
Sceen003b,\
Sceen004b,\
Sceen005b,\
Sceen006b)


### prefetch: 16, 0
### ###
""")

# Here the audio is added and the vide0/audio is cut up into the same
# scenes as above for individual evaluation. "Total" splices the scenes together.

VideoX=Trim(0,0)

Video4=AudioDub(VideoX, AudioX)#.ShowFrameNumber()

Sceen001c=Video4.Trim(0, 01801) # Two girls together
Sceen002c=Video4.Trim(01802, 02093) # Bogi - First close up
Sceen003c=Video4.Trim(02094, 02515) # Reka - First close up
Sceen004c=Video4.Trim(02516, 04705) # Two girls together
Sceen005c=Video4.Trim(04706, 05855) # Reka - 2nd close up
Sceen006c=Video4.Trim(05856, 0) # Bogi - 2nd close up

Total=UnalignedSplice(\
Sceen001c,\
Sceen002c,\
Sceen003c,\
Sceen004c,\
Sceen005c,\
Sceen006c)


#Return Sceen001b
#Return Sceen002b
#Return Sceen003b
#Return Sceen004b
#Return Sceen005b
#Return Sceen006b

Return Total

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

Edit: Sorry, I just noticed that I misspelled scene throughout. Won't worry about that now...

Selur
20th July 2024, 09:59
Small suggestion: maybe use 'code'-tags to make your posts more readable to others.

Emulgator
20th July 2024, 18:17
Jó estét ! I would welcome a sample of the source MJPG file.

t_2
20th July 2024, 18:59
Köszönöm érdeklődését!


https://drive.google.com/file/d/1zFGHFY1VDzN-HCjkquzZkc8tk5E4e6Cp/view?usp=sharing


If you’re interested in knowing what the actors are saying, please find below a link to the entire 61 min drama with English subtitles. The young ladies’ conversation starts at 14 min 30 sec and lasts for 2 min 17 sec. The conversation stands on its own. SPOILER ALERT! The film is religious content on steroids!

https://drive.google.com/file/d/1Hhjr9h76PO-GfqostviTcYIbMOJRsBvg/view?usp=sharing

t_2
23rd July 2024, 03:27
@ Emulgator

Thanks again for your interest in my problem! That was so kind of you! In the meantime, I have been working further on the problem. I took your cue and started working with the raw archive footage before passing it through the de-interlacer. Alas, the strobing problem – lightening and darkening of the background – wasn’t fixed. Then, I decided to put white borders around the clips (settled on 200 pixels all around) before passing them to the Retinex filter and cropping them off afterwards. That seems to have done the trick.

Please find here a Google Drive link to the video output of the script which I have cut and pasted below.

https://drive.google.com/file/d/1Hs5uWZOXOqIMZ_Pi5-NGXLyIYTbyrRp4/view?usp=sharing

I was even able to use much stronger settings (lowered “sigma” from 120 to 60) for the effect. This did produce another distortion effect, a sort of halo that surrounds the two girls in scenes 2 and 4. I think I can live with that. Do you think there is any way to improve on these results? I must admit that I am pleasantly pleased. Really interested in your feedback.

##############################################
AudioX=FFAudioSource("LumaMJPEG.avi")
Video1=FFVideoSource("LumaMJPEG.avi")

y=200


Scene001a=Video1.Trim(0, 900).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Two girls - Bogi and Reka are common Hungarian girl's names.
Scene002a=Video1.Trim(901, 1046).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Bogi - First close up
Scene003a=Video1.Trim(1047, 1257).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Reka - First close up
Scene004a=Video1.Trim(1258, 2352).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=120, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Two girls together.
Scene005a=Video1.Trim(2353, 2927).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Reka - 2nd close up
Scene006a=Video1.Trim(2928, 0).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Bogi - 2nd close up

Video2=UnalignedSplice(\
Scene001a,\
Scene002a,\
Scene003a,\
Scene004a,\
Scene005a,\
Scene006a)

Video2=AudioDub(Video2, AudioX).AssumeTFF()

Scene001b=Video2.Trim(0, 900)
Scene002b=Video2.Trim(901, 1046)
Scene003b=Video2.Trim(1047, 1257)
Scene004b=Video2.Trim(1258, 2352)
Scene005b=Video2.Trim(2353, 2927)
Scene006b=Video2.Trim(2928, 0)

Luma=UnalignedSplice(\
Scene001b,\
Scene002b,\
Scene003b,\
Scene004b,\
Scene005b,\
Scene006b)

#Return Scene001b
#Return Scene002b
#Return Scene003b
#Return Scene004b
#Return Scene005b
#Return Scene006b

Return Luma

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

Emulgator
23rd July 2024, 10:37
Downloading now. Ah, I get better shadow details fom the source MJPEG. Expected that. Stay tuned.

# +++++ Start of AutoPath 1 Videostream + 0 or 1 Audiostream +++++
SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("LWLibavVideoSource", 3)
SetFilterMTMode("LWLibavAudioSource", 3)
SetFilterMTMode("FFVideoSource", 3)
SetFilterMTMode("FFAudioSource", 3)
SetFilterMTMode("DGSource", 3)
SetFilterMTMode("InpaintDelogo", 3)
scriptextlen=FindStr(RevStr(ScriptFile()),".")
avextlen=FindStr(RevStr(LeftStr(ScriptFile(),StrLen(ScriptFile())-scriptextlen)),".")
avfolder=ScriptDir()
audfolder=avfolder
avfile0=LeftStr(ScriptFile(),(StrLen(ScriptFile())-scriptextlen-avextlen))
avext0=LeftStr(RightStr(ScriptFile(),scriptextlen+avextlen),avextlen)
vidsrc= avext0==".d2v" ? "MPEG2Source" : avext0==".dga" ? "AVCSource" : avext0==".dgi" ? "DGSource" : avext0=="mpg" ? "FFVideoSource" : "LWLibavVideoSource"
#vidsrc="LWLibavVideoSource"
#vidsrc="FFVideoSource"
vidformatLWLibav="YUV444P8"
vidformatFF="YV24"
vidargDG158="idct=5, ipp=true, cpu=6, cpu2=String(xxxxxx), moderate_h=40, moderate_v=80"
audfile=avfile0
audext=avext0==".d2v" ? ".ac3" : avext0==".dgi" ? ".ac3" : avext0
#audext=avext0==".d2v" ? ".dts" : avext0==".dgi" ? ".dts" : avext0
#audext=avext0==".d2v" ? ".wav" : avext0==".dgi" ? ".wav" : avext0
#audext=".mpg"
audpid= avext0==".d2v" ? " T80 2_0ch 224Kbps DELAY 0ms" : avext0==".dgi" ? " PID 1100 2.0ch 48KHz 192Kbps DELAY 0ms" : avext0==".mpg" ? " Tc0 L2 2ch 44.1 224 DELAY 0ms" : ""
#audpid= avext0==".d2v" ? " T81 3_2ch 448Kbps DELAY 0ms" : avext0==".dgi" ? " T81 3_2ch 48KHz 448Kbps DELAY 0ms" :""
audpid=""
audsrc= audext==".ac3" ? "NicAC3Source" : audext==".mp2" ? "FFAudioSource" : "LWLibavAudioSource"
#audsrc="BestAudioSource"
#audsrc="FFAudioSource"
ffaudtrk=1
audsrc="LWLibavAudioSource" #Asd-g versions only, here 1194
Libavaudtrk=-1 #int stream_index = -1 #-1: default stream
Libavaudcache=true #bool cache = true
Libavaudcachefile=String(audfolder)+String(audfile)+String(audpid)+String(audext)+".lwi"#string cachefile = source +".lwi"
Libavaudavsync=false #bool av_sync = false
Libavaudlayout="FL+FR"#"0x3f"#"FL+FR+FC+LFE+SL+SR" #string layout = "" | CN ? No Audio | 5.1 -> "5.1" or "FL+FR+FC+LFE+SL+SR" or "0x3f"
Libavaudrate=0 #int rate = 0
Libavauddecoder="" #string decoder = ""
Libavaudffloglevel=0 #int ff_loglevel = 0
Libavaudcachedir="" #string cachedir = ""
Libavindexingpr=true #bool indexingpr = true
Libavauddrcscale=0.0 #float drc_scale = 1.0 #0.0 deactivates DRC, -values invert the DRC processing
Libavaudffopts="" #string ff_options = ""
Exist(String(avfolder)+String(avfile0)+String(avext0)) ? Apply(vidsrc,String(avfolder)+String(avfile0)+String(avext0))\
: Assert(false, "! NO SUCH AV FILE -> " + String(avfolder)+String(avfile0)+String(avext0) + "<- NO SUCH AV FILE !")
#try {AudioDub(last,Apply(audsrc,String(audfolder)+String(audfile)+String(audpid)+String(audext)))}
try {AudioDub(last,Apply(audsrc,String(audfolder)+String(audfile)+String(audpid)+String(audext),Libavaudtrk,Libavaudcache,Libavaudcachefile,Libavaudavsync,Libavaudlayout,Libavaudrate,Libavauddecoder,Libavaudffloglevel,Libavaudcachedir,Libavindexingpr,Libavauddrcscale,Libavaudffopts))}
#Blankclip(last).Subtitle(String(audfolder)+String(audfile)+String(audpid)+String(audext))
catch (err) {last}
# ----- End of AutoPath 1 Videostream + 0 or 1 Audiostream -----
# source is 720x544 TFF
ConvertToYUV444()
smoothdebug=0
SmoothCurve16(ConvertTo16bit().ConvertToStacked(),\
Ycurve="0-1023;12000-14000;38000-35000;55000-42000;60000-48000;65535-61000",\
Ucurve="0-0;16383-16383;32767-32767;49151-49151;65535-65535",\
Vcurve="0-0;16383-16383;32767-32767;49151-49151;65535-65535",\
limiter=false, HQ=true, interp=100, debug=smoothdebug==0 ? false : true, screenW=1920, screenH=1080).ConvertFromStacked()#.Convertbits(8)
propSet("_FieldBased",2) #QTGMCp needs propSet from a certain version on. 0=frame based (progressive), 1=bottom field first, 2=top field first
QTGMCp()
ConvertBits(32).ConvertToPlanarRGB().MSRCR(sigma=[300,400,500], lower_thr=0.001, upper_thr=0.001, fulls=false, fulld=false, restore=125.0).ConvertToYUV444().ConvertBits(16)
#return(last)
SmoothCurve16(ConvertTo16bit().ConvertToStacked(),\
Ycurve="0-0;12000-13000;32767-32767;55000-48000;65535-65535",\
Ucurve="0-0;16383-18000;32767-32767;49151-47000;65535-65535",\
Vcurve="0-0;16383-16383;32767-32767;49151-46000;65535-65535",\
limiter=false, HQ=true, interp=100, debug=smoothdebug==0 ? false : true, screenW=1920, screenH=1080).ConvertFromStacked().ConvertBits(10)
SMDegrain(tr=6, thSAD=400, RefineMotion=true, contrasharp=true, interlaced=false, plane=4, prefilter=8, chroma=true, Show=false) #5: DFTTest, 6: KNLMeansCL, 7: DGDenoise, 8: BM3D
GrainFactory3(2*Round(Pow(2,BitsPerComponent-8)),2*Round(Pow(2,BitsPerComponent-8)),1*Round(Pow(2,BitsPerComponent-8)),100,100,100,0.9*sqrt(width()/720),0.7*sqrt(width()/720),0.5*sqrt(width()/720),0,0,0,0,0,24*Round(Pow(2,BitsPerComponent-8)),56*Round(Pow(2,BitsPerComponent-8)),128*Round(Pow(2,BitsPerComponent-8)),160*Round(Pow(2,BitsPerComponent-8)))
#portalscope()

This gives 720x544x50p YUV444P10 with lots of detail.
It still needs colour matching to sunlight per shot, your turn (MSRCR amplifies sky casts: sometimes pinkish tint, sometimes cyan tint).

P.S. SMDegrain to your liking, ReGrain...well, there they are. Couldn't resist.

t_2
23rd July 2024, 11:56
@ Emulgator

Wow! Very impressive script. I can't make heads nor tails of it. I am getting the following error: "No such video file" at line 47, but can't figure out what file it is looking for. Also, I noticed in your script that you call QTGMCp(). I only have QTGMC() installed. Will that give me problems? I can't wait to see your results, but I will have to since I am out of town the next 4 days without Internet!

Emulgator
23rd July 2024, 12:20
Ah, forgot to mention: Name the script after your file and put it side by side like that: "LumaMJPEG.avi.avs"
Or just cut off all the intro including # ----- End of AutoPath 1 Videostream + 0 or 1 Audiostream -----
and start with LWLibavVideoSource(), LWLibavAudioSource() as usual.

Why QTGMCp() ? It seems to be the gold standard for me now, gets so much details out of interlaced sources, be it VHS or any other.
For trying your script QTGMC is fine too.

Rendering 6850frames @ 2,4fps now into a H.264 4:2:0 10bit .mkv
BTW, just as I saw the scene in the completed movie:
My result is not that much different from what you already achieved in the final movie. Maybe less strobing..
I just prefiltered before Retinex to make it less hard for it, and postfiltered again.

Sharc
23rd July 2024, 16:36
A luma mask may help to prevent the clipped bright sky from just turning occasionally into grey by the filtering (file fx.mp4 of post#28).
Something like
lmask=clip.mt_binarize(threshold=58,upper=true).converttoYV12(interlaced=true).GaussianBlur(varY=2000.0).grayscale()
overlay(<your filtering>,mask=lmask)

(I usually apply Retinex with a mask, for example)

t_2
24th July 2024, 18:53
@ Emulgator

I do have Internet afterall, but am not at my usual workstation. I couldn't get your script to run on this machine, but will try again back at home. Thanks again!

@Sharc

I tried adding your code to my script but avisynth+ didn't recognize GaussianBlur(). Here is my modified script below: I inserted your code
at the bottom. Do I have the right idea?

#####################################
AudioX=FFAudioSource("LumaMJPEG.avi")
Video1=FFVideoSource("LumaMJPEG.avi")
clip=AudioDub(Video1, AudioX)
y=200


Scene001a=Video1.Trim(0, 900).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=60, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Two girls - Bogi and Reka are common Hungarian girl's names.
Scene002a=Video1.Trim(901, 1046).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=60, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Bogi - First close up
Scene003a=Video1.Trim(1047, 1257).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=60, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Reka - First close up
Scene004a=Video1.Trim(1258, 2352).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=60, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Two girls together.
Scene005a=Video1.Trim(2353, 2927).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=80, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Reka - 2nd close up
Scene006a=Video1.Trim(2928, 0).SeparateFields().AddBorders(y, y, y, y, $FFFFFF).ConvertToYUV444.MSRCP(sigma=60, fulls=true, fulld=true).ConvertToYUV422().Crop(y, y, -y, -y). Weave() # Bogi - 2nd close up

Video2=UnalignedSplice(\
Scene001a,\
Scene002a,\
Scene003a,\
Scene004a,\
Scene005a,\
Scene006a)

Video2=AudioDub(Video2, AudioX).AssumeTFF()

Scene001b=Video2.Trim(0, 900)
Scene002b=Video2.Trim(901, 1046)
Scene003b=Video2.Trim(1047, 1257)
Scene004b=Video2.Trim(1258, 2352)
Scene005b=Video2.Trim(2353, 2927)
Scene006b=Video2.Trim(2928, 0)

Luma=UnalignedSplice(\
Scene001b,\
Scene002b,\
Scene003b,\
Scene004b,\
Scene005b,\
Scene006b)

#Return Scene001b
#Return Scene002b
#Return Scene003b
#Return Scene004b
#Return Scene005b
#Return Scene006b

lmask=clip.mt_binarize(threshold=58,upper=true).converttoYV12(interlaced=true).GaussianBlur(varY=2000.0).grayscale()
overlay(Luma,mask=lmask)


Return Luma

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

Sharc
24th July 2024, 21:55
@Sharc

I tried adding your code to my script but avisynth+ didn't recognize GaussianBlur().
It is the Avisynth plugin variableblur.dll which includes GaussianBlur.
You find it here
http://avisynth.nl/index.php/VariableBlur

Prinipally you can replace it by any very strong blurrer. Very strong because one does not want to have sharp transitions between filtered and unfiltered areas in a picture.