View Full Version : Audio not in sync using .flv
Starduster
6th August 2014, 09:58
I'm trying to automate the combining of a number of .flv's into a single video file and having a problem getting the audio synced with the video. Although I've tried many things, here's the basics:
...
a = FFAudioSource("10002.flv")
v = FFVideoSource("10002.flv")
vd = audiodub(v,a)
vd = changeFPS(vd,15)
VD=VD.ConvertToRGB32().Spline36Resize(640,480)
sld1=getChannel(VD,1,1).ssrc(11025)
sld0 + sld1
The audio is a couple of seconds off. I'm not even sure FFMS is the way to go for .flv's. If I drop all the conversion filters, the audio still is off a bit, just not as much.
What is the best way to convert .flv's and how to I keep the audio in sync?
sneaker_ger
6th August 2014, 10:14
a = FFAudioSource("10002.flv")
v = FFVideoSource("10002.flv", fpsnum=15)
vd = audiodub(v,a)
You could also append all flv files using mkvtoolnix without any conversion.
tebasuna51
6th August 2014, 10:47
Use also:
sld0 ++ sld1
instead
sld0 + sld1
Starduster
6th August 2014, 11:44
Humm... added fpsnum=15 and it says, FFAudioSource: Seeking is severely broken. That doesn't sound good... ;-) I took off all the other conversions and it didn't help. Is there a way to fix broken audio?
Unfortunately, the .flv's are different so I have to make them a common format, that's why the conversion.
Starduster
6th August 2014, 11:47
Tebasuna51, I just have one file I'm trying to convert right now but I'll give the ++ a go when I'm combining files. Currently, I'm having the problem just using a single file... Can't wait until I try and string them together! ;-)
Starduster
6th August 2014, 15:06
I have another computer with a lot more on it so I used:
f = "212_0_10002.flv"
FFIndex(f)
a = FFAudioSource(f)
v = FFVideoSource(f, fpsnum=15)
sld1 = audiodub(v,a)
sld1
I got the video to play but it sounded like a machine gun. I took the fpsnum off and it sounded the same. No other audio was heard. If I take the FFIndex off, then all I have is video and no audio. This is a little file so if anyone is interested in giving it a go... http://www.velocedge.com/starduster/212_0_10002.flv
poisondeathray
6th August 2014, 15:30
That sample is VFR with nellymoser audio . It's going to be tough to append them and keep them in sync with avisynth
You can convert them with ffmpeg (keeping VFR), then if you still want to use avisynth , convert to CFR and append them
What are the specs of the other videos ?
sneaker_ger
6th August 2014, 15:50
I have another computer with a lot more on it so I used:
f = "212_0_10002.flv"
FFIndex(f)
a = FFAudioSource(f)
v = FFVideoSource(f, fpsnum=15)
sld1 = audiodub(v,a)
sld1
I got the video to play but it sounded like a machine gun. I took the fpsnum off and it sounded the same. No other audio was heard. If I take the FFIndex off, then all I have is video and no audio. This is a little file so if anyone is interested in giving it a go... http://www.velocedge.com/starduster/212_0_10002.flv
Interestingly, audio and video are fine here. Are you using an outdated build of ffms2?
a=ffaudiosource("212_0_10002.flv").DelayAudio(1.459)
v=ffvideosource("212_0_10002.flv", fpsnum=15)
audiodub(v, a)
I took the delay from MediaInfo, ffms2 messes it up.
Starduster
7th August 2014, 18:57
Sorry for the delay, I installed the flvsplitter and now it doesn't know what FFAudioSource or FFVIdeoSource are. Poisondeathray, what would you convert them to first? That's actually what I'm doing. I'm taking a number of files, using avisynth to merge them together, and then passing the .avs to ffmpeg to write the file as a .mp4, .flv, and .wmv. I never thought of using ffmpeg by itself to merge files... didn't know it could do that
poisondeathray
8th August 2014, 04:31
Sorry for the delay, I installed the flvsplitter and now it doesn't know what FFAudioSource or FFVIdeoSource are. Poisondeathray, what would you convert them to first? That's actually what I'm doing. I'm taking a number of files, using avisynth to merge them together, and then passing the .avs to ffmpeg to write the file as a .mp4, .flv, and .wmv. I never thought of using ffmpeg by itself to merge files... didn't know it could do that
flvsplitter has nothing to do with FFAudio or FFVideoSource . Those are part of ffmpegsource2. You need ffms2.dll. If you find a version that works natively without issues on these then you could use that
If you are using ffmpeg to append first, and they are the same dimensions, you can use concat demuxer
https://trac.ffmpeg.org/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files
If they are different specs, I would use a lossless codec (e.g. libx264 crf 0, uncompressed audio). You can batch convert with ffmpeg. Then you can still do your other manipulations in avisynth.
Starduster
12th August 2014, 18:07
I've tried so many combinations, I'm not sure which way is up anymore. I've been working on the ffmpeg concatenation. All the files were created with Avisynth as .flv's. ffmpeg converts them without a video sync problem (ya) but one of them has no audio at all. It was originally a .mp4 that was converted into the .flv with Avisynth using the following:
a = FFAudioSource("wicvideo1.mp4")
v = FFVideoSource("wicvideo1.mp4")
sld5 = audiodub(v,a)
sld5 = changeFPS(sld5,15)
sld5 = sld5.ensureVBRMP3sync()
sld5 = sld5.ConvertToRGB32().Spline36Resize(640,480).SSRC(22050, fast = True)
sld5 = getChannel(sld5,1,1)
It plays fine by itself. If I put the info command in Avisynth and compare those that play audio and those that don't, the only difference is the one that plays audio says: Frames per second: 15.0000 (15/1) and the one that doesn't says: Frames per second: 15.0000 (10000000/666667) otherwise they both say:
Colorspace: RGB32
Width: 640 pixels, Height: 480 pixels
Fieldbased (Separated) Video: No
Parity: Assumed bottom field first
Video pitch: 2560 bytes
Has audio: Yes
Audio Channels: 2
Sample type: Float 32 bit
Samples per second: 22050
In ffmpeg I'm using: "ffmpeg -f concat -i vlist.txt -s 640x480 -acodec pcm_alaw test.flv" where vlist.txt contains:
file '212_0_10002.flv'
file '212_0_0.flv'
file '212_0_10004.flv'
file '212_0_2.flv'
file '212_0_10008.flv'
file '212_0_3.flv'
What have I missed?
poisondeathray
12th August 2014, 18:27
Dumb question, but do you still have the original mp4's ?
Was that problem FLV the only one in the batch that was converted from an MP4 ?
What does mediainfo (view=>text) say about the problematic FLV? what does ffmpeg -i say about the the problematic FLV? and compared to FLV's that work ?
And if you're using uncompressed audio, I would use -c:a pcm_s16le, it's more compatible with most programs than alaw
Starduster
12th August 2014, 20:33
Actually, I do have the originals. However, the process is such that it combines a variety of audio, images, videos into a single .flv. That's what the .mp4 is part of. Then "this" process combines videos that have already been combined.
The other files don't contain any mp4's. They primarily contain .swf's (image) that have been merged with .flv audio to produce a series of slides with voiceover.
Results from mediaInfo and ffmepeg attached. One thing I realized as I was making these files is the original reason for using Avisynth to combine them was there are the .flv's from Red5 that have not been converted. Those are the ones that are actually out of sync, they are the talking heads. The others all have gone through the Avisynth process to make them all the same.
If I use -c:a pcm_s16le, I get no audio at all from any of the videos.
poisondeathray
12th August 2014, 20:42
If you can just copy & paste the text, that would be great. Sometimes it takes a while for a mod to approve attachments
Process seems like a lot of steps doesn't it ? A lot of steps means more places for things to go wrong
Do the red5 FLV's append correctly in ffmpeg ?
poisondeathray
12th August 2014, 22:00
"212_0_10002.flv" is 8000Hz, mono, nellymoser
The others are 22050 Hz, stereo, MP3 .
You can try re-encoding the audio of that one to match, fake stereo, resample to 22050
Starduster
12th August 2014, 22:36
I'm assuming you can view the attachments now... I can anyway. Yes, lots-o-steps... you can't imagine! ;-) The Red5 videos append but since they are the ones that are talking heads, they're the problem. You can see lips! ;-)
The 212_0_1002 and the 212_0_3 work fine, it's the 212_0_2 that was created from the .mp4 that's a problem. I'll give the Red5 one a shot, but when I re-encode it, it's out of sync. I'll put all these on the web if it helps.
poisondeathray
12th August 2014, 22:51
Well I don't see how you can do this without at least some re-encoding, you have different audio codecs, channels, sampling rates, different resolution videos (some are 640x480, others are 320x240)
You have to start by deciding what standard format /characteristics you want
Starduster
13th August 2014, 11:45
Well, that's why I was using Avisynth in the beginning to put everything into 640x480 RGB, 2 channel, 11025. I think I'm back to Avisynth being the way to standardize and combine the videos, but that leaves me with the original sync problem. So, forgetting everything else, is there a way to make sure the audio is in sync with Avisynth?
StainlessS
13th August 2014, 12:39
I would just use ffmpeg to convert to AVI (much easier than messing around trying to find a suitable source filter for each.
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) DO (
%FFMPEG% -i "%INDIR%\%%A" -vcodec utvideo -acodec pcm_s16le "%OUTDIR%\%%~nxA.AVI"
)
Pause
Then see this post/thread where I submitted a script (work in progress) that might assist, if you want things automated.
http://forum.doom9.org/showthread.php?p=1667909#post1667909
poisondeathray
13th August 2014, 19:32
Well, that's why I was using Avisynth in the beginning to put everything into 640x480 RGB, 2 channel, 11025. I think I'm back to Avisynth being the way to standardize and combine the videos, but that leaves me with the original sync problem. So, forgetting everything else, is there a way to make sure the audio is in sync with Avisynth?
You can do those manipulations in ffmpeg, such as resizing, duplicating audio channels and resampling. The point of appending in ffmpeg was to keep everything in sync, VFR , same as original. It copies the timecodes over, so everything is in sync .
If you are able to open it in avisynth, some of those VFR videos will be out of sync unless you convert it to CFR, or unless you encode it to VFR by using timecodes. Avisynth is CFR only. If the videos are only minimally variable, then you might be able to get away without converting it to CFR. When you convert it to CFR, you basically insert duplicates in those sections where the framerate drops
StainlessS
13th August 2014, 20:30
The Poison guy is well gud. (just ingore the Deathray stuff, really scary) but the guy himself is a pussy cat, and well gud.
Whatever the poison man says, go with that.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.