View Full Version : Source Filters Guidance Needed
mariner
6th November 2012, 12:45
Greetings.
I'm using the following script kindly provided by Didée to rectify repeated frame error in a progressive film BD. Tried three different source filters (DirectShowSource, FFvideoSource, DSS2) and each seems to have issues of its own.
1. X264 reports different number of frames encoded. Is this a known issue and which is the correct figure? On the sample provided,
DirectShowSource=136
DSS2=135
FFvideoSource=134
2. DSS2 would crash at the end of encoding the whole video.
3. DirectShowSource seems to cause certain frames to be encoded out of sequence (see cut_ds.m2ts).
Would appreciate any guidance on the correct source filter to use.
System : W7x86
Software: Avisynth 2.58, ffms2-r725-icl-4, latest Haali and FFdshow.
# LoadPlugin("MVTools2.dll")
dgsource("mastiff.dgi")
o = last
o4 = o.pointresize(width+16,height+16,-4,-4,width+16,height+16)
o8 = o.pointresize(width+16,height+16,-8,-8,width+16,height+16)
o12 = o.pointresize(width+16,height+16,-12,-12,width+16,height+16)
d2p = mt_lutxy(o,o.selectevery(1,-1),"x y - abs 128 *").greyscale()
dup = mt_lutf(d2p,d2p,mode="avg",yexpr="x").mt_lut("x 2 < 255 0 ?")
skip = dup.selectevery(1,-1)
sup = o.msuper(pel=1)
bv = sup.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
fv = sup.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
inter = o.mblockfps(sup,bv,fv,num=0,mode=3).selectodd()
sup4 = o4.msuper(pel=1)
bv4 = sup4.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
fv4 = sup4.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
inter4 = o4.mblockfps(sup4,bv4,fv4,num=0,mode=3).selectodd().crop(4,4,-12,-12,true)
sup8 = o8.msuper(pel=1)
bv8 = sup8.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
fv8 = sup8.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
inter8 = o8.mblockfps(sup8,bv8,fv8,num=0,mode=3).selectodd().crop(8,8,-8,-8,true)
sup12 = o12.msuper(pel=1)
bv12 = sup12.manalyse(isb=true, blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
fv12 = sup12.manalyse(isb=false,blksize=16,overlap=0,search=5,searchparam=6,DCT=5)
inter12 = o12.mblockfps(sup12,bv12,fv12,num=0,mode=3).selectodd().crop(12,12,-4,-4,true)
inter = merge(merge(inter12,inter8),merge(inter4,inter))
conditionalfilter(dup,o,o.selectevery(1,1),"averageluma","<","2")
conditionalfilter(skip,last,inter,"averageluma","<","2")
return(last)
cut.m2ts (http://www2.zshare.ma/fbbp7noio4sf)
cut_ds.m2ts (http://www2.zshare.ma/lpqyegx72oc8)
fvisagie
6th November 2012, 13:36
Although I haven't come across a decent explanation yet, it seems those in the know regard DirectShowSource as frame-inaccurate. I certainly have struggled with it in that regard at times. DSS2 I have no experience of. For frame-accurate work like timing subtitles I normally use FFVideoSource from FFMPEGSource 2: http://code.google.com/p/ffmpegsource/downloads/list.
For what it's worth, how many frames does something like MediaInfo report compared to the others?
Mounir
6th November 2012, 15:55
for x264/hd streams i use DGindexNv which is not free; for avi -> avisource ,mpeg1/2 -> mpegsource and everything else (flv, wmv etc....) directshowsource
IanB
6th November 2012, 21:41
It is not DirectShowSource or DSS2 themselves that are frame-inaccurate it is some Direct Show components. If all the components in the graph are frame accurate then there is no problem. Because DirectShow is a media player API some components may take short cuts that are acceptable in a media player but are not sufficient for exact frame serving. e.g. just jumping to the nearest key frame when seeking, for a media player this is great because when you drag the seek slider some approximately nearby media starts to play immediately. For a frame server this is really bad. DSS2 has some extra preroll logic that can mitigate some inaccurate components.
Sources like Mpeg2Source and FFVideoSource maintain indexes to achieve frame accuracy. AviSource uses the old VFW interface which is intrinsically frame accurate.
mariner
9th November 2012, 10:12
Although I haven't come across a decent explanation yet, it seems those in the know regard DirectShowSource as frame-inaccurate. I certainly have struggled with it in that regard at times. DSS2 I have no experience of. For frame-accurate work like timing subtitles I normally use FFVideoSource from FFMPEGSource 2: http://code.google.com/p/ffmpegsource/downloads/list.
For what it's worth, how many frames does something like MediaInfo report compared to the others?
Thanks for the kind reply, fvisagie.
1. My MediaInfo does not show frame count. How do you get it to do so? Or any other suggestions?
2. Can you kindly do a quick test with cut.m2ts using FFVideoSource and see what is the frame count reported?.
Thanks and best regards.
mariner
9th November 2012, 10:15
for x264/hd streams i use DGindexNv which is not free; for avi -> avisource ,mpeg1/2 -> mpegsource and everything else (flv, wmv etc....) directshowsource
Thanks for the kind reply, Mounir.
I can't use DGindexNv due to hardware incompatibility. Can you kindly do a quick test with cut.m2ts to check the frame count reported?
Many thanks and best regards.
mariner
9th November 2012, 10:49
It is not DirectShowSource or DSS2 themselves that are frame-inaccurate it is some Direct Show components. If all the components in the graph are frame accurate then there is no problem. Because DirectShow is a media player API some components may take short cuts that are acceptable in a media player but are not sufficient for exact frame serving. e.g. just jumping to the nearest key frame when seeking, for a media player this is great because when you drag the seek slider some approximately nearby media starts to play immediately. For a frame server this is really bad. DSS2 has some extra preroll logic that can mitigate some inaccurate components.
Sources like Mpeg2Source and FFVideoSource maintain indexes to achieve frame accuracy. AviSource uses the old VFW interface which is intrinsically frame accurate.
Thanks for the kind reply, IanB.
1. Which DS components do you have in mind that's responsible for frame inaccuracy?
2. Haali splitter is called by both DirectShowSource and DSS2, yet x264 reports different number of frames encoded. DirectShowSource uses FFdshow video decoder, not sure about DSS2. Which of these could be the culprit? Or is it a x264 problem?
3. How does one use a graph to pick specific filter components (source filter and decoder) for a script? Would filters from Gabest's MPC or commercial playback software such as PDVD of TMT offer frame accurate result?
4. Can you explain what may have caused Didée's script to misbehave (out of sequence frame) when used together with
DirectShowSource?
5. Do Mpeg2Source and AviSource work with h264 m2ts? What are the alternatives?
6. I've read FFVideoSource has problem with interlaced material. What alternatives would you recommend?
Many thanks and best regards.
IanB
9th November 2012, 23:04
1. Which DS components do you have in mind that's responsible for frame inaccuracy?Some early rev asf splitters with various codecs and a commercial mpeg2 decoder spring from memory, but there are probably many more. Trying to step backwards is a good test. Dodgy implementations return the same frame multiple times and/or skip a number of frames on each back step.
2. Haali splitter is called by both DirectShowSource and DSS2, yet x264 reports different number of frames encoded. DirectShowSource uses FFdshow video decoder, not sure about DSS2. Which of these could be the culprit? Or is it a x264 problem?Unlikely to be x264. Load your script in VirtualDub to see what is actually coming out of the script. DirectShowSource and DSS2 use subtly different methods for trying to determine the length of the stream. VFR content does cause issues, DSS2 always uses convertfps=true logic, DirectShowSource has "convertfps" as an option, default is false. DirectShowSource also has a "framecount" option to override recalcitrant cases.
3. How does one use a graph to pick specific filter components (source filter and decoder) for a script? Would filters from Gabest's MPC or commercial playback software such as PDVD of TMT offer frame accurate result?
Use GraphEdit or GraphStudio to build a custom Direct Show Graph and save as a .GRF file, load that into DirectShowSource.
4. Can you explain what may have caused Didée's script to misbehave (out of sequence frame) when used together with DirectShowSource?Some of the fancier scripts process frames through a number of different paths comparing the processing results to pick and merge the best result. If the process does not get the exact same frame N for each path then the results are a meaningless jumble. The DirectShowSource "seek" option can help mitigate some issues.
5. Do Mpeg2Source and AviSource work with h264 m2ts? What are the alternatives?Mpeg2Source is for mpeg2 streams. AVISource is for .avi containers. Neuron2's DGSource package is very good but is not free and needs a compatible video card. FFVideoSource .....
6. I've read FFVideoSource has problem with interlaced material. What alternatives would you recommend?Use threads=1 and keep a collection of builds old and new, the FFMpeg people keep trying new things for interlaced h264 some work well for some streams, others work well with other streams. Do take the time to submit troublesome streams to the developers.
fvisagie
11th November 2012, 17:30
It is not DirectShowSource or DSS2 themselves that are frame-inaccurate it is some Direct Show components. ...
Thanks for the thorough explanation, Ian, much appreciated.
1. My MediaInfo does not show frame count. How do you get it to do so? Or any other suggestions?
I never realised either that it doesn't display frame count (by default)! Go Debug > Advanced mode. Details - 0 is sufficient.
2. Can you kindly do a quick test with cut.m2ts using FFVideoSource and see what is the frame count reported?
In this case MediaInfo reports:
General
...
Duration : 00:00:05.663
Video
...
Duration : 00:00:05.588
...
Frame rate : 23.976 fps
Frame count : 134
AvsP with FFVideoSource reports 136 frames.
Looking at the numbers and doing some sums,
5.588*23.976 ~ 134
5.6763*23.976 ~ 136,
it seems possible that in some cases the different frame counts could be explained by the differences in General (container?) and Video durations.
mariner
17th November 2012, 08:00
Greetings IanB and fvisagie. Thanks for the kind reply.
I did some simple encoding tests leaving out Didée's script,
stripping out the audio and subtitle in the source,
and output directly to MP4. Here are the results:
DSS2 135 frames, hangs at frame 82.
FFV 134 frames 5588ms.
DS 136 frames 5672ms.
MediaInfo report of source vcut.m2ts:
General
Count : 280
Duration : 5630.622222
Video
Count : 256
Duration : 5672
Frame count : 136
x264 report: DSS2
F:\1\dog2cut>x264 --bitrate 10000 -o vcut.mp4 vcut.avs
avs [info]: 1920x1080p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cach
e64
x264 [info]: profile High, level 4.0
[60.7%] 82/135 frames, 8.28 fps, 10290.05 kb/s, eta 0:00:06
x264 report: FFV
F:\1\dog2cut>x264 --bitrate 10000 -o vcut.mp4 vcut.avs
avs [info]: 1920x1080p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cach
e64
x264 [info]: profile High, level 4.0
x264 [info]: frame I:2 Avg QP:11.85 size:405017
x264 [info]: frame P:43 Avg QP:15.09 size:104789
x264 [info]: frame B:89 Avg QP:19.03 size: 12707
x264 [info]: consecutive B-frames: 7.5% 11.9% 0.0% 80.6%
x264 [info]: mb I I16..4: 22.5% 45.9% 31.5%
x264 [info]: mb P I16..4: 5.3% 6.6% 2.8% P16..4: 37.9% 20.2% 19.1% 0.0% 0
.0% skip: 8.2%
x264 [info]: mb B I16..4: 1.0% 1.2% 0.4% B16..8: 36.8% 2.9% 0.7% direct:
3.4% skip:53.6% L0:54.3% L1:41.0% BI: 4.6%
x264 [info]: final ratefactor: 14.57
x264 [info]: 8x8 transform intra:45.3% inter:59.5%
x264 [info]: coded y,uvDC,uvAC intra: 77.9% 70.0% 48.5% inter: 24.2% 32.2% 11.7%
x264 [info]: i16 v,h,dc,p: 8% 24% 37% 31%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 28% 31% 3% 5% 4% 8% 4% 8%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 27% 27% 3% 6% 4% 6% 3% 4%
x264 [info]: i8c dc,h,v,p: 45% 35% 12% 9%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: ref P L0: 47.8% 5.4% 34.4% 12.4%
x264 [info]: ref B L0: 75.5% 21.2% 3.3%
x264 [info]: ref B L1: 94.1% 5.9%
x264 [info]: kb/s:9228.13
encoded 134 frames, 9.47 fps, 9229.18 kb/s
x264 report: DS
F:\1\dog2cut>x264 --bitrate 10000 -o vcut.mp4 vcut.avs
avs [info]: 1920x1080p 0:0 @ 24000/1001 fps (cfr)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cach
e64
x264 [info]: profile High, level 4.0
x264 [info]: frame I:2 Avg QP:11.85 size:405017
x264 [info]: frame P:43 Avg QP:15.02 size:107165
x264 [info]: frame B:91 Avg QP:19.07 size: 12391
x264 [info]: consecutive B-frames: 6.6% 11.8% 2.2% 79.4%
x264 [info]: mb I I16..4: 22.5% 45.9% 31.5%
x264 [info]: mb P I16..4: 5.3% 6.6% 2.9% P16..4: 37.0% 20.2% 19.2% 0.0% 0
.0% skip: 9.0%
x264 [info]: mb B I16..4: 1.0% 1.2% 0.4% B16..8: 36.3% 2.8% 0.7% direct:
3.2% skip:54.4% L0:54.3% L1:41.0% BI: 4.7%
x264 [info]: final ratefactor: 14.61
x264 [info]: 8x8 transform intra:45.2% inter:59.0%
x264 [info]: coded y,uvDC,uvAC intra: 78.1% 70.3% 48.9% inter: 24.0% 31.7% 11.8%
x264 [info]: i16 v,h,dc,p: 8% 24% 37% 31%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 28% 31% 3% 5% 4% 8% 4% 8%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 27% 27% 4% 6% 4% 6% 3% 4%
x264 [info]: i8c dc,h,v,p: 45% 35% 12% 9%
x264 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x264 [info]: ref P L0: 47.7% 5.5% 34.5% 12.3%
x264 [info]: ref B L0: 75.6% 21.1% 3.2%
x264 [info]: ref B L1: 94.3% 5.7%
x264 [info]: kb/s:9231.82
encoded 136 frames, 10.02 fps, 9232.86 kb/s
Appreciate if you can kindly explain the results.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.