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

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st February 2015, 16:26   #1  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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.)
TCmullet is offline   Reply With Quote
Old 21st February 2015, 16:31   #2  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Code:
video = FFVideoSource("sample.flv")
audio = FFAudioSource("sample.flv")
AudioDub(video, audio)
or LSmash

Code:
video = LWLibavVideoSource("sample.flv")
audio = LWLibavAudioSource("sample.flv")
AudioDub(video, audio)

Last edited by Reel.Deel; 21st February 2015 at 16:35.
Reel.Deel is offline   Reply With Quote
Old 21st February 2015, 16:33   #3  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
You're showing two FLVs. I have only 1 FLV with both audio and video in the same file.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 16:35   #4  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Load the the same FLV for audio and video.
Reel.Deel is offline   Reply With Quote
Old 21st February 2015, 16:44   #5  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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")
The FFmpegSource2 is a "helper function" that does what you say. I used FFmpegSource2 and the file doesn't handle well (scrubbing along the VirtualDub timeline). Is there some functional advantage over doing the audio and video separately as you described? The source of info said using FFmpegSource2 is EXACTLY the same as what you did.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 16:49   #6  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
Yeah, I forgot about FFmpegSource2 (since I mainly use AviSynth with video), it's probably the same as what I suggested above but I would just use FFmpegSource2, it seems more well thought out .
Reel.Deel is offline   Reply With Quote
Old 21st February 2015, 16:57   #7  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 16:57   #8  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
You see I thought there were other FLV-open methods out here beside FFmpegSource and DirectShowSource.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 17:06   #9  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,084
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.
Reel.Deel is offline   Reply With Quote
Old 21st February 2015, 17:15   #10  |  Link
RTW47
Rome Total War
 
RTW47's Avatar
 
Join Date: Mar 2013
Location: C:\Python33
Posts: 34
Quote:
Originally Posted by TCmullet View Post

I've seen logic like this where they say you can reduce it to one line:

Code:
FFmpegSource2("sample.flv")
The FFmpegSource2 is a "helper function" that does what you say. I used FFmpegSource2 and the file doesn't handle well (scrubbing along the VirtualDub timeline). Is there some functional advantage over doing the audio and video separately as you described? The source of info said using FFmpegSource2 is EXACTLY the same as what you did.

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
RTW47 is offline   Reply With Quote
Old 21st February 2015, 17:17   #11  |  Link
HolyWu
Registered User
 
HolyWu's Avatar
 
Join Date: Aug 2006
Location: Taiwan
Posts: 484
Quote:
Originally Posted by TCmullet View Post
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.
The default value of atrack in FFmpegSource2 is -2, which effectively disables audio by default. Set atrack to -1 to make FFmpegSource2 open the first found audio track.
HolyWu is offline   Reply With Quote
Old 21st February 2015, 17:19   #12  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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?
TCmullet is offline   Reply With Quote
Old 21st February 2015, 17:37   #13  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
Quote:
Originally Posted by Reel.Deel View Post
You can try LSmashSource like I suggested in post #2. Also, are you using the latest FFMS2?
Yes, I believe I am. Version 2.20.icl. But I will look into LSmash, in parallel to this discussion.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 17:47   #14  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,681
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
}
Requires RT_Stats, FFMpegSource, LSmash, DirectShowSource2, Mpeg2Source(from DGIndex), and also Favc.avsi (cant remember where I got that).
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.
StainlessS is offline   Reply With Quote
Old 21st February 2015, 18:52   #15  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
Seems this post's embedded code is Favc.avsi?

Last edited by martin53; 21st February 2015 at 18:58.
martin53 is offline   Reply With Quote
Old 21st February 2015, 19:22   #16  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,681
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 ???
StainlessS is offline   Reply With Quote
Old 21st February 2015, 20:02   #17  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 20:15   #18  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 257
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.
TCmullet is offline   Reply With Quote
Old 21st February 2015, 20:44   #19  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 360
I usually use just this snippet:

Code:
f = <input file>
v = DSS2(f)
a = DirectShowSource(f, video=false)
AudioDub(v, a)
For DSS2 you'll need avss.dll or avss_26.dll.

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).
creaothceann is offline   Reply With Quote
Old 21st February 2015, 20:48   #20  |  Link
RTW47
Rome Total War
 
RTW47's Avatar
 
Join Date: Mar 2013
Location: C:\Python33
Posts: 34
Quote:
Originally Posted by TCmullet View Post
I wonder if LSmash's bigger index has benefits.
.lwi index is simply not compressed format (and therefore is human-readable)
__________________
GOTO:EOF
RTW47 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:32.


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