I have a video that starts off playing fine but, as the the episode progesses, the video will gradually lag behind the audio. I've read many other posts about getting audio and video in sync but they were mainly just offsetting the audio and vice versa to get things to match up, which obviously won't work here since the lag is not consistent.
I encoded the video using MeGUI (2008 svn) with all of the updates as well as the latest version of ffdshow tryouts. I even tried doing another encode using ffdshow tryouts r3154 beta 7 (which is supposedly the most stable) and still have the same problem. The source video plays just fine and doesn't lag at all.
My script is really simple and I'm not sure if it will help any but here it is:
DirectShowSource("D:\JIN\Ep01\JIN Ep01 1080p.mkv", fps=29.970, audio=true, convertfps=true).AssumeFPS(30000,1001)
#deinterlace
#crop
LanczosResize(1280,720) # Lanczos (Sharp)
#denoise
Here's the mediainfo for the original file:
General
Unique ID : 191614497887991492739233272685605085455
(0x90279C241E45A17281ABAAC5F176E10F)
Complete name : D:\JIN\Ep 01\JIN Ep01 1080p.mkv
Format : Matroska
File size : 5.00 GiB
Duration : 1h 33mn
Overall bit rate : 7 651 Kbps
Encoded date : UTC 2009-11-12 23:38:37
Writing application : mkvmerge v2.9.7 ('Tenderness') built on Jul 1 2009
18:43:35
Writing library : libebml v0.7.7 + libmatroska v0.8.1
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Baseline@L4.0
Format settings, CABAC : No
Format settings, ReFrames : 1 frame
Codec ID : V_MPEG4/ISO/AVC
Duration : 1h 33mn
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : A_AAC
Duration : 1h 33mn
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Delay relative to video : 6ms
Title : PID 274
Language : Japanese
And the encoded one:
General
Unique ID : 181901405713827214973802134532888859116
(0x88D8EFB9287C676CAD8DDEB96ABE11EC)
Complete name : D:\JIN\Ep 01\JIN Ep01 1080p-muxed.mkv
Format : Matroska
File size : 1.28 GiB
Duration : 1h 33mn
Overall bit rate : 1 954 Kbps
Encoded date : UTC 2011-04-21 21:48:13
Writing application : mkvmerge v4.6.0 ('Still Crazy After All These Years') built
on Mar 10 2011 02:50:32
Writing library : libebml v1.2.0 + libmatroska v1.1.0
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 1h 33mn
Nominal bit rate : 1 812 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.066
Writing library : x264 core 114 r1913 5fd3dce
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x113 /
me=umh / subme=8 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 /
trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=3
/ sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=3 /
b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 /
keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass /
mbtree=1 / bitrate=1812 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 /
cplxblur=20.0 / qblur=0.5 / vbv_maxrate=50000 / vbv_bufsize=50000 / nal_hrd=none /
ip_ratio=1.40 / aq=1:1.00
Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : A_AAC
Duration : 1h 33mn
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz / 24.0 KHz
Compression mode : Lossy
I have already noticed the 6ms delay in the source audio and tried offsetting the encoded audio in mkvmerge by putting 6ms in the audio delay field and it gave the same results of progressively going out of sync, as expected.
+ Reply to Thread
Results 1 to 24 of 24
-
-
Most likely, one or the other is running at the wrong frame rate, carefully examine and/or eliminate any framerate changes in your script. I'm no AviSynth expert but I would seriously question the second line in your script. What happens if you play that in Vdub?
Common problem, if you saw no reference to it you did not search very well and/or long enough. -
Thank you for your input nelson but, as you can see by reading the mediainfo, both of the videos are running at 29.970. I'm sure you're also aware that both the source and encode are MKV files and Vdub is quite outdated when it comes to that format as well.
It's ok if you didn't though, since it's a common problem that people don't read things through thoroughly before replying to someone else's post. I also know of the common problem that you are referring to but if you happen to know of a post that answers my "common problem", by all means, please let me know. -
Well, first, you mean the video and the audio. Second, you have no proof that they are, just that mediainfo states that they are identified as such. It does no actual check on true framerates, just reads header info. You have a gradual de-synch, that is often a framerate problem.
Yes, there are dozens if not hundreds of posts addressing gradual de-synch issues. Having read most of them years ago and solved most problems I had with this issue, I haven't checked for one lately.
The output of your script will NOT be an MKV file, and Vdub should play it just fine. If the de-synch occurs, that pinpoints the problem in the script and not the re-encoding.
That would be the first step in diagnosing and solving your problem, if you are not interested in doing that obvious, simple step, then I would suggest you attempt to get answers someplace else. -
The cheap trick would be to change the frame rate in the MKV header.
So the video starts out in sync and gradually gets out of sync. How far off is it by the end of the video? That may be a hint as to what's going wrong. The difference between 30000/1001 and 29.97 is very small. Not noticeable (~5 ms) after a 90 minute movie. -
@jagabo
Exactly what I thought. The difference between the two framerates is small like you said and even if the framerate was converted, it shouldn't be noticeable. The video is only about 90 minutes long and it starts to go out of synch around 50 something minutes if I remember correctly. By the end of the video, I would say it's off by a second or so and it's like a poorly dubbed movie. I already tried extracting the video and setting it with various fps values when I muxed it back with mkvmerge before I created this thread (that is the cheap trick to change the framerate in the mkv header that you were referring to right?).
@nelson
Seriously, how about we stop trying to bash other people when they ask for help? I don't know about you but I try to treat people like how I would like to be treated. I already said that I TRIED looking before I posted but wasn't able to find a solution. Give me a break. If you noticed, I don't post here often BECAUSE I look around before I ask. Sorry that "gradual de-synch" wasn't one my keywords during my search and that I'm not as awesome at searching the forums as you are. Btw, I loaded the script into Vdub (without getting rid of the framerate conversion) and everything played just fine. Any other possible causes come to mind? -
For a frame rate change to work the sync has to change gradually throughout the video. If it is off by one second at the end, it should be off by 1/2 second in the middle, 1/4 second a quarter of the way through, etc.
If your video has good A/V sync up to the middle then is suddenly a second off for the rest of the movie, that's a different type of problem. If you change the frame rate, A/V sync will be good at the start and end but it will be off by 1/2 second in the middle.
You can just open the file with MMG, set the frame rate in the Format Specific Options tab for the video, then save as MKV again. -
Assuming the additional information is correct, the problem is now NAILED DOWN to something that happens during the re-encoding process.
Since the video is correct up to the 50 minute mark, and the problem occurs afterwards, then the issue is not framerate, it is something that happens at that point. Interesting is is very near the half-way mark. Possible the movie was previously split and incorrectly rejoined, possible there is simply some sort of data error at that point. You may have to split it yourself and correct the second half.
So you have now learned that Vdub will play an AviSynth script, no matter what the input file type. Also that your search methodology needs some refinement. Third thing would be don't ever question my reading comprehension again. -
Maybe try using different muxer , like mp4box, tsmuxer, or different version of mkvtoolnix
Are you re-encoding the audio as well, or muxing the original ? Try muxing new video + old audio, maybe the audio is the issue ?
Try encoding xvid to narrow down if it's x264 encoding issue -
@jagabo
That's was how I've been doing it. I already tried some other fps values in the drop box but still nothing as expected, unfortunately.
@poisondeathray
I did re-encode the audio (cbr and adaptive) along with the video and I already tried muxing the encoded video with the source audio and the video is definitely the one that's lagging. Thanks for the input. I'll give that a try later today or sometime tomorrow to see if it is a x264 problem.
@nelson
It seems like you're a pro when it comes to video and audio issues. With that said, you're terminology SHOULD naturally be better and you SHOULD be able to search better. When I search, I use the keywords that come to mind, within the best of my knowledge with this topic. Like I said, stop bashing on people asking for help and people won't bash back.
"I treat people like how I would like to be treated"<---remember that? What goes around comes around so just don't start in the first place?? I can understand if I didn't try before asking or something but sorry for not going to page 300 of the search results if that's what you were expecting and, like I said, not being as awesome as you when searching. -
What do you mean by "nothing"? All the players I use obey the frame rate indicated in the MKV header. If the original frame rate is 29.97 and the audio is 1 second shorter than the 90 minute video you need to make the the video play faster, 5399 seconds instead of 5400 seconds. Change the frame rate to 29.97 * 5400 / 5399, or ~29.97555 fps. Conversely, if the audio is 1 second longer than the video use 29.97 * 5399 / 5400, or ~29.96445 fps.
Again, this is a cheap trick. Some standalone players may not like the unusual frame rate. -
My search for audio de-synch showed that, in the first five results, TWO mentioned a gradual or progressive de-synch. I typed "audio de-synch" into the search box, no special skill needed.
I know from experience that usually one of the first questions asked to a de-synch post is "is it constant, or gradually increasing". I also know from experience that almost everybody says they searched for hours and hours and about 10 seconds of effort reveals that they did not.
I told you your search could have been better, which is accurate and truthful. You replied by questioning my reading comprehension and made several "obvious" statements that have been shown to be inaccurate.
You also failed to supply the very important information that the problem does not begin until 50 minutes into the video. I absolutely cannot understand how any functioning human being could have spent more than 30 seconds looking into this problem without gaining an understanding that this is critically important information.
Your problem is NOT framerate, unless it begins at the 50-minute mark, which would go back to the file-split issue I mentioned earlier. I would try some of the standard methods for dealing with audio synch which I am sure you have already read, and then if those fail, split the file at the failure point and deal with the back half seperately. -
Good for you. I'm sure YOUR search did get you those results but, "gradual de-synch was not one of my keywords" <-remember reading that?? I see what you're saying though. Everybody in the world thinks the same after all and the first two words that comes to mind definitely has to be "gradual de-synch" as oppose to "gradual desynch" without the hypen or any other combination of words. Words like "out of synch" or "lag" is just completely unacceptable search terms. Maybe I should have spent the whole day throwing strings of words into the search engine because I couldn't possibly have anything else beter to do right? Good for you finding it so well. You want a cookie?
I know from experience that usually one of the first questions asked to a de-synch post is "is it constant, or gradually increasing". I also know from experience that almost everybody says they searched for hours and hours and about 10 seconds of effort reveals that they did not.
I told you your search could have been better, which is accurate and truthful. You replied by questioning my reading comprehension and made several "obvious" statements that have been shown to be inaccurate.
You also failed to supply the very important information that the problem does not begin until 50 minutes into the video. I absolutely cannot understand how any functioning human being could have spent more than 30 seconds looking into this problem without gaining an understanding that this is critically important information.
@jagabo
Sorry about that. I was pressed for time when I posted earlier today. What I meant was that nothing was able to match up right despite what fps I used in the drop box. I didn't use any other values than the ones listed in mkvmerge but I'll try some other ones later to see if it works. Thanks. -
-
You can try another source filter too, directshow sometimes causes problems. Although your script plays ok, so this is unlikely
e.g. ffms2 -
Hello ... first off ... I want to say that "Nelson37" was the first person to offer some help after ... 2 hours of your post being made ... and to make the comment ... "It's ok if you didn't though, since it's a common problem that people don't read things through thoroughly before replying to someone else's post" ... that comment you made was negative ... you really could have reworded it.
I have had the audio out of sync problem too ... over the years. I dont use ... AviSynth with scripts to produce my videos ... just too much hassle to mess with.
I recently wanted to take some videos from ... Martina McBride Video Hits DVD [yes I do own it] and convert them to Divx / avi ... format.
But the first program I used was CloneDVD Mobile ... well ... that program does a great job but the audio is VBR ... and not CBR.
When I ran the 58 minute video through Virtualdub to extract the single video segments ... the audio was not in sync ... so I did the usual stuff ... extracted the audio ... converted it to a PCM wav and such and still had problems.
So ... just like a good picture from a 35mm camera is only as good as the negative ... using CloneDVD Mobile was not the best choice for making my avi video.
So I rebooted my PC and started up WIN XP ... and used TMPGEnc 4.0 XPress to create a AVI video of 58 minutes ... and then I used Virtualdub to extract the individual videos from Martina McBride's Video Hits DVD.
The songs I like are ... A Broken Wing - Martina McBride ... Independence Day - Martina McBride ... Whatever You Say - Martina McBride ... When God Fearing Women ... Get The Blues - Martina McBride.
I also sometimes extract the wav file with VDUB and enhance it with Cool Edit Pro 1.2a [OS is WIN 7 Ultimate x64] ... I use the Waves DX plugin to give the song more ... dynamic range and such ... in case the song sounds kind of dull.
I then use that enhanced ... WAV PCM file ... with VDUB to produce the final results.
So ... EasyDrama ... maybe you should try taking the original video file ... you mention MKV at the beginning ... and use a video converter / editing program ... that is of good quality and reprocess it ... knowing that when you do this ... the frame rate will stay at 29.970 and that the audio will be using a CBR instead of VBR.
I realize that we want to avoid re-processing a video if we can ... to keep the video from looking worse but ... your needs and your wants need to be evaluated here.
What would I do ... someone mentioned ... splitting the video into sections ... could try that.
How about using ... ConvertXtoDVD ... and convert the MKV to a DVD in a folder somewhere. Use maximum settings ... DVD-9 and such and then see if the audio is still messed up.
I've used Vegas a time or two in the past ... and when I had bad audio sync ... I could see in Vegas the length of the video and the length of the audio ... and they didn't line up correctly.
Could be that in your video ... somewhere in the middle portion a glitch has taken place [you might be able to see it] where the video for a moment gets screwy looking ... that can be the problem.
I recorded the TV episode ... CSI:Crime Scene Investigation "A Space Oddity" ... it was the episode where two of the lab technicians went to a ... Star Trek convention ... they used a different name for the show but it was ... Star Trek. I used WIN 7 Media Center to record the show in HD and at one spot ... the video stream got jumbled up and I was not able to convert it to a AVI video. Took awhile to find a Video Editing program on my PC that could with brute force ... plow through that bad spot without the converter stopping or having bad audio sync.
Well ... enuff said ... I've given you some ideas ... -
Hey, READING COMPREHENSION BOY - did you READ what I typed into the search box? NOT "Gradual Desynch" but simply "Audio De-synch". You even quoted it .
I did NOT SAY you only searched for 10 seconds. I SAID that it took 10 seconds for me to reveal that YOU did not search very well.
I also DID NOT SAY that you never mentioned the GRADUAL issue, but that almost every de-synch post contains someone asking this question. This should have alerted YOU to the different types of synch issues.
I am not here to hold your hand and wipe your ass for you. You made the first negative comment, you started it, and I will certainly finish it for you if you wish to continue.
I have also given you the answer and how to proceed. Knowing your type, you will most likely continue to whine pitifully like a lost kitty until somebody does it for you. I refuse to hand you a fish, but I will show you how to hold the pole.
Changing the framerate on the ENTIRE VIDEO is NOT repeat NOT the answer. -
Nelson, I guess that lack of comprehension disease that you got is just contagious. Stop spreading it around already. Like I said in my previous post, I didn't use "gradual de-synch" in response to the hundreds of posts addressing "gradual de-synch" issues that YOU mentioned and I didn't notice that you switched "gradual de-synch" to "audio de-synch", which I didn't use in my search either. I guess I was still hung up on how you concluded that I should have used those words as well, since you used it after all and everyone should do like nelson and that's when your disease infected me.
I did NOT SAY you only searched for 10 seconds. I SAID that it took 10 seconds for me to reveal that YOU did not search very well.
I also DID NOT SAY that you never mentioned the GRADUAL issue, but that almost every de-synch post contains someone asking this question. This should have alerted YOU to the different types of synch issues.
I am not here to hold your hand and wipe your ass for you. You made the first negative comment, you started it, and I will certainly finish it for you if you wish to continue.
I have also given you the answer and how to proceed. Knowing your type, you will most likely continue to whine pitifully like a lost kitty until somebody does it for you. I refuse to hand you a fish, but I will show you how to hold the pole.
Changing the framerate on the ENTIRE VIDEO is NOT repeat NOT the answer.
@lacywest
I just got back not too long ago and had no time to read through it all to be honest but it seems very detailed. Thanks for the help and not questioning my effort like someone else. What you said is true. I could have worded it differently but, seeing how nelson didn't feel the need to word the way he questioned my effort differently, neither did I feel the need to word my comment differently either. Even though he was the first to reply, there was no need for him questioning my effort. There really wasn't.
@everyone else that replied so far
I'm been so busy I haven't been able to get around to all of the suggestions yet. I will try to do so within the next week or so. Thanks again! -
This won't solve your script problem but without getting into the cause, the few gradual sync issues I've had were solved this way after the fact:
First I demux the audio and check the reported time length comparing it with the reported length of the video. Whenever I've had a gradual drift the two always differed. I load the audio into an editor like Audacity (in my case the audio has always been an mp3) and apply the "Change tempo" effect. Here you must calculate the length of your audio and video in seconds and change the length parameter so the audio matches the length of the video exactly. The new audio can then be remuxed with the video. If the two are still not in sync it will no longer be a drift issue but simply an alignment problem which can be easily corrected by applying a constant fractional delay to one or the other stream.There's not much to do but then I can't do much anyway. -
Sonny, I get paid to teach people and I am very, very good at it. Your evaluation does not interest me in the slightest, and I don't give a damn what your opinion is. The possibility that you will ever have the answer I need to anything is extremely minimal.
I did not QUESTION your effort. I STATED very clearly that it needed to be better. I could care less that you don't like to be told that your minimal effort just wasn't good enough. The simple fact is, that it wasn't.
I have also already given you the answer to how to solve your problem, and will note that critical information which you left out of your original post totally invalidates most of the suggestions you have been getting.
But then, with the way that you read and fail to comprehend, you will probably need a diagram with pictures and step-by-step instructions, and for somebody like you, I'm just not willing to put forth the effort. Waste of my time. -
I honestly don't care what your evaluation of me is either. People get paid for just about anything nowadays. Just because you get paid to teach, it doesn't mean that you're necessarily any good at it. I suppose if someone who also teaches makes more money than you, they must be considered better at teaching right? I've had teachers in the past who thought they were the oracle of all knowledge but they completely failed in the being a human being department as well as the skills required to teach department. Since everyone is entitled to their opinion on what a good teacher is and so on, I'll leave it at that.
I did not QUESTION your effort. I STATED very clearly that it needed to be better. I could care less that you don't like to be told that your minimal effort just wasn't good enough. The simple fact is, that it wasn't.
I have also already given you the answer to how to solve your problem, and will note that critical information which you left out of your original post totally invalidates most of the suggestions you have been getting.
But then, with the way that you read and fail to comprehend, you will probably need a diagram with pictures and step-by-step instructions, and for somebody like you, I'm just not willing to put forth the effort. Waste of my time.
@gll99
Thank you for the suggestion. That doesn't seem to take very long to do so I might give it a try later as well if nothing else works.
@poisondeathray
I let megui run and re-encode the video using xvid this morning and unfortunately the problem is still present so it doesn't seem to be a x264 issue. I also tried using other muxers and it had the same effect. Either way, at least we ruled out some other possibilities =)
@lacywest
Now that you mention it, there might have been a suddle scene change a little earlier on in the video where the video was a little blocky. The blockiness might just be because of the settings the original file creator encoded the video with but I'll go back and try to find it. If it happens to be a glitch like you say, I might just have to find some time to sit down and edit out those bad frames with avs cutter before remuxing the audio back in or something. It's interesting how the original audio syncs up with the original glitchy video just fine but goes out of sync during the re-encoding process if a glitch happens to be the case. Watching the video carefully and checking for glitches is gonna take some time though. Either way, I'll keep everyone posted when I am able to get around to it. Thank you! -
That's not even true, is it? From the sound of it it's in synch until it hits a certain spot, goes out of synch at that point, and then stays out of synch by the same amount the rest of the way? Is that right?
The video is only about 90 minutes long and it starts to go out of synch around 50 something minutes if I remember correctly.
One answer (if it remains out of synch by the same amount after that 50 minute mark) would be to split the audio at that point, set a proper delay for the second part, and then rejoin them. Either that or, if the out-of-synch really is progressive after that 50 minute mark, stretch the second part and then rejoin them.
It also seems to me you could have figured out the real problem before bringing it to this forum, sending everyone on a wild goose chase, and stinking up the place with your feud with Nelson37 who, in his ornery way, is only trying to help. -
To the op:
My suggestion to you was based on your title and opening comment:
Video lags behind audio as episode progresses.
I have a video that starts off playing fine but, as the the episode progesses, the video will gradually lag behind the audio.There's not much to do but then I can't do much anyway. -
@manano
Thank you for your input. Please do not jump to conclusions though. I am not interested in sending anyone on any kind of chase. Does it start off playing fine like I said? Yes it does. Does it lag as the episode progresses like I said? Yes it does. Not right away and it happens further down the progression but I did not know that something couldn't be classified as a gradual desynch/asynch unless it was immediate. Lastly, no, it does not stay the same for the remainder of the video as originally stated but thank for your solution for that scenario as well.
As indicated in my previous post, I am not the original encoder so I honestly don't know if the blockiness are glitches or were a result of the settings used during encoding. Since I usually do QC on subtitles when working with videos, I wasn't able to focus on the video itself as a whole and it might very well be a glitch. If that is the case, it seems I will have to stretch the 2nd part of the video and as oppose to setting a delay since it really does get worse by the end of the movie. Please understand I am not here to deceive anybody nor did I set out with the intention of insulting anyone. The same applies to your previous responses in my other thread awhile back regarding a different topic.
@gll99
Thank you the update and additional info. I will go back and watch the video and apply the right solution accordingly when I get the chance.
Similar Threads
-
Enable GPU acceleration in VLC for sure? (Or: Video lags behind audio)
By Asterra in forum Newbie / General discussionsReplies: 8Last Post: 7th May 2011, 08:21 -
Video lags when playing 720p or 1080p videos without DXVA support
By white_snake in forum Software PlayingReplies: 11Last Post: 28th Nov 2010, 06:11 -
I pop in my dvd's, it starts to play, the video/audio lags
By rko2164 in forum ComputerReplies: 5Last Post: 11th Jan 2010, 20:53 -
Video lags
By warjo in forum Software PlayingReplies: 4Last Post: 7th Oct 2008, 15:09 -
video lags after converting
By allie in forum Video ConversionReplies: 1Last Post: 20th May 2007, 22:16