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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th August 2020, 21:38   #61  |  Link
clsid
*****
 
Join Date: Feb 2005
Posts: 5,647
MPC-HC/LAV has a workaround to disable use of P010/P016 when it is (potentially) unsupported. It only allows P010 on recent versions of Windows 10.
clsid is offline   Reply With Quote
Old 18th August 2020, 22:09   #62  |  Link
chainik_svp
Registered User
 
Join Date: Mar 2012
Location: Saint-Petersburg
Posts: 239
> Variable frame rate video: I don't have any experience about this.

You'll have different frame durations for different frames
So your method of getting frame time from frame number, based on a fixed frame duration, will fail - it'll return wrong frames.
You need to count input frames, and return the exact frame (by number) when it's requested.

> Do you have any sample video?

Basically any anime video out there is VFR in some parts.

> How does ffdshow behave? Does it treat like dynamic format change?

It's not a format change. Since ffdshow works with frame numbers it doesn't have any problems here.

> When I put SVSmoothFps_NVOF() in script, and NOT recreate the avs environment every time I connect pin or seek, the filter just freezes.

I'll take a look...
__________________
SVPflow motion interpolation
chainik_svp is offline   Reply With Quote
Old 19th August 2020, 14:18   #63  |  Link
chainik_svp
Registered User
 
Join Date: Mar 2012
Location: Saint-Petersburg
Posts: 239
I wonder if it's really necessary to reload script so many times?
Considering the simple YV12 playback, it's reloaded:
- 4 times in CheckConnect
- 1 time in HandleInputFormatChange
- 1 time in TransformAndDeliver

total of six (6) times just to start the playback, plus one time for every set on pause (why??).

And each time SVSmoothFps have to init and destroy OpenCL context, queues, build shader programs etc., plus init/destoy CUDA context for NVOF.

I'd at least remove Reset() from pause handler... 5 times re-init is better than 6

===

The "NVOF problem" - my guess is it arises from the fact that when reloading script w/o deleting the environment, the "new" filters initialization might occur before destruction of "old" filters.
__________________
SVPflow motion interpolation

Last edited by chainik_svp; 19th August 2020 at 14:39.
chainik_svp is offline   Reply With Quote
Old 19th August 2020, 21:17   #64  |  Link
chainik_svp
Registered User
 
Join Date: Mar 2012
Location: Saint-Petersburg
Posts: 239
Regarding VFR. Just played with an anime file where frame rate is constantly floating between 24 and 30 fps, and found that IMediaSample::GetTime() is returning incorrect end-time - it's always equal to start-time plus average-time-per-frame defined in VIDEOINFOHEADER. However subtracting previous frame's start-time from the current frame's start-time gives correct value.
__________________
SVPflow motion interpolation
chainik_svp is offline   Reply With Quote
Old 20th August 2020, 06:38   #65  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
clsid: Thanks for info. However I tested in the latest Windows 10 (ver 2004) though. My MPC-HC version is 1.9.4.21 (daeb8bf8d).

VFR: "You need to count input frames, and return the exact frame (by number) when it's requested." But you are assuming the samples we receive are ordered and continuous. Upstream can give us frame #X then #X + 2 in case of frame drop. And if seek happens, all we know is the time of that frame. Why does avs take frame number instead of frame time? Does that mean avs only support CFR?

I also played a VFR video (where ffmpeg vfrdet reports "VFR:0.501632 (1076/1069) min: 3753 max: 15015 avg: 3777"). I don't see any problem during playback.

Reload: You can read my comment in filter.cpp. I hate reloading. It destroys performance. But I think every single one of them is necessary.

CheckConnect: Reason why reload is to feed the script new input format. Each time the upstream gives me a new media type. I need to run through the script to get the corresponding output format, then feed it to downstream. Good news is these reload only reload the script, not the whole avs environment (because there is no frame generated yet).

HandleInputFormatChange: Same reason as above. New input media type, thus reload. Bad news, since the playback is already started, there could be frames inside avs. To flush the cache, we need to reload the whole thing. Maybe one day we will get some answer from https://github.com/AviSynth/AviSynthPlus/issues/180.

TransformAndDeliver: This is for Pause(). As you may know, the DirectShow document specifically requires filters to "discard any samples that were created before the seek command". We could flush cached frames in our filter, but we can't control any caching in avs. Thus a full reload is done every time user seeks. You could argue that it is not strictly "necessary", but then you will encounter the same ghost frame problem as in ffdshow, that after seeking you still see a bunch of frames around the time before seeking. I'd rather the seek taking a bit of time than seeing wrong frames.

NVOF: You are correct full reload works. The first 5 reloads (being full or not) are not the concern because they are generally not user visible (usually one time per playback). However, if every time we completely reload the environment there is no problem. But doing full reload in Pause() will impose unbearable latency for seeking. So either AviSynth gives us proper flushing method, NVOF somehow can do without full reload, or use NVOF with ghost frame.

Last edited by CrendKing; 20th August 2020 at 07:30.
CrendKing is offline   Reply With Quote
Old 20th August 2020, 08:34   #66  |  Link
chainik_svp
Registered User
 
Join Date: Mar 2012
Location: Saint-Petersburg
Posts: 239
> Thus a full reload is done every time user seeks.

seek != pause

> I don't see any problem during playback.

and still you
1. fetch the wrong frames using fixed frameTime value while converting requested frame number to timestamp
2. pass a cfr sequence to downstream
__________________
SVPflow motion interpolation

Last edited by chainik_svp; 20th August 2020 at 08:47.
chainik_svp is offline   Reply With Quote
Old 20th August 2020, 11:03   #67  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
Quote:
Originally Posted by chainik_svp View Post
> Thus a full reload is done every time user seeks.

seek != pause
Fixed and pushed.

Quote:
Originally Posted by chainik_svp View Post
> I don't see any problem during playback.

and still you
1. fetch the wrong frames using fixed frameTime value while converting requested frame number to timestamp
2. pass a cfr sequence to downstream
I get what you are saying, but I don't understand how to reconcile between DS and AVS. From what I see, AVS only supports CFR, otherwise it would not use frame number to getFrame(). So feeding any VFR to AVS would only get out CFR. Am I wrong?
CrendKing is offline   Reply With Quote
Old 20th August 2020, 13:40   #68  |  Link
chainik_svp
Registered User
 
Join Date: Mar 2012
Location: Saint-Petersburg
Posts: 239
> So feeding any VFR to AVS would only get out CFR. Am I wrong?

you feed AVS with a frame sequence and you get another frame sequence back, it's up to you how to set timestamps
what I know is ffdshow somehow managed to deal with VFR input/output

https://github.com/jeeb/ffdshow-tryo...synth.cpp#L975
__________________
SVPflow motion interpolation

Last edited by chainik_svp; 20th August 2020 at 15:33.
chainik_svp is offline   Reply With Quote
Old 20th August 2020, 23:01   #69  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
I get it now. Basically we need to calculate the output frame duration ourselves, by applying the avs scaling (where the scaling itself is fixed at e.g. 2x, 1.5x, etc) to the source frame duration. And to get the frame number, we need to count from start or last seek point, instead of relying on the average frame duration, which is just a statistic number and rather meaningless. And for seeking, I don't need to care about anything before seeking. Just rebuild the frame queue from anew.

Last edited by CrendKing; 21st August 2020 at 00:18.
CrendKing is offline   Reply With Quote
Old 28th November 2020, 13:03   #70  |  Link
edcrfv94
Registered User
 
Join Date: Apr 2015
Posts: 84
VapourSynth multithreading stable than AviSynth, maybe supporting VapourSynth is a better idea.

Last edited by edcrfv94; 28th November 2020 at 13:59.
edcrfv94 is offline   Reply With Quote
Old 28th November 2020, 16:42   #71  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by edcrfv94 View Post
VapourSynth multithreading stable than AviSynth, maybe supporting VapourSynth is a better idea.
not anymore, I don't see any problem in multithreading stablety in AviSynth+ 3.6.2-test4 20201112
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 29th November 2020, 14:45   #72  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
Quote:
Originally Posted by edcrfv94 View Post
VapourSynth multithreading stable than AviSynth, maybe supporting VapourSynth is a better idea.
Do you mean AviSynth is not stable in general, or specifically in this filter's use case? If latter, can you open an issue in the repo so I can understand the problem.

Technically I could create a version of this filter that uses VapourSynth instead of AviSynth as the frame server (I have a working internal version but extremely buggy, not actively working on it), but since it pulls in Python in runtime thus way heavier in footprint, I need some good use case and incentive to do that work.
CrendKing is offline   Reply With Quote
Old 2nd December 2020, 04:27   #73  |  Link
edcrfv94
Registered User
 
Join Date: Apr 2015
Posts: 84
Quote:
Originally Posted by CrendKing View Post
Do you mean AviSynth is not stable in general, or specifically in this filter's use case? If latter, can you open an issue in the repo so I can understand the problem.

Technically I could create a version of this filter that uses VapourSynth instead of AviSynth as the frame server (I have a working internal version but extremely buggy, not actively working on it), but since it pulls in Python in runtime thus way heavier in footprint, I need some good use case and incentive to do that work.
My computer is currently unavailable.
Currently, VapourSynth HDB support and multithreading are much better than AviSynth+.
You can try some complex script with multithreading e.g: QTGMC + fslg_quick_denoise + mcDAA3.
edcrfv94 is offline   Reply With Quote
Old 2nd December 2020, 07:02   #74  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by edcrfv94 View Post
My computer is currently unavailable.
Currently, VapourSynth HDB support and multithreading are much better than AviSynth+.
You can try some complex script with multithreading e.g: QTGMC + fslg_quick_denoise + mcDAA3.
I do use complex scripts (using QTGMC, mcDAA3 and others) most of times and I can say that there are no problem these days in avs+ mt

HDB support maybe not as the vs one since there are few plugins need to add HBD in avs+, but again it's way better than 2019, since https://github.com/Asd-g?tab=repositories did added a lot since then
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 3rd December 2020, 19:49   #75  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
Also remember that since the use case here is real-time video playing, having complex script that requires significant CPU time would jeopardize your experience. For instance, playing a 60 fps video means you can't spend more than 16.6ms per frame on both decoding, avs and rendering, or you will start to drop frames. So essentially we only need to concern about a very subset of functionality. As long as this subset is stable, it's fine.
CrendKing is offline   Reply With Quote
Old 5th December 2020, 14:10   #76  |  Link
cork_OS
Registered User
 
cork_OS's Avatar
 
Join Date: Mar 2016
Posts: 160
Hello.
I've faced several problems with AVSF, not sure where to report it.
1. On the new PC manually installed AVSF didn't appear in the player's filters list (and don't work) until activate_remote_control.reg is applied. Is it a bug or a feature?

2. Player hangs on start if this script is loaded:
Quote:
AvsFilterSource()
TDecimate(mode=2, rate=23.976)
prefetch()
If TDecimate string is commented on player start and uncommented after playback starts, the video with script reloaded in real-time runs ok (audio sync not tested).

3. QTGMC and ApparentFPS work great individually, but not in one script.
This script plays choppy, but seeking works:
Quote:
AvsFilterSource()
QTGMC()
ApparentFPS()
prefetch()
This script plays smoothly, but player hangs on seek:
Quote:
AvsFilterSource()
QTGMC()
prefetch()
ApparentFPS()
AVS+ 3.6.1, AVSF 0.8.2. TDecimate problem tested on two PCs with different players/renderers (MPC-HC+madVR/MPC-BE+EVR-CP).
__________________
I'm infected with poor sources.
cork_OS is offline   Reply With Quote
Old 5th December 2020, 17:36   #77  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I cant remember what AvsFilterSource() is, but suggest RequestFramesLinear() [with appropriate cache args] inserted after AvsFilterSource.
Before and After cache args might best be at least the framerate of the source clip. [maybe]

EDIT: or maybe if still probs, try at least the framerate of the source clip * Prefetch.

EDIT: Note, ApparentFPS() has to access 2*FrameRate [by default] frames everytime you jump about, hence hang
especially due to QTGMC doing its stuff for each of those.

EDIT: ApparentFPS() wil need linear access, need set as such in your SetMTMode.avs thing. [MT_SERIALIZED]
so probably best placed AFTER Prefetch().
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 5th December 2020 at 19:00.
StainlessS is offline   Reply With Quote
Old 6th December 2020, 11:05   #78  |  Link
CrendKing
Registered User
 
Join Date: May 2019
Posts: 42
Quote:
Originally Posted by cork_OS View Post
Hello.
I've faced several problems with AVSF, not sure where to report it.
Please report to https://github.com/CrendKing/avisynt...ues/new/choose. There is bug report template to ask you information I need.

Quote:
Originally Posted by cork_OS View Post
1. On the new PC manually installed AVSF didn't appear in the player's filters list (and don't work) until activate_remote_control.reg is applied. Is it a bug or a feature?
There are other people report installation not working. Some were due to lack of Visual C++ runtime. activate_remote_control.reg should have nothing to do with it. If it's true, it's bug. Please report and we track there.

Quote:
Originally Posted by cork_OS View Post
2. Player hangs on start if this script is loaded:
I thought "Prefetch" has required thread number argument. Have you tried adding it?

I've tested FDecimate2 before, but never tested TDecimate. Please report on separate issue.

However, we should first solve the installation issue. I'm not even sure you are actually loaded the filter in its expected state.

Quote:
Originally Posted by cork_OS View Post
This script plays smoothly, but player hangs on seek:
I thought "prefetch" must be the last statement in a script. Am I wrong? Reference: http://avisynth.nl/index.php/AviSynth%2B:
Quote:
You enable MT by placing a single call to Prefetch(X) at the end of your script, where X is the number of threads to use.
Quote:
Originally Posted by StainlessS View Post
I cant remember what AvsFilterSource() is
It is the source function added by this filter: https://github.com/CrendKing/avisynt...vsfiltersource. It feeds source samples from upstream DirectShow filter to AviSynth engine.

Last edited by CrendKing; 6th December 2020 at 11:09.
CrendKing is offline   Reply With Quote
Old 6th December 2020, 17:04   #79  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
I thought "Prefetch" has required thread number argument. Have you tried adding it?
Quote:
Originally Posted by pinterf View Post
Prefetch has a default value, which is number of Physical CPUs + 1.
NOTE, I think 'Physical CPUs' is meaning 'Physical Cores'.
Eg, a machine might have 2 physical Xeon CPUs, each with 6 physical cores and 6 logical cores, 12 physical [EDIT: total] cores per CPU, or
24 threads/cores total machine.
Dont know if Physical_CPUs means physical_cores in single CPU, or eg total number of physical cores in multi CPU Xeon system.
Quote:
Originally Posted by StainlessS View Post
From Avisynth.cpp

Code:
size_t  __stdcall ScriptEnvironment::GetProperty(AvsEnvProperty prop)
{
  switch(prop)
  {
  case AEP_FILTERCHAIN_THREADS:
    return (prefetcher != NULL) ? prefetcher->NumPrefetchThreads()+1 : 1;
  case AEP_PHYSICAL_CPUS:
    return GetNumPhysicalCPUs();
  case AEP_LOGICAL_CPUS:
    return std::thread::hardware_concurrency();
  case AEP_THREAD_ID:
    return 0;
  case AEP_THREADPOOL_THREADS:
    return thread_pool->NumThreads();
  case AEP_VERSION:
    return AVS_SEQREV;
  default:
    this->ThrowError("Invalid property request.");
    return std::numeric_limits<size_t>::max();
  }

  assert(0);
}
Also see GetProperty in avisynth.h

EDIT: Not available for Avs Standard v2.60 (dont know about v2.61).
Quote:
I thought "prefetch" must be the last statement in a script.
Prefetch() is just an pretty standard filter which takes as its first argument a video clip,
it is more usually called with implicit Last clip, it also returns a video clip, and has never had to be final filter in script,
although that has been its usual use in the past.

I'm pretty sure that there was a Pinterf post [which I did not find] that showed multiple use of Prefetch in single script,
multi-use was quite recent mod to avs+. [EDIT: I only searched Devs forum, maybe was in Usage]

Quote by Pinterf, [cant directly quote a closed thread any more ???]:- https://forum.doom9.org/showthread.p...72#post1904672
Quote:
Prefetch (clip c, int threads, int "frames")

In the original Plus, you could use only one Prefetch, but you can use any number of CUDA versions.
Also, an argument has been added to specify the number of frames to prefetch.
Prefetch (1,4) # Make 1 thread stand and prefetch 4 frames
By doing so, flexible parallelization configuration is possible, such as pipeline parallelization.

threads
Number of threads. If it is 0, it passes without doing anything.

frames
Number of frames to prefetch.
Again, if it is 0, it passes without doing anything.
Note above clip c,
and threads default = physical cores + 1, frames default is presumably 1 [although defaults tend not to be shown]

EDIT: Threads is Optional, should be enclosed in double quotes.
Code:
Prefetch (clip c, int "threads"=Physical_cores+1, int "frames"=1)    # returning video clip
EDIT: I'm guessin that Physical_Cores might mean physical cores in a single CPU.

Quote:
It is the source function added by this filter
Thanks.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 6th December 2020 at 19:28.
StainlessS is offline   Reply With Quote
Old 6th December 2020, 18:00   #80  |  Link
clsid
*****
 
Join Date: Feb 2005
Posts: 5,647
Quote:
Originally Posted by CrendKing View Post
There are other people report installation not working. Some were due to lack of Visual C++ runtime.
I really recommend to use static linking. Pretty much every DirectShow filter uses static linking. Requiring runtimes is really annoying for distribution and also a support nightmare.
clsid is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.