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. |
21st February 2015, 16:26 | #1 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
Basic and CURRRENT (2015) loading FLV files
There is SO much out there scattered about here and on the web about loading/opening FLVs in AviSynth, but it's spread over a decade and impossible (to me) to know what is current and what is outdated.
Could someone please tell me what is the CURRENT (in Feb. 2015) best way to open a simple FLV that I have? Media info says it's AVC video and AAC audio. I've tried FFmepgSource2 but it gives no audio. I've tried DirectShowSource, but I can't scrub frame-to-frame quickly in order to plan edits, etc. I'm trying to avoid converting it to huge AVI (which I CAN do) and instead directly open it in AviSynth. (I have a lot of such FLVs to work on.) |
21st February 2015, 16:31 | #2 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,664
|
Code:
video = FFVideoSource("sample.flv") audio = FFAudioSource("sample.flv") AudioDub(video, audio) Code:
video = LWLibavVideoSource("sample.flv") audio = LWLibavAudioSource("sample.flv") AudioDub(video, audio) Last edited by Reel.Deel; 21st February 2015 at 16:35. |
21st February 2015, 16:44 | #5 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
Thank you, Reel. I see you edited your initial reply to make the audio and video come from the same file.
I've seen logic like this where they say you can reduce it to one line: Code:
FFmpegSource2("sample.flv") |
21st February 2015, 16:57 | #7 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
I've tried FFmpegSource2 on 2 different files. Both of them result in NO audio showing up in Virtualdub. It's like there's no audio track inside the FLV, even though MediaInfo shows it there, it plays fine (and loud) in Applian FLV Player, and Virtualdub can create output from it using the ffdshow video codec.
|
21st February 2015, 17:06 | #9 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,664
|
You can try LSmashSource like I suggested in post #2. Also, are you using the latest FFMS2?
Edit: Also, another alternative is using FLVExtract (alternative v2.2.0 fork here) and then load the raw stream with DGAVCDec or even better (if you have the license and required hardware) DGDecNV or DGDecIM. Audio will have to be loaded separately like the example above. Last edited by Reel.Deel; 21st February 2015 at 17:16. |
21st February 2015, 17:15 | #10 | Link | |
Rome Total War
Join Date: Mar 2013
Location: C:\Python33
Posts: 39
|
Quote:
in this case, it's not exactly the same i.e if video is opened first. And second you are still not importing audio. Code:
FFmpegSource2("sample.flv", atrack=-1)
__________________
GOTO:EOF |
|
21st February 2015, 17:19 | #11 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
I have now added atrack=-1 (and I read up on how -1 picks up the first audio track found). I get:
Avisynth open failure: FFAudioSource: No audio track found (FFMS2.avsi, line 40) Is it possible that the FLV was "fudged at the factory" (intentionally "damaged") to fool tools like this but still play okay in players? |
21st February 2015, 17:37 | #12 | Link | |
Registered User
Join Date: Nov 2003
Posts: 365
|
Quote:
|
|
21st February 2015, 17:47 | #13 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
If you want to be a guinea pig you can try this
Code:
Function GetFile(string vFN,string "aFN",Int "Prefer",Float "AudioDelay") { 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 AudioDelay=Float(Default(AudioDelay,0.0)) 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,UPCONV=1) 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 c = (c.HasAudio) ? DelayAudio(c,AudioDelay).Trim(0,0) : 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 } It has a go with all of the possible sources dubs the audio and ensures mod 8 YV12 video and Stereo audio. Work-in-progress. I usually dont bother with awkward clips, just do batch conversion to avi with ffmpeg, probably always less bother than trying to figure out how to open, and hoping that result is frame accurate, life is just too short for anything else. I do use this script a lot, but usually only with avi (for the mod 8 yv12 stereo type stuff). EDIT: Also requires NicAudio
__________________
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; 21st February 2015 at 17:52. |
21st February 2015, 19:22 | #15 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Thanx M53, that FAVCStereo() script works fine.
__________________
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 ??? |
21st February 2015, 20:02 | #16 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
Looks like ffmpeg created an index file (with extension .ffindex). I hadn't noticed that. By deleting it and reopening the script, I have audio now! It took 10 sec of "lockup", apparently building that index. Thanks to all.
And to Reel, I did try the L-Smash, and it too, worked. (With the 3-line invocation.) Also took at least 10 sec before Vdub showed the first frame. Now that both work, I may do some comparing. |
21st February 2015, 20:15 | #17 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
A couple differences already:
1. Ffmpeg took 10-11 seconds to create its index (.ffindex). 2,291 KB. 2. LSmash took a lot longer, 26 seconds, to do same (.lwi). But it's a whopping 123,915 KB. I wonder if LSmash's bigger index has benefits. |
21st February 2015, 20:44 | #18 | Link |
Registered User
Join Date: Jul 2010
Location: Germany
Posts: 357
|
I usually use just this snippet:
Code:
f = <input file> v = DSS2(f) a = DirectShowSource(f, video=false) AudioDub(v, a) If you want to make absolutely sure that you can do frame-accurate seeks everywhere, encode the source to a lossless format that uses only keyframes (e.g. Lagarith). |
21st February 2015, 20:52 | #20 | Link |
Registered User
Join Date: Nov 2003
Posts: 365
|
I have a more tangible difference. I"ve loaded the same video into both. The video is a 2 1/2 hour sports program. I found an action frame 13 minutes in (meaning it's close to the start), and one late in the show, 2 hr 13 min. These action frames are where an athlete hits a ball so that there's a distinct "pop" that visually shows up in Virtualdub when you do "View", "Audio display".
FFmpeg (FFmpegSource2): The first point had a audio delay of about 3 frames at first point and 9 frames at the second. LSmash (3 lines of code): The first point had delay of about 2 frames at the first point and ALSO 2 frames at the second point. So it looks like I'll work with LSmash for now. Thanks, Reel.Deel. I guess LSmash must be handling audio a bit more precisely. |
Thread Tools | Search this Thread |
Display Modes | |
|
|