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 November 2008, 14:17 | #1 | Link |
AVStoDVD Dev
Join Date: Apr 2006
Location: Italy
Posts: 1,302
|
Universal Source functions
For my project AVStoDVD, I am trying to write a couple of fuctions (video and audio sources) that combine well known general purpose Source methods:
Code:
# Following AviSynth plugins are required: # FFMpegSource.dll @ http://forum.doom9.org/showthread.php?t=127037 # GetSystemEnv.dll @ http://avisynth.org/stickboy LoadPlugin("FFMpegSource.dll") LoadPlugin("GetSystemEnv.dll") Function A2DVideoSource(string VideoSource, bool "debug") { debug = default(debug, false) Try { SourceStr = "A2DVideoSource: AVISource" Video = AVISource(VideoSource, audio = false) } Catch(Err_Msg) { Try { SourceStr = "A2DVideoSource: DirectShowSource" Video = DirectShowSource(VideoSource, convertfps = true, audio = false) } Catch(Err_Msg) { SourceStr = "A2DVideoSource: FFmpegSource" Video = FFmpegSource(VideoSource, vcachefile = GetSystemEnv("temp") + "\A2DVideoSource.cache", seekmode = 0) } } Video = (debug == true) ? Subtitle(Video.Info(), SourceStr, font = "courier new", size = 16, align = 1) : Video return(Video) } Function A2DAudioSource(string AudioSource) { Try { Audio = DirectShowSource(AudioSource, video = false) } Catch(Err_Msg) { Audio = FFAudioSource(AudioSource, atrack = -1, acachefile = GetSystemEnv("temp") + "\A2DAudioSource.cache", acachefile2 = GetSystemEnv("temp") + "\A2DAudioSource2.cache") } return(Audio) } Bye |
22nd November 2008, 01:28 | #2 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
|
That is very, very wrong. FFmpegSource always assumes that if an index exists it will also be the correct index. Call your function twice to see very interesting results. Use vcache=false if you're that concerned about writing files everywhere. Why you set seekmode=0 is also a mystery.
My recommendation to you is to read the manuals first and script later.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
23rd November 2008, 14:56 | #3 | Link | |||
AVStoDVD Dev
Join Date: Apr 2006
Location: Italy
Posts: 1,302
|
Myrsloik, first of all I would like to thank you for FFmpegSource, really a great AviSynth plugin. Then I would like to thank you for reviewing my first attempt to write an AviSynth function. Now, let's go thru the discussion and, please, be patient if I am making mistakes.
Quote:
Quote:
0: linear access, the definition of slow but should make some formats "usable" Shouldn't it mean that seekmode=0 can have higher success at decoding formats? If so, IMO it makes sense using it for a "universal" source function. Quote:
I have read some portions of FFmpegSource Doom9 forum thread too. If you can point me other resources, please do it, I will appreciate. Bye |
|||
24th November 2008, 10:16 | #4 | Link |
Professional Code Monkey
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
|
Seekmode=0 is most of the time useless unless you can guarantee linear access. So much for being universal...
Also if you for some reason really have to create the cache(s) somewhere else (why exactly?) generate a random temporary filename for it and then delete it when the script closes using on of the utility filters I can't remember the name of (or at least I think it exists). Of course you'll still clog up the temp directory if something crashes... I guess what I'm trying to say is: why are you trying to change the default behavior in the first place? which problem are you trying to solve?
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet |
24th November 2008, 10:59 | #5 | Link |
AVStoDVD Dev
Join Date: Apr 2006
Location: Italy
Posts: 1,302
|
Ok about seekmode=0. I will remove it.
The reason to create cache files in a different (safe) folder is: what does it happen if you try to open a file located in a read-only position (i.e. CD or DVD)? FFmpegSource will prompt: Code:
Failed to write video cache info Thanks in advance Bye |
24th November 2008, 15:03 | #6 | Link |
Registered User
Join Date: Dec 2007
Posts: 639
|
Well, reading what he quoted from the documentation, it gives off the impression that seekmode=0 is the same a seekzero=true for DirectShowSource() or EnsureVBRMP3Sync() for audio... which guarantees frame accuracy, but is "the definition of slow" :P
|
30th November 2008, 15:52 | #7 | Link |
AVStoDVD Dev
Join Date: Apr 2006
Location: Italy
Posts: 1,302
|
Finally I have come out with this script:
Code:
# A2DSource library: Universal AviSynth Source Functions # Written by MrC (November 2008) # Following AviSynth plugins are required in the same A2DSource folder: # FFMpegSource.dll more info @ http://forum.doom9.org/showthread.php?t=127037 # GetSystemEnv.dll more info @ http://avisynth.org/stickboy LoadPlugin("FFMpegSource.dll") LoadPlugin("GetSystemEnv.dll") Function A2DVideoSource(string VideoSource, string "CacheFolder", bool "debug") { CacheFolder = default(CacheFolder, GetSystemEnv("temp")) debug = default(debug, false) Try { SourceStr = "A2DVideoSource: AVISource" Video = AVISource(VideoSource, audio = false) } Catch(Err_Msg) { Try { SourceStr = "A2DVideoSource: DirectShowSource" Video = DirectShowSource(VideoSource, convertfps = true, audio = false) } Catch(Err_Msg) { SourceStr = "A2DVideoSource: FFmpegSource" Video = FFmpegSource(VideoSource, vtrack = -1, atrack = -2, vcachefile = CacheFolder + "\A2DFFV_" + String(Rand()) + ".cache") } } Video = (debug == true) ? Subtitle(Video.Info(), SourceStr, font = "courier new", size = 16, align = 1) : Video return(Video) } Function A2DAudioSource(string AudioSource, string "CacheFolder") { CacheFolder = default(CacheFolder, GetSystemEnv("temp")) Try { Audio = DirectShowSource(AudioSource, video = false) } Catch(Err_Msg) { Audio = FFAudioSource(AudioSource, atrack = -1, acachefile = CacheFolder + "\A2DFFA1_" + String(Rand()) + ".cache", acachefile2 = CacheFolder + "\A2DFFA2_" + String(Rand()) + ".cache") } return(Audio) } Bye |
Thread Tools | Search this Thread |
Display Modes | |
|
|