View Full Version : Do I need AssumeFPS?
MysteryX
13th December 2014, 06:15
When I open a video script with MeGUI, it opens the file like this
DirectShowSource("Terry Tate - Office Linebacker.flv", fps=18.004, audio=false, convertfps=true).AssumeFPS(4501,250).ConvertToYV12()
My question is: What is AssumeFPS, and do I need it?
I'm writing a software that generates the script, but if this is needed, it seems quite complicated to calculate this ratio. So do I really need it, and if so, how can I calculate it?
feisty2
13th December 2014, 06:18
assumefps can change the playback speed of ur video
let's say the source clip is at 24fps
assumefps (12) would make it play at 12 fps which means 2x slow motion
MysteryX
13th December 2014, 06:24
So if I want to preserve the same speed I should just remove that parameter? Is there any particular reason why MeGUI is adding it?
StainlessS
13th December 2014, 09:34
It is probably adding the AssumeFPS just in case DirectShowSource gets it wrong (which it sometimes does). Try it without, see what you get.
Can add 'Info()' to end of script to show framerate etc.
DirectShowSource is not terribly good for loading flv (nor is anything else come to that),
The bat file below is what I usually use to convert pretty much any awkward clip to avi for easy AviSource loading;
setlocal
REM Where to Find ffmpeg
set FFMPEG="C:\BIN\ffmpeg.exe"
REM Where to get input file, No terminating Backslash, "." = current directory
set INDIR="."
REM Where to place output file, No terminating Backslash.
set OUTDIR="D:\AVS\AVI"
FOR %%A IN (*.wmv *.mpg *.avi *.flv *.mov *.mp4 *.m4v *.RAM *.RM *.mkv *.TS *.y4m *.yuv) DO (
%FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
REM %FFMPEG% -i "%INDIR%\%%A" -vcodec huffyuv -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
)
Pause
It uses ffmpeg (you can probably add other file extensions to script if not already there).
EDIT: And UT_Video Codec. Remove REM from huffyuv line and add REM before utvideo line if you want HuffYUV codec instead (YUY2)
MysteryX
13th December 2014, 10:00
I'm reading other files with Haali Splitter, but it fails to load FLV videos. Since I'm making that part of a software that automates the process, adding a batch file re-encoding process would complicate the whole thing so I would avoid going down that route.
What are the problems I can expect with DirectShowSource?
Most of the videos I would convert are videos downloaded from YouTube, and nowadays they seem to have replaced all their FLV videos with MP4 videos so any newly downloaded file would instead be in MP4 format so it really won't be much of an issue. But still it can happen that I need to process FLV.
StainlessS
13th December 2014, 10:06
Well for a start, DirectshowSource is not frame accurate.
EDIT: This is part of a work in-progress
Function GetFile(string vFN,string "aFN",Int "Prefer") {
myName="GetFile: "
START=RT_TimerHP
Assert(vFN!="",myName+"Empty VideofileName")
vFN = LCase(vFN)
aFN = LCase(Default(aFN,""))
Prefer=Default(Prefer,0) # Default 0=Avi if "AVI", 1, 1 = L-SMASH, 2 = FFMPegSource
Prefer = (Prefer<0 || Prefer>2) ? 0 : Prefer
SepAud = (aFN!="" && aFN!=vFN)
Ext=RT_GetFileExtension(vFN)
Function IsISOFileName(String s) {
s=Lcase(RT_GetFileExtension(s)) Return(s==".mov"||s==".mp4"||s==".3gp"||s==".3g2"||s==".mj2"||s==".dvb"||s==".dcf"||s==".m21")}
GScript("""
c = 0
FLGS = 0
RT_DebugF("\nOpening Video %s for Extension %s",vFN,Ext,name=myName)
try {
# Attempt open for some formats by extension, NOT AVISource as could be non seekable, Allow AVI Indexing via later Source Plugs.
if(Ext == ".d2v") {c = MPEG2Source(vFN) RT_DebugF("MPEG2Source Succeeds:",name=myName)}
Else if(Prefer==0 && Ext == ".avi") {
c = AviSource(vFN)
try {c=AviSource(vFN) RT_DebugF("AVISource Video Succeeds:",name=myName) }
catch (msg) {RT_DebugF("AVISource Video Fails:- '%s'",msg,name=myName) }
}
if(!c.IsClip) {
if(Prefer<=1) {
If(IsISOFileName(Ext)) {
FLGS=RT_BitSet(FLGS,0)
c = LSMASHVideoSource(vFN) RT_DebugF("LSMASHVideoSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,1) try{c=AudioDubEx(c,LSMASHAudioSource(vFN)) } catch(msg){} }
}
if(!c.IsClip) {
try {FLGS=RT_BitSet(FLGS,2) c=LWLibavVideoSource(vFN) RT_DebugF("LWLibavVideoSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,3) try{c=AudioDubEx(c,LWLibavAudioSource(vFN)) } catch(msg){} }
} catch (msg) {RT_DebugF("LWLibavVideoSource Video Fails:- '%s'",msg,name=myName) }
}
} Else {
try {FLGS=RT_BitSet(FLGS,4) FFIndex(vFN) c=FFVideoSource(vFN) RT_DebugF("FFMSSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,5) try{c=AudioDubEx(c,FFAudioSource(vFN)) } catch(msg){} }
} catch(msg) {RT_DebugF("FFMSSource Video Fails:- '%s'",msg,name=myName)}
}
}
} catch (msg) {c=0 RT_DebugF("Open Video by Extension Fails:- '%s'",msg,name=myName)}
if(!c.IsClip) {
if(!RT_BitTst(FLGS,4)) {
try {FLGS=RT_BitSet(FLGS,4) FFIndex(vFN) c=FFVideoSource(vFN) RT_DebugF("FFMSSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,5) try{c=AudioDubEx(c,FFAudioSource(vFN)) } catch(msg){} }
} catch(msg) {RT_DebugF("FFMSSource Video Fails:- '%s'",msg,name=myName)}
}
if(!c.IsClip) {
if(!RT_BitTst(FLGS,2)) {
try {FLGS=RT_BitSet(FLGS,2) c=LWLibavVideoSource(vFN) RT_DebugF("LWLibavVideoSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,3) try{c=AudioDubEx(c,LWLibavAudioSource(vFN)) } catch(msg){} }
} catch (msg) {RT_DebugF("LWLibavVideoSource Video Fails:- '%s'",msg,name=myName) }
}
if(!c.IsClip) {
if(!RT_BitTst(FLGS,0)) { # Not tried LSmash Video yet
FLGS=RT_BitSet(FLGS,0)
try {c = LSMASHVideoSource(vFN) RT_DebugF("LSMASHVideoSource Video Succeeds:",name=myName)
if(!SepAud) {FLGS=RT_BitSet(FLGS,1) try{c=AudioDubEx(c,LSMASHAudioSource(vFN)) } catch(msg){} }
} catch (msg) {RT_DebugF("LSMASHVideoSource Video Fails:- '%s'",msg,name=myName) }
}
if(!c.IsClip) {
try {c = DSS2(vFN) RT_DebugF("DSS2Source Video Succeeds:",name=myName) }
catch(msg) {RT_DebugF("DSS2Source Video Fails:- '%s'",msg,name=myName)
if(Ext==".avi") { # One last go before DirectShowSource
try {c=AviSource(vFN) RT_DebugF("AVISource Video Succeeds:",name=myName) }
catch (msg) {RT_DebugF("AVISource Video Fails:- '%s'",msg,name=myName) }
}
if(!c.IsClip) {
try {c=DirectShowSource(vFN,pixel_type="YV12") RT_DebugF("DirectShowSource(YV12) Video Succeeds:",name=myName) }
catch(msg) {RT_DebugF("DirectShowSource(YV12) Video Fails:- '%s'",msg,name=myName)
try {c=DirectShowSource(vFN,pixel_type="YUY2") RT_DebugF("DirectShowSource(YUY2) Video Succeeds:",name=myName) }
catch(msg) {RT_DebugF("DirectShowSource(YUY2) Video Fails:- '%s'",msg,name=myName)
try {c=DirectShowSource(vFN,pixel_type="RGB") RT_DebugF("DirectShowSource(RGB) Video Succeeds:",name=myName) }
catch(msg) {Assert(False,myName+"DirectShowSource(RGB) Video Fails: "+Chr(10)+msg)}
}
}
}
}
if(!c.HasAudio && !SepAud) {try{c=AudioDubEx(c,DirectShowSource(vFN,video=false) ) } catch(msg){} }
}
}
}
}
if((!c.HasAudio&&Ext!=".d2v") || SepAud){
RT_DebugF("Attempting Get Audio")
a = 0
aFN = (aFN=="") ? vFN : aFN
Ext=RT_GetFileExtension(aFN)
if(SepAud) {
RT_DebugF("Opening Audio %s for Extension %s",aFN,Ext,name=myName)
try {
if(Ext==".ac3") {a=NICAC3Source(aFN,channels=2,DRC=0) RT_DebugF("NICAC3Source Succeeds:",name=myName) }
Else if(Ext==".mpa"||Ext==".mp1"||Ext==".mp2"||Ext==".mp3") {
a=NicMPG123Source(aFN,Normalize=False) RT_DebugF("NicMPG123Source Succeeds:",name=myName) }
Else if(Ext==".wav") {a=RaWavSource(afN) RT_DebugF("RaWavSource Succeeds:",name=myName) }
Else if(Ext==".dts") {a=NicDTSSource(aFN) RT_DebugF("NicDTSSource Succeeds:",name=myName)}
} catch (msg) {a=0 RT_DebugF("Extension based Audio Fails:- '%s'",msg,name=myName) }
}
if(!a.IsClip) {
if(SepAud || !RT_BitTst(FLGS,5)) {
try {
if(SepAud || !RT_BitTst(FLGS,4)) {FFIndex(aFN)}
a = FFAudioSource(aFN) RT_DebugF("FFAudioSource Succeeds:",name=myName)
} catch(msg) {RT_DebugF("FFAudioSource Fails:- '%s'",msg,name=myName)}
}
if(!a.IsClip) {
if((SepAud || !RT_BitTst(FLGS,3))) {
try {a=LWLibavAudioSource(aFN) RT_DebugF("LWLibavAudioSource Succeeds:",name=myName) }
catch (msg) {RT_DebugF("LWLibavAudioSource Fails:- '%s'",msg,name=myName) }
}
if(!a.IsClip) {
if((SepAud || !RT_BitTst(FLGS,1))) {
try {a=LSMASHAudioSource(aFN) RT_DebugF("LSMASHAudioSource Succeeds:",name=myName) }
catch (msg) {RT_DebugF("LSMASHAudioSource Fails:- '%s'",msg,name=myName) }
}
if(!a.IsClip && SepAud) {
try {a=DirectShowSource(s,video=false) RT_DebugF("DirectShowSource Succeeds:",name=myName) }
catch (msg) {a=0 Assert(aFN!=vFN,myName+"Audio Fails: "+Chr(10)+msg)}
}
}
}
}
c = (a.IsClip) ? AudioDubEx(c,a) : c
}
RT_DebugF("Checking dimensions")
W=c.Width % 8 H=c.Height % 8
if(W > 0 || H > 0) {
W=(W==0)?0:8-W H=(H==0)?0:8-H
if(c.IsRGB()) {
yMin=c.RT_YPlaneMin(n=0,threshold=0.2) # Default matrix @ PC levels
Col = (yMin * 256 + yMin) * 256 + yMin
RT_DebugF("RGB Adding Borders %dx%d, Y=$%06X",W,H,Col,name=myName)
c=c.Addborders(0,0,W,H,Col)
} Else {
yMin=c.RT_YPlaneMin(n=0,threshold=0.2)
Col = (yMin * 256 + $80) * 256 + $80
RT_DebugF("YUV Adding Borders %dx%d, Y=$%06X",W,H,Col,name=myName)
if(W>0) {c=c.StackHorizontal(c.Blankclip(color_yuv=Col,Width=W))}
if(H>0) {c=c.StackVertical(c.Blankclip(color_yuv=Col,Height=H))}
}
}
RT_DebugF("ConvertYV12")
c = c.ConvertToYV12()
RT_DebugF("Convert Stereo")
c = FAVCStereo(c,c) # Output is YV12 + Stereo, Width & Height Mod 8
""")
T=RT_TimerHP - START
RT_DebugF("Total File Open Time = %.2fsecs",T,name=myName)
return c
}
I dont use ffmpegsource or the LSmash stuff much and those parts could definitely be improved.
johnmeyer
13th December 2014, 17:39
The frame rate created by that strange ratio (4501/250) is exactly 18.04. Do you want your video to play at 18.04 fps?? I expect that you don't.
It would be interesting to know why the software came up with this strange number. It certainly does not relate to the usual 1000/1001 reduction in frame rate needed to conform to the NTSC frame rate reduction needed to comply with the color carrier "fix" implemented back in the early 1950s.
Try your script without it, look at the resulting video, and see if it looks to be the correct speed, and check that the audio is in sync.
MysteryX
14th December 2014, 23:50
StainlessS, wow this is a complex file-opening script!
Would you definitely recommend to use this instead of dss2 (Haali), especially for MPEG1 videos ?
Although this script is complex, I can just copy/paste it and it should work perfectly?
StainlessS
15th December 2014, 00:39
The script does use Dss2, but for Mpeg (1 or 2) I would pretty much always use DGIndex as d2v.
I do use this script but almost always convert non mpg to AVI, nearly always less bother.
I tend to use that particular script together with several others + Avisynthesizer_Mod http://forum.doom9.org/showthread.php?t=166820&highlight=avisynthesizer_mod
EDIT: Vampirdom has a script which may work better.
Would you definitely recommend to use this instead of dss2 (Haali), especially for MPEG1 videos ?
Although this script is complex, I can just copy/paste it and it should work perfectly?
I would not recommend it but you can try it if you like, see if it works for you, as I said, I nearly always use it for AVI.
MysteryX
15th December 2014, 01:32
If it is so complicated, I might as well go down the route of first converting to AVI. I added an auto-convert when they select the file and it takes only 5 seconds to convert.
However, now when I try to open the file, I get the error:
AVISource: couldn't locate a decompressor for fourcc ULY0
The simple fact of convert the video from MPEG1 to AVI does remove a lot of encoding (decoding?) artifacts on its own! The AVI file plays fine.
As for the wrong FPS information, MediaInfo now gives 1.092 instead of 12/11 which is 1.0909 (?)
I call FFMPEG with these arguments
string.Format(@"-i ""{0}"" -vcodec utvideo -acodec pcm_s16le ""{1}""", source, destination)
StainlessS
15th December 2014, 01:37
UT_Video codec, can change to use HuffYUV as previously noted.
Here on VideoHelp: http://www.videohelp.com/tools/Ut-Video-Codec-Suite
MysteryX
15th December 2014, 01:48
OK it works with HuffYUV. The other codec, however, encodes faster. Besides speed, are there other benefits to utvideo? What's needed to make it work, do I have to install the codec suite you linked? It does play fine in the media player, just not in AviSynth. Since this will be part of a software that others will install, adding yet another component that needs to be installed would just complicate the setup.
And now I'm getting the audio as well.
Am I still better to encode the video only and then muxe with the audio, or can I directly encode with the audio without re-encoding it with x264?
StainlessS
15th December 2014, 01:56
'Codec suite' is probably just because it has separate YV12, RGB and I think YUY2 codecs.
Dont know if eg ffdshow yet supports it.
UT_Video is especially fast at decompression, of course is lossless. You can possibly change to Lagarith or whatever but would need
to see ffmpeg docs to see what the codec string for it is.
MysteryX
15th December 2014, 04:44
So do I need to set the 'fourCC' parameter of AviSource to 'something' for it to work?
StainlessS
15th December 2014, 05:57
Am I still better to encode the video only and then muxe with the audio, or can I directly encode with the audio without re-encoding it with x264?
No idea what you are asking there.
You need a codec of some sort to decode UT_Video (if that is what you've decided upon), whether be UT_Video itself or ffdshow's version of it if it is supported.
The audio converted via ffmpeg (via the bat file) is PCM (Pulse Code Modulated), ie un-compressed audio.
x264 encodes mp4 AVC video, not audio, whatever kind of audio it is in your flv, it may or may not be playable in all players (muxed into mp4),
if your wanted to use original audio you would have to 'suck it and see', ie try it out.
So do I need to set the 'fourCC' parameter of AviSource to 'something' for it to work?
Not if you have the suitable codec.
MysteryX
15th December 2014, 18:46
No idea what you are asking there.
You need a codec of some sort to decode UT_Video (if that is what you've decided upon), whether be UT_Video itself or ffdshow's version of it if it is supported.
The audio converted via ffmpeg (via the bat file) is PCM (Pulse Code Modulated), ie un-compressed audio.
x264 encodes mp4 AVC video, not audio, whatever kind of audio it is in your flv, it may or may not be playable in all players (muxed into mp4),
if your wanted to use original audio you would have to 'suck it and see', ie try it out.
Not if you have the suitable codec.
x264 wasn't encoding the audio so I just mux it back with the original file and it's great.
TheFluff
15th December 2014, 18:59
So if I want to preserve the same speed I should just remove that parameter? Is there any particular reason why MeGUI is adding it?
probably because the fps parameter to directshowsource only takes a float and megui wants to be ~exact~ about it or something
megui is overall a pretty dumb program that you probably shouldn't be using; your scenario as described sounds like it calls for just using ffms2
MysteryX
15th December 2014, 19:08
Not if you have the suitable codec.
Weird thing is that the AVI ut_video file plays fine directly in the media player. If the codec truly was missing, this shouldn't play.
How easy or difficult would it be to use this to load the proper codec without requiring extra installation?
http://forum.doom9.org/showthread.php?t=171541
TheFluff
15th December 2014, 19:10
which media player, a lot of them have builtin codecs these days
MysteryX
15th December 2014, 19:29
which media player, a lot of them have builtin codecs these days
Windows Media Player
StainlessS
15th December 2014, 21:46
Then you must have a DirectShow codec for UT_Video installed (WMP), but also need a Video For Windows codec for UT_Video too.
EDIT: If you have some kind of codec suite installed, perhaps its switched on for DS but not vfw.
EDIT: Perhaps the version of ffmpegsource you are using does not support UTVideo (not sure if it only uses built-in codecs or can use system vfw codecs).
MysteryX
15th December 2014, 22:35
If I install the codec software, then it works. In terms of encoding, the performance goes from 4.7-4.8 to 5.0 fps which is a nice improvement for simply changing the codec!
But if I want to use that, do I have to include this installation as part of the setup process?
StainlessS
15th December 2014, 22:44
Just provide a link and let them set it up themselves, apart from anything else, they may already have latest and be a bit annoyed about having
used the extra bandwidth to download something they already have. UT_Video is getting very popular (as is the new MagicYUV).
hello_hello
15th December 2014, 23:40
So if I want to preserve the same speed I should just remove that parameter? Is there any particular reason why MeGUI is adding it?
In the case of your script the DirectShowSource frame rate is 18.004fps
Assumefps is 4501/250 = 18.004fps so it's the same thing. Whatever MeGUI determines as the frame rate should be used for both. If you change the frame rate under the Filters/DSSource tab in the script creator, both should change to match the new frame rate.
Whether it makes any real difference to the world as we know is or not, I don't know, but in the case of 23.976fps video, AssumeFPS will be 24000/1001 which equals 23.976023976fps. I assume 24000/1001 is a more accurate representation of the NTSC frame rate? The same would apply to 30000/1001 for 29.970fps video.
http://avisynth.org.ru/docs/english/corefilters/fps.htm
I can't imagine it's going to make any real difference if you don't use AssumeFPS as MeGUI does.
creaothceann
16th December 2014, 00:04
[...] in the case of 23.976fps video, AssumeFPS will be 24000/1001 which equals 23.976023976fps. I assume 24000/1001 is a more accurate representation of the NTSC frame rate? The same would apply to 30000/1001 for 29.970fps video.
30000/1001 frames/s (60000/1001 fields/s) is the NTSC VIDEO rate, 24000/1001 is the FILM rate before telecine / after IVTC.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.