View Full Version : Audio DeSync while Trimming.
AlonP
28th August 2015, 22:17
Hi,
I have tried using the below two scripts to combine bits and pieces from my parents birthday video, the first 2 videos were shot on my phone(note 2) and rest on canon EOS 700D(or some similar name).
I tried the following two but no success( there is like... a few milliseconds delay, up to a second I suppose - the 2nd script seems to have given a bit more precise result).
AudioDub(LWLibavVideoSource("20150821_210914.mp4"),LWLibavAudioSource("20150821_210914.mp4"))
Trim(0,15209)++Trim(15386,20871)
A=last.assumefps("ntsc_video")
AudioDub(LWLibavVideoSource("20150822_160656.mp4"),LWLibavAudioSource("20150822_160656.mp4"))
B=last.assumefps("ntsc_video")
AudioDub(LWLibavVideoSource("MVI_0049.mov"),LWLibavAudioSource("MVI_0049.mov"))
Trim(151,3827)
C=last
AudioDub(LWLibavVideoSource("MVI_0050.mov"),LWLibavAudioSource("MVI_0050.mov"))
Trim(0,2176)
D=last
AudioDub(LWLibavVideoSource("MVI_0051.mov"),LWLibavAudioSource("MVI_0051.mov"))
E=last
AudioDub(LWLibavVideoSource("MVI_0052.mov"),LWLibavAudioSource("MVI_0052.mov"))
Trim(0,11330)
F=last
AudioDub(LWLibavVideoSource("MVI_0055.mov"),LWLibavAudioSource("MVI_0055.mov"))
Trim(60,14924)
G=last
AudioDub(LWLibavVideoSource("MVI_0056.mov"),LWLibavAudioSource("MVI_0056.mov"))
Trim(85,6049)
H=last
AudioDub(LWLibavVideoSource("MVI_0057.mov"),LWLibavAudioSource("MVI_0057.mov"))
I=last
AudioDub(LWLibavVideoSource("MVI_0058.mov"),LWLibavAudioSource("MVI_0058.mov"))
Trim(0,3957)
J=last
AudioDub(LWLibavVideoSource("MVI_0059.mov"),LWLibavAudioSource("MVI_0059.mov"))
Trim(0,1230)
K=last
AudioDub(LWLibavVideoSource("MVI_0060.mov"),LWLibavAudioSource("MVI_0060.mov"))
L=last
AudioDub(LWLibavVideoSource("MVI_0061.mov"),LWLibavAudioSource("MVI_0061.mov"))
Trim(0,19781)
M=last
Return A++B++C++D++E++F++G++H++I++J++K++L++M
ffmpegsource2("20150821_210914.mp4",atrack=-1)
Trim(0,15209)++Trim(15386,20871)
A=last.assumefps(30001,1001)
ffmpegsource2("20150822_160656.mp4",atrack=-1)
B=last.assumefps(30001,1001)
ffmpegsource2("MVI_0049.mov",atrack=-1)
Trim(151,3827)
C=last
ffmpegsource2("MVI_0050.mov",atrack=-1)
Trim(0,2176)
D=last
ffmpegsource2("MVI_0051.mov",atrack=-1)
E=last
ffmpegsource2("MVI_0052.mov",atrack=-1)
Trim(0,11330)
F=last
ffmpegsource2("MVI_0055.mov",atrack=-1)
Trim(60,14924)
G=last
ffmpegsource2("MVI_0056.mov",atrack=-1)
Trim(85,6049)
H=last
ffmpegsource2("MVI_0057.mov",atrack=-1)
I=last
ffmpegsource2("MVI_0058.mov",atrack=-1)
Trim(0,3957)
J=last
ffmpegsource2("MVI_0059.mov",atrack=-1)
Trim(0,1230)
K=last
ffmpegsource2("MVI_0060.mov",atrack=-1)
L=last
ffmpegsource2("MVI_0061.mov",atrack=-1)
Trim(0,19781)
M=last
#Part1=A++B
#Part2=C++D++E++F++G++H++I++J++K++L++M
#Return
Return A++B++C++D++E++F++G++H++I++J++K++L++M
I suppose the problem is the splicing? I feed the script to megui audio part, and encode to lame mp3.
Would appreciate some help with this. I tried googling, haven't found info that was very helpful.
poisondeathray
29th August 2015, 00:29
The phone video is probably the culprit - it's likely VFR (check with mediainfo view=>text) . You likely have to convert those to CFR if you want to edit
AlonP
29th August 2015, 01:26
The videos are encoded into lagarith lossless via virtual dub.
But What I will do is try and encode Segments A and B together, and the rest together, so I will get 2 segments out, and see if I have this issue then. Thanks! Will update.
Edit:
I checked and you were right the framerate is variable on the mobile videos - but would it matter? After all I apply the assumefps(30001,1001) - on both of them...
raffriff42
29th August 2015, 01:51
AssumeFPS can be a problem...http://avisynth.nl/index.php/AssumeFPS
The AssumeFPS filter changes the frame rate without changing the frame count (causing the video to play faster or slower). It only sets the framerate-parameter.
If sync_audio (which is false by default) is true, it also changes the audio sample rate to match the duration of the video, the pitch of the resulting audio gets shifted. So without the sync_audio parameter, video duration is altered without changing audio duration.
Anyway if you wanted 29.97 fps (standard NTSC frame rate) you would say
assumefps(30000,1001)
Try specifying the frame rate explicitly:
ffmpegsource2("ABC.mov", atrack=-1, fpsnum=25)
ffmpegsource2("ABC.mov", atrack=-1, fpsnum=30)
ffmpegsource2("ABC.mov", atrack=-1, fpsnum=30000, fpsden=1001) ## 29.97fps
...and removing the calls to AssumeFPS.
poisondeathray
29th August 2015, 05:02
I checked and you were right the framerate is variable on the mobile videos - but would it matter? After all I apply the assumefps(30001,1001) - on both of them...
It matters because VFR video from phones means there are missing frames (frames are dropped during recording, usually during lower light conditions). VFR timecodes keep everything in sync (it plays back faster or slower in segments). But you cannot edit it with most software, avisynth included
When you use AssumeFPS, it will go out of sync, because you still have missing frames. You're assuming a constant frame rate, but with the same number of decimated frames.
You want to use ConvertFPS to insert duplicate frames in approximately the same locations where they would have been dropped in the first place. It's not perfect, but it's the better method that avisynth has to offer. This is one time where DirectShowSource() actually works well (usually using it is a last resort). This way you keep everything else the same, including the audio
Not all camera phones record with a base rate of 30000/1001 . Some actually record 30.0 (ie. not 29.97) as a base rate. Usually what mediainfo says as the frame rate is the correct one (not the min or max, but the frame rate)
DirectShowSource("video.ext", fps=x, convertfps=true)
AlonP
29th August 2015, 12:09
Thanks for the responses guys! I encoded without the cellphone segments (A and B) and it was in Sync. I also tried as suggested to use the sync parameter (assumefps(30001,1001,sync_audio=true)) - but that gave me an error saying sample rate in audio is different, so then I added also an SSRC(48000) line, and still it complained. So, I moved on to convertfps, only not the DSS one (so I dunno if it'll actually work), my current script is this:
ffmpegsource2("20150821_210914.mp4",atrack=-1)
Trim(0,15209)++Trim(15386,20871)
A=last.ConvertFPS(30001,1001)
ffmpegsource2("20150822_160656.mp4",atrack=-1)
B=last.ConvertFPS(30001,1001)
ffmpegsource2("MVI_0049.mov",atrack=-1)
Trim(151,3827)
C=last
ffmpegsource2("MVI_0050.mov",atrack=-1)
Trim(0,2176)
D=last
ffmpegsource2("MVI_0051.mov",atrack=-1)
E=last
ffmpegsource2("MVI_0052.mov",atrack=-1)
Trim(0,11330)
F=last
ffmpegsource2("MVI_0055.mov",atrack=-1)
Trim(60,14924)
G=last
ffmpegsource2("MVI_0056.mov",atrack=-1)
Trim(85,6049)
H=last
ffmpegsource2("MVI_0057.mov",atrack=-1)
I=last
ffmpegsource2("MVI_0058.mov",atrack=-1)
Trim(0,3957)
J=last
ffmpegsource2("MVI_0059.mov",atrack=-1)
Trim(0,1230)
K=last
ffmpegsource2("MVI_0060.mov",atrack=-1)
L=last
ffmpegsource2("MVI_0061.mov",atrack=-1)
Trim(0,19781)
M=last
Return A++B++C++D++E++F++G++H++I++J++K++L++M
Oh, also, the reason I used (30001,1001) and not 30000,1001 - is because besides the 2 camera segments - all other segments are 30001,1001. so Instead of converting 11 segments to (30000,1001) - I figured I might as well convert just 2 to (30001,1001). I figure - there's no need to go by standards - coz it'll be played on a computer anyway.
Thanks for all the help! I will edit to say if it all worked out :).
sneaker_ger
29th August 2015, 12:59
So, I moved on to convertfps, only not the DSS one (so I dunno if it'll actually work)
They are not interchangeable.
StainlessS
29th August 2015, 13:00
but that gave me an error saying sample rate in audio is different
You might also want to use eg ResampleAudio(44100) to change all samples to the same rate before splice.
(EDIT: sync_audio will produce 'odd' audio sample rate requiring resample)
EDIT: Also use 30000,1001.
AlonP
29th August 2015, 13:43
@sneaker_ger - dunno, all seems to work ;).
@StainlessS - all seems to work now hehe ;). By the way, thank you again for that megui-que automation tool - was very helpful at the time ;).
I am pretttty sure it all works, but it's a bit hard to tell as I have outputted to lagarith and it lags a bit during playback, it's a 90gb file, plays a bit choppy, BUT, from what I can see it came out perfectly fine. Thanks for all your help guys. I will update again once I convert to h264. First tho, I need to take care of yellowness. The room was very golden(tiles) and everything looks a bit too yellow. Think I saw a filter to take care of that somne time ago, so gonna go look it up ;).
StainlessS
30th August 2015, 23:22
AlonP, happy that you like the MeGUI auto thing, me likes it too, but does make mistakes on occasion, not sure why.
(EDIT: Mistakes involve probably only timing or something like that, nothing major only wrong directory being received,
for some reason, results when wrong works perfectly if done a 2nd time usually [never yet wrong a 2nd time here]).
(Only thing I can think of is OS being inconsistent sometimes)
AlonP
31st August 2015, 20:15
AlonP, happy that you like the MeGUI auto thing, me likes it too, but does make mistakes on occasion, not sure why.
(EDIT: Mistakes involve probably only timing or something like that, nothing major only wrong directory being received,
for some reason, results when wrong works perfectly if done a 2nd time usually [never yet wrong a 2nd time here]).
(Only thing I can think of is OS being inconsistent sometimes)
You just... literally... blamed the computer *grins* Such a programmer thing to do hahahaha ;).
StainlessS
31st August 2015, 23:23
The problem exhibits itself when eg sending "D:\" to OS fileselector and debug log shows that that is exactly what is being sent, but,
what appears in the fileselector text box is eg "D:". The problem 1st appeared a couple of years ago after having no previous problems for
some time (maybe 12 months, same compile), only difference being Windows update (I had not visited Windows Update for quite some time prior),
at about same time another user posted about same problem, so both of us had similar problem at same time and without source or compile update.
So, only thing I can think is that an update that affected the file selector is the problem. If the exact same operation and file selection is
selected a second time the problem is unlikely to appear again. In last executable update I changed to sending ENTER key separately after
the directory string and that reduced the number of times the problem appears but it does still appear maybe about 1 in 100 or 200 avs files,
so it is not something that bothers me too much, also unpredictability makes it difficult to find a work around.
It could I suppose be a problem in AutoIt (language used to create executable), but for sure not a problem in MeGUI.
You just... literally... blamed the computer *grins* Such a programmer thing to do hahahaha
Dont know what else to blame :(
EDIT: Since last update, only noticed it happening when source directory is root of a hard drive, not a sub directory (but not sure).
AlonP
1st September 2015, 00:17
I dunno, I have used the program to que ~1500 files(50 at a time or so). Hadn't happened once *grins*.
StainlessS
1st September 2015, 13:50
The other user that reported a problem said that the problem later just disappeared (methinks was ZeroWalker), I'm guessing that he
was on W7 whereas I'm (still) on XP32, perhaps W7 later fixed the update fix but XP was left as is.
I think the problem 1st appeared 2 Novembers ago, and of course XP support ended about 6 months later (perhaps they were not quite so zealous
about fixing problems in XP just prior to end of support).
Anyways, glad to hear that it is not affecting you and assume that you are on post XP32 OS.
AlonP
2nd September 2015, 00:26
Yup, I'm on win7. Glad you are still around. It's kinda weird but even though I never spoke to Didee, coming back to encoding stuff I came back to these forums and seen that he is gone and it's a bit sad, ya know? I'm happy for him coz' he prolly is more involved in something that is after his own heart, and yet it's somewhat sad coz' he was such a strong player in this whole avisynth biz... So, it's nice to see StainlessS here, as well as some other known faces. How fucked up is it that you can get nostalgic over people you didn't know lol? haha.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.