#1  
10-17-2018, 06:07 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Hi there.
Im having a problem getting avisynth with mpeg2source to work with ffmpeg.
When i output the script to virtualdub it works fine, but encoding with ffmpeg just gives a green picture.
Output to ffmpeg works with every other avs script Ive tested.
When I use ffmpegsource2 the sync isnt correct.
It is a bff mpeg2 source.
This is the script that works fine with virtualdub but not ffmpeg for whatever reason.

Code:
SetFilterMTMode("DEFAULT_MT_MODE", 2)               
SetFilterMTMode("FFVideoSource", 3)                
video=mpeg2source(".d2v")                 
audio=WAVSource(".wav")     
audiodub(video,audio)                     
QTGMC(Preset="slow")                               
Crop(2, 2, -2, -2)                                
AddBorders(2, 2, 2, 2)                            
Prefetch(8)
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
10-17-2018, 06:27 AM
lordsmurf's Avatar
lordsmurf lordsmurf is online now
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,508
Thanked 2,449 Times in 2,081 Posts
I advise against use mpeg2source(), and suggest only ffvideosource() at best.

But I usually prefer to let VirtualDub or VirtualDub2/FM extract it out to a lossless intermediary, usually Lagarith on x64 systems, and then process from it. An added bonus is that Avisynth works faster with a lossless AVI. And yes, then entire extract+Avisynth is still often faster than Avisynth chewing on the MPEG.

I've also started to shy away from MT mode on the non+ (and x64) builds, and I've seen too many frame glitches. If I do use it, I really have to watch it. (Not just scrub the video, but literally view it realtime.)

That all said, a green picture is almost always a codec problem.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #3  
10-17-2018, 07:53 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
When I use ffvideosource or ffmpegsource2 I get sync issues with mpeg2.
I tried a bunch of settings, same issues.
Read a lot of places its best to use mpeg2source, because ffvideosource has sync issues as I also experienced.

Doing Vdub extract is too time/space consuming.

I tried using avisynth+ 64bit and 32bit, and now also with ffmpeg 32bit, with 32bit ffmpeg i can encode both 64bit and 32bit successfully with mpeg2source, but with ffmpeg 64bit I get the green picture with both 32bit and 64bit avisynth.
Its only applicable to mpeg2source, avisource has been working perfectly with ffmpeg 64bit.
I also tried different version of ffmpeg, static zeranoe had same issue.

Another issue, encoding time. Now its encoding 1x-1,5x max.

ffmpeg:
Code:
 -c:v libx264 -preset slower -crf 17 -aspect 4:3 -c:a libfdk_aac -b:a 384k -ar 48k -afterburner 1
avisynth:
Code:
SetFilterMTMode("DEFAULT_MT_MODE", 2) 
SetFilterMTMode("FFVideoSource", 3)   
avisource("E:\Eva Nyeborg\TEST\2\02 - Høst 00'20001202 09.12.25.avi")              
QTGMC(Preset="slow")                  
Crop(2, 2, -2, -2)                    
AddBorders(2, 2, 2, 2)                
Prefetch(8)
Any suggestions to speed it up without quality loss?
Sources are mostly SD material from DV.
Im using Threadripper 1950X
Reply With Quote
  #4  
10-17-2018, 08:16 AM
lordsmurf's Avatar
lordsmurf lordsmurf is online now
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,508
Thanked 2,449 Times in 2,081 Posts
Please use [code][/code] tags around Avisynth and ffmpeg scripts. Or any scripts.
The # in the reply box is also the code editor.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #5  
10-17-2018, 08:59 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Ok, will do.
Reply With Quote
  #6  
10-17-2018, 09:08 AM
sanlyn sanlyn is offline
Premium Member
 
Join Date: Aug 2009
Location: N. Carolina and NY, USA
Posts: 3,648
Thanked 1,307 Times in 982 Posts
Quote:
Originally Posted by lordsmurf View Post
I advise against use mpeg2source(), and suggest only ffvideosource() at best.
I disagree. Mpeg2Source and d2v are still considered the most frame-accurate avenue for decoding MPEG2/MPEG1/VOB/m2v videos. ffvideosource would be used for MPEG2 incorrectly enveloped in mkv, mp4, or other non-preferred containers for MPEG encodes.
Reply With Quote
  #7  
10-17-2018, 10:45 AM
hodgey hodgey is offline
Free Member
 
Join Date: Dec 2017
Location: Norway
Posts: 1,680
Thanked 447 Times in 384 Posts
Haven't experienced any issues like this when using 64-bit ffmpeg, though there should be hardly any difference between 32 and 64-bit speed-wise in any case. The performance critical parts of the code are mostly hand-optimized stuff where it selects different implementations based on the capabilities of the CPU. What color space are you getting on the avisynth output (avspmod can be used to check)? It's possible that the different source plugins outputs in different color spaces, and that's one area where ffmpeg could get confused.

Quote:
Originally Posted by knumag View Post
Any suggestions to speed it up without quality loss?
Sources are mostly SD material from DV.
Im using Threadripper 1950X
If it's purely deinterlacing and blackening borders you are doing you could try to use vapoursynth rather than avisynth. The vapoursynth version of QTGMC can take advantage of OpenCL, and is better at multithreading so it may work faster. I'll post the script I use for DV material later. The downside is that you have to mux the audio in manually with ffmpeg as vapoursynth doesn't handle audio yet. (Hence why it's impractical when trimming etc.)

There is a package containing vapoursynth + needed plugins here:
https://forum.doom9.org/showthread.php?t=175529

Also note that the DV format is full-range YUV, as opposed to like every other video format where 16-235 are the values meant for display, so you may want to adjust the video levels accordingly, or you may get blown out darks and whites. In my experience material from miniDV tapes tend to use the full range up to y=255, but often only go down to somewhere between 12-16, so it might be worth looking at a histogram. No idea about the stuff the canopus boxes produce.
Reply With Quote
The following users thank hodgey for this useful post: knumag (10-27-2018)
  #8  
10-17-2018, 08:56 PM
lordsmurf's Avatar
lordsmurf lordsmurf is online now
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,508
Thanked 2,449 Times in 2,081 Posts
Quote:
Originally Posted by sanlyn View Post
I disagree. Mpeg2Source and d2v are still considered the most frame-accurate avenue for decoding MPEG2/MPEG1/VOB/m2v videos. ffvideosource would be used for MPEG2 incorrectly enveloped in mkv, mp4, or other non-preferred containers for MPEG encodes.
For some reason, I've just always had bad luck with D2V, yet ffvideosource rarely let me down. I really have no preference, aside from a preference to use what works for decide. That's the main reason I don't even like letting Avisynth open non-lossless files.

Sync errors are no fun, having one myself on a hobby project, hoping to finish by end of year.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #9  
10-23-2018, 07:17 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Hi. A small update.

I'm still having problems getting avisynth+ 64bit to work correctly.
I've tried the other version as well, but they are much slower and the regular MT-version just quits randomly. ST is max 0.3X, and if I start a bunch of them, I can get it to a total of 2X, but after some time and after most of them finishes, the speed drops to 0.1X. So that´s not really an option as I see it.

I used the universal installer at doom9.org to test the different versions.
And the 64bit avs+ is what seems fastest, and never once has it quit or stopped working.

I have mtmodes.avsi in the plugins folder. http://publishwith.me/ep/pad/view/ro.rDkwcdWn4k9/latest
That's the correct way to do it, right? Just copy the text and save it as mtmodes.avsi in the plugins folder?
I have all the latest Core Plugins and scripts for 64bit for qtgmc http://avisynth.nl/index.php/QTGMC
NNEDI3, I copied the W7_AVX2 plugin. Guess that's correct?

I have two ffmpeg encodings going simultaneously as I can't get full speed on one single encoding.
Sometimes I have a total of 1X, sometimes 0.7X, and sometimes 2x but always 100% cpu, with the same scripts, even at slow speed around 0.5X, it still shows 100% cpu, nothing else is running.

This is the script I´m using to test.

Code:
SetFilterMTMode("DEFAULT_MT_MODE", 2)         
SetFilterMTMode("avisource", 3)           
avisource("**.avi")                      
QTGMC(Preset="slow", EdiThreads=2)                  
Crop(2, 2, -2, -2)                            
AddBorders(2, 2, 2, 2)                        
Prefetch(12)
I've tried different values for prefetch and edithreads.
This is what seems fastest on my PC. Settings edithreads=1 makes it slower, but not much difference above 2.
I guess you're not supposed to use edithreads with avs+? Any experience with this?
On the qtgmc site it says only the regular MT version is supported, but that just stopped randomly all the time. Maybe 32bit memory problem? Tried different setmemorymax values, but same problem with the 32bit MT version.

I'm thinking its the amount of logical cores that's the main problem here. Threadripper has 32.
I've tried higher values for prefetch, but still not faster, and it then eats up all of the cpu at low speeds.

Any suggestions would be greatly appreciated.
Reply With Quote
  #10  
10-23-2018, 10:39 AM
lordsmurf's Avatar
lordsmurf lordsmurf is online now
Site Staff | Video
 
Join Date: Dec 2002
Posts: 13,508
Thanked 2,449 Times in 2,081 Posts
I use this for simple QTGMC in Avisynth+ x64

Code:
SetFilterMTMode("DEFAULT_MT_MODE", 1)
AVISource("c:\file.avi")
ConvertToYV16(interlaced=true)
QTGMC(Preset="faster") 
Prefetch(6)
Slow blurs too much.
But I'll tweak the QTGMC based n the source quality/needs.

- Did my advice help you? Then become a Premium Member and support this site.
- For sale in the marketplace: TBCs, workflows, capture cards, VCRs
Reply With Quote
  #11  
10-23-2018, 10:43 AM
hodgey hodgey is offline
Free Member
 
Join Date: Dec 2017
Location: Norway
Posts: 1,680
Thanked 447 Times in 384 Posts
Quote:
Originally Posted by knumag View Post
I have mtmodes.avsi in the plugins folder. http://publishwith.me/ep/pad/view/ro.rDkwcdWn4k9/latest
That's the correct way to do it, right? Just copy the text and save it as mtmodes.avsi in the plugins folder?
I have all the latest Core Plugins and scripts for 64bit for qtgmc http://avisynth.nl/index.php/QTGMC
NNEDI3, I copied the W7_AVX2 plugin. Guess that's correct?
I believe that's correct yes. The mtmodes script just needs to be autoloaded, which it should be if it's in the plugin folder, to work.

There is going to be a limit to how many threads the plugins can use effectively, so you may simply have hit that limit with avs64+. You could try if vapoursynth is faster. Did you figure out the green frames issue?

Last edited by hodgey; 10-23-2018 at 10:45 AM. Reason: bbcode
Reply With Quote
The following users thank hodgey for this useful post: knumag (10-27-2018)
  #12  
10-23-2018, 11:16 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Quote:
Originally Posted by hodgey View Post
There is going to be a limit to how many threads the plugins can use effectively, so you may simply have hit that limit with avs64+. You could try if vapoursynth is faster.
Ive never tried Vapoursynth, and also new to Avisynth. The thought about muxing the audio in after encode sounds like a hazzle. What about sync issues?
Do you mux it in while encoding, or afterwards?

Quote:
Originally Posted by hodgey View Post
Did you figure out the green frames issue?
I switched to LSMASHSource for mpeg2, seems like it works correctly.
Reply With Quote
  #13  
10-23-2018, 12:38 PM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Finally!
Added this to the beginning of every script:
Code:
AddAutoloadDir("PATH\AvisynthRepository\AVSPLUS_x64\plugins")
Now seeing 2X speed at 75% cpu usage. Guess the mtmodes.avsi doesnt get autoloaded without it.
Reply With Quote
  #14  
10-27-2018, 08:54 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Quote:
Originally Posted by hodgey View Post
If it's purely deinterlacing and blackening borders you are doing you could try to use vapoursynth rather than avisynth. The vapoursynth version of QTGMC can take advantage of OpenCL, and is better at multithreading so it may work faster. I'll post the script I use for DV material later. The downside is that you have to mux the audio in manually with ffmpeg as vapoursynth doesn't handle audio yet. (Hence why it's impractical when trimming etc.)
Thank you very much for the advice!
VapourSynth is just great, hard to get into it in the beginning, and not that much information for newbies, but understood it in the end and got it working.
Avisynth+ 64bit was working ok enough, but when it came to 1080i MPEG2TS it maxed out around 0.3X, 0.4X with 100% cpu usage.
VapourSynth is working steadily at 0.8X with same settings on QTGMC at 75-80% cpu usage.
Over all it feels much more stable.
Had these strange spikes with Avisynth and Windows was working really slowly in times when encoding was going on in the background, even with affinity and priority set.
Have not had this problem with VapourSynth.

With mpeg2 sources i found that only PS works without sync issues, after a stream fix with some bad sources. And also ffms2 with VapourSynth drops some of the first frames in MPEG2 streams and D2Vsource was buggy. L-SMASH Source works perfectly. Maybe its different with DVD, havent tested that yet with VapourSynth.

Have any advice about the levels you mentioned with DV sources?
I tried TV>PC with coloryuv, but not correct output in my eyes.
Reply With Quote
  #15  
10-27-2018, 09:55 AM
hodgey hodgey is offline
Free Member
 
Join Date: Dec 2017
Location: Norway
Posts: 1,680
Thanked 447 Times in 384 Posts
I use something like this, adjusting levels with the Levels function:
Code:
import vapoursynth as vs
import havsfunc as haf

core = vs.get_core()
clip = core.ffms2.Source(source=input_file)
#Adjust levels - Luma
#miniDV cams tend to go to y=255, but not go fully to Y=0, so adjust min_in as needed.
clip = core.std.Levels(clip, min_in=8, max_in=255, min_out=16, 
max_out=235, planes=0)
#Adjust levels - Chroma
clip = core.std.Levels(clip, min_in=0, max_in=255, min_out=16, 
max_out=240, planes=[1,2])
# Enable and adjust as needed, DV sources seems to vary on whether and where there are flickering borders.
#clip = core.std.Crop(clip,bottom=4)
#clip = core.std.AddBorders(clip,top=2,bottom=2)
#Enabling OpenCL can help or not depending on the computer.
#DV is Bottom field first, so set TFF to false.
clip = haf.QTGMC(clip, Preset='Medium', TFF=False,opencl=True)
clip.set_output()
TV>PC would be the reverse of what you would want for DV. PC refers to full-range (0-255), TV to 16-235 (16-240 for chroma).
Reply With Quote
The following users thank hodgey for this useful post: knumag (10-27-2018)
  #16  
10-27-2018, 10:06 AM
knumag knumag is offline
Free Member
 
Join Date: Feb 2014
Posts: 72
Thanked 1 Time in 1 Post
Thank you!

Code:
core = vs.get_core(threads=4)
You dont specify threads? If I dont, I get around 10% of the speed when I do specify, at same cpu usage or more.
Usually use around 2-6 threads, and leave rest for encoder.

Code:
SET ffmpeg=start "ffmpeg" /low /b /w /AFFINITY 0000FFF0 ffmpeg
SET vspipe=start "vspipe" /low /b /w /AFFINITY 000000FF "C:\Program Files (x86)\VapourSynth\core64\vspipe.exe"
Code:
SET ffmpeg=start "ffmpeg" /low /b /w /AFFINITY 0FFF0000 ffmpeg
SET vspipe=start "vspipe" /low /b /w /AFFINITY FF000000 "C:\Program Files (x86)\VapourSynth\core64\vspipe.exe"
And also specify affinity like this for 32 threads.

Quote:
TV>PC would be the reverse of what you would want for DV. PC refers to full-range (0-255), TV to 16-235 (16-240 for chroma).
Just tested it quickly on a 30 sec segment. That was the logical choice for me. From TV source to PC. But of course it`s the reverse of what I want.
Reply With Quote
  #17  
10-27-2018, 10:23 AM
hodgey hodgey is offline
Free Member
 
Join Date: Dec 2017
Location: Norway
Posts: 1,680
Thanked 447 Times in 384 Posts
Wasn't actually aware about specifying number of threads, it's supposed to autodetect the number of cores. Didn't notice a difference on a 4-core i5, but I suppose it may make more of a difference on a threadripper with loads of cores.

The reference suggests getting the core instance like this now though, get_core is apparently deprecated:
Code:
core = vs.core
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
FFMPEG, AviSynth, VirtualDub - Which tool for which purpose? naripeddi Restore, Filter, Improve Quality 2 07-05-2018 02:18 AM
QTGMC repeating frames on MP4 in Avisynth? Master Tape Restore, Filter, Improve Quality 8 06-30-2018 02:40 AM
S-video capture on Linux via ATI USB card, FFmpeg - recommendations? wronkyn Capture, Record, Transfer 1 11-30-2014 01:45 PM
Problem converting to Huffyuv codec using ffmpeg metaleonid Encode, Convert for discs 3 11-19-2012 07:28 AM
Compression with MMC ATI, P frames and B frames for MPEG-2 ? John Capture, Record, Transfer 1 08-20-2011 10:15 PM

Thread Tools



 
All times are GMT -5. The time now is 05:30 AM