Log in

View Full Version : Same .avs/ffmpeg different audio on 2 PCs


Starduster
23rd August 2010, 21:32
I have a process that runs drastically different on two servers. I'm using the exact same input files and the .avs and ffmpeg commands are identical but when I run them on the second server the ffmpeg audio output is SSSLLLOOOWW. The .avs is:

LoadVFAPIPlugin("swf.vfp","SWFSource")
vd = DirectShowSource("MOB.flv", fps = 29.97, convertfps = True)
fv = SWFSource("slide6.swf").flipVertical.AssumeFPS(vd).Loop.Trim(0,vd.FrameCount)
sld1 = AudioDub(fv,vd)
sld1 = sld1.ConvertToRGB32().Spline36Resize(640,480)

return sld1

The ffmpeg command is:

ffmpeg -i MOB.avs -acodec libfaac -ac 2 -vcodec mpeg4 -r 15 -s 640x480 -b 256kb -ab 96kb -ar 8000 -coder 1 -flags +aic+cbp+loop+mv4+naq -trellis 1 MOB.mp4

On the server (hosted) that produces the slow output, I don't have a sound card and .avs kept failing on Spline36Resize... I tried many different resize functions with the same error. So, I installed a sound card emulator (actually tried 2) and the .avs ran... but produces this slow audio.

I suspect it's the emulator that's giving me trouble but I don't understand why .avs's Resize functions need the sound card to work.

So, I guess my questions are:

1. Why does resize require a sound card
2. Is there any way to get .avs to work around the resize
3. Does the slowness make any sense

Inspector.Gadget
24th August 2010, 02:12
DirectShowSource is the likely culprit; check the splitter and decoder actually in use with Graphedit.

Starduster
24th August 2010, 13:03
It may be my inexperience with Graphedit, but I didn't see much. I tried DSGraphEdit too but it didn't show me much more. Here is an image of the server with the sound card. The only difference with the non-sound card server is there is no sound device for the avisynth audio output pin to connect.
http://76.242.102.193/cadelmw/images/avsgraph.gif

I did notice that ffmpeg was placing icons in the system tray that might help.

ffdshow audio decoder, input 8000mhz mono nellymoser (libavcodec), output 6 channels 16-bit integer
ffdshow video decoder, input FLV1 (libavcodec flv), output YV12, adj

Was that any help or no?

sr

Inspector.Gadget
24th August 2010, 17:14
Well, you need to compare the splitter (what parses the FLV?) and decoder (what does MP3 -> PCM conversion)? used when rendering the FLV file directly (no Avisynth) in Graphedit on each computer. A reasonably trouble-free way to do it should be to use the same FLV splitter (Gabest?) and audio decoder (ffdshow tryouts recent build) on both PCs. So for the most part your graph would be:

Somefile.flv -> Some FLV Splitter -> Some video decoder -> Renderer
.............................................-> Some audio decoder -> Some directsound device

And if it's the same on both PCs, ignoring for the moment CPU/RAM/disk factors, the speed should be good on both.

IanB
24th August 2010, 23:36
DirectShowSource() cannot render a default audio graph if the system does not have a default audio renderer. This is a restriction of the IGraphBuilder::RenderFile() library call used to render source files into usable graphs.

On most systems the default audio renderer is aligned with the sound card.

On systems without a sound card or suitable substitute you need to manually create the audio graph with Graphedit, save this graph to a .GRF file and load the .GRF file with DirectShowSource().

The Graphedit Render File feature directly calls the IGraphBuilder::RenderFile() library call. If you do not get a working audio graph from this then DirectShowSource() will also not work.

Starduster
25th August 2010, 00:15
Are you guys speaking English?... assume so, but head is spinning trying to understand! ;-) Inspector, not ignoring you, but for the time being, let me ask a question of IanB. IanB, it sounds like you have the solution to the no sound card problem (ie. manually creating an audio graph). Now, pardon me while I sound stupid...

This is part of a server-side automated process that actually writes the .avs and then calls ffmpeg. There will be a large number of files to be "processed" on an on-going basis. I assume (hoping) there would be a way to create a genereic audio graph on the computer with the sound card, like the "Default Direct Sound Device", and save its graph. Then use that graph on the server without the card. Loading it in the automated process as necessary.

Then as part of the process where I need to load it with DirectShowSource, I'm not sure what that looks like... load my .flv and then load the graph? How do the two fit together? Something like:

vd = DirectShowSource("MOB.flv", fps = 29.97, convertfps = True).DirectShowSource("defaultAudio.grf")
fv = SWFSource("slide6.swf").flipVertical.AssumeFPS(vd).Loop.Trim(0,vd.FrameCount)
sld1 = AudioDub(fv,vd)
sld1 = sld1.ConvertToRGB32().Spline36Resize(640,480)

Am I even close?? ;-)

IanB
25th August 2010, 02:33
@Starduster,

Not really, DirectShowSource() when using .GRF files will only handle either the video or the audio element. You have to manually do the AudioDub() joining of the 2 streams, but you are doing that already with your SWFSource().

The other hardship is you need to render a unique graph for each input file stream.

My normal procedure for making .GRF files is to In Graphedit use the File > Render Media File... (Ctrl+R)
Then either delete all of the video path for an audio graph, or delete all of the audio path for a video graph.
Then apply all my tweaks to the remaining graph.
Test it to see it plays as required.
Then delete the final output Video Renderer or Audio DirectSound Device.
Then save the remaining graph to a .GRF fileSo your starting point might be a bit like this :-ad=DirectShowSource("MOB.grf", Video=false)
vd = DirectShowSource("MOB.flv", fps = 29.97, convertfps = True, Audio=False)
fv = SWFSource("slide6.swf").flipVertical.AssumeFPS(vd).Loop.Trim(0,vd.FrameCount)
sld1 = AudioDub(fv, ad)
sld1 = sld1.ConvertToRGB32().Spline36Resize(640,480)

Some people claim success by using a DirectShow Merit editor to force the Null Renderer to be your default audio renderer, others add various virtual audio cards drivers, I have not tried these. I just put a $10 audio card in when I needed this.

Starduster
25th August 2010, 16:39
Well, I'd love to add an audio card at any price. Unfortunately, this server is a hosted server (GoDaddy) and they aren't too keen on putting a sound card in. I threatened to pull all of our accounts if they didn't. They just said, "Ok, go ahead". So much for threats! ;-)

Sounds, like I'm in trouble. This is an automated (unattended) process that puts files together in many different sessions for different people. So, a manual editing of the graph unfortunately won't work here. I have had some luck with the VCard sound card emulator but only when I'm remoted into the server. When I'm off and it's running as a service, it seems like the VCard isn't loaded and the build fails. Maybe I can find another virtual sound card somewhere that will work.

Thanks again for all the help. I'll post more if I find a solution on the sound card emulator.

Inspector.Gadget
25th August 2010, 17:24
Could you replace DirectShowSource with FFMPEGSource (http://code.google.com/p/ffmpegsource/) and thus avoid the need for a graph setup?

Starduster
25th August 2010, 21:53
FFMPEGSource looks very interesting. I've downloaded it and will give it a go. I've also had some better success with VCard sound card emulator. I selected their devices in control panel -> audio and checked only use default devices. It's now working as a service. Still not happy with the output, audio and video are out of synch on the .flv's without a slide, just a talking head. The .flv's look good, running .avs looks good, so it must be in ffmpeg. The FFMPEGSource may help with that too.

Thanks for the advice... I'm getting close, very close! ;-)

sr