VideoHelp Forum
+ Reply to Thread
Results 1 to 18 of 18
Thread
  1. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    I have a consistent audio sync error after encoding MPEG to MP4/MKV video files using MeGUI.X264 encoding using the latest versions available. I am trying to encode a 25 fps PAL movie with 720x576 frame size and AC3 audio as a source to produce either MP4 or MKV output of similar dimensions but with AAC encoding.

    As the encoded MP4/MKV movie plays, the audio gets increasingly out of sync with the video. At the start the movie is in sync but, after 90 minutes or so, the audio is 0.25 seconds ahead of the video making the movie unwatchable.

    Note: I am using X264 encoding with fairly standard settings and Nero AAC for sound encoding.

    I get the same results on two different computers and three different MPEG video sources.

    I have tried removing an reinstalling MeGUI and also using both the Stable and Development threads all with the similar out of sync results.

    As far as I am concerned this is a major error as it has put a total stop to all my video encoding for the moment.

    I haven't any clue what could be wrong or how to fix this - any advice or assistance would be much appreciated.

    BTW: I have done some testing myself to see if I can find out why this problem is occurring. The following test results does shed some light on this problem though: If I take the MP2 audio stream demuxed from the original MPEG movie and mux this together with a newly encoded .264 video then the movie IS STILL out of sync as with the final MP4/MKV version. That is, an untouched audio file does not sync any better with the recently encoded .264 file than the .aac version. This indicates to me that the problem is NOT with the audio encoding process but rather with the X264 encoder itself.
    Quote Quote  
  2. Originally Posted by Cyberpro60 View Post
    This indicates to me that the problem is NOT with the audio encoding process but rather with the X264 encoder itself.
    It's probably not x264, rather the pre processing megui is using before it touches x264

    Did you decrypt the DVD ? Is the MPEG2 source in sync ?

    Post the log file

    Add audio to the avs script (e.g. using AudioDub() ), and preview the script with audio in a media player - is it in sync ?
    Quote Quote  
  3. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    Thanks poisondeathray for your quick response.

    To answer your questions:

    1. The source was not DVD - it was PAL Digital TV.
    2. The original source was recorded in .ts format afterwards extracted to .mpg. Both formats were in sync from start to finish.
    3. Please see logfile attached. logfile-13-06-06_18-39-24.log
    4. I haven't tried the mediaplayer test as yet but I will do so shortly and post results.
    Quote Quote  
  4. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    I experimented with using an avs file including audiodub() but I could not get this to work at all.
    There was sound but it was running at breakneck speed - totally unsynced with the video.
    I don't know enough about the audiodub function to make it work properly - any suggestions as to how to modify the standard .avs script from MeGUI to make this test work?
    Quote Quote  
  5. I've not encoded much in the way of ts files containing mpeg2 myself, but the first thing I'd check is whether the output video has the same number of frames in total as the input video. If not, maybe frames are being dropped, or the original video has missing/repeated frames which aren't being encoded.

    One way to test this might be to open the AVIsynth Script Creator and select the ts or mpeg file as the input video. MeGUI should ask how you want to open the video. Select DirectShowSource.
    When the video opens you'll see MeGUI has added frame rate conversion to the script. It should look something like this:

    DirectShowSource("E:\video.ts", fps=25.000, audio=false, convertfps=true).AssumeFPS(25,1)

    Check the number of frames and video duration at the top of the preview window. Delete the part highlighted in brown above from the script, click on the preview button and check the video duration/frame count again. If it changes, the first one is likely to be correct. You could then open the video again with MeGUI using the file indexer and check the frame count/duration to see if it's correct/consistent.

    If you still have the original ts files try opening those rather than the extracted mpeg2 video to see if anything changes.
    Quote Quote  
  6. You have an AV mismatch (different audio & video lengths) , this causes progressive desync that you are observing

    ----[Information] Format: MPEG Audio
    ----[Information] FormatString: MPEG Audio
    ----[Information] FileSize: 223382784
    ----[Information] PlayTime: 01:56:20.712


    ----[Information] Format: MPEG-4
    ----[Information] FormatString: MPEG-4
    ----[Information] FileSize: 1256160729
    ----[Information] PlayTime: 01:56:21.080

    01:56:20.712 vs. 01:56:21.080


    It's not clear from the log what the underlying cause is, it might be from the source filter you used for the audio; You might try FFAudioSource() instead of NicMPG123Source

    or you can try hello_hello's suggestion to use DirectShowSource()

    If this is your original script ,

    Code:
    DGDecode_mpeg2source("C:\Temp\The X-Files (1998).d2v", cpu=4, info=3)
    LoadPlugin("C:\Program Files (x86)\Video\MeGUI\tools\avisynth_plugin\ColorMatrix.dll")
    ColorMatrix(hints=true, threads=0)
    #deinterlace
    crop(4, 10, -4, -4)
    LanczosResize(720,576) # Lanczos (Sharp)
    global MeGUI_darx = 16
    global MeGUI_dary = 9
    To include audio in the script , add the following lines

    Code:
    vid = last
    aud = FFAudioSource("C:\Temp\The X-Files (1998) Tc0 L2 2ch 48 256 DELAY 0ms.mp2")
    AudioDub(vid,aud)
    Save the script with a different name, e.g. "test.avs", and play the script in a media player . For testing sync , it's usually a good idea to comment out ("#") all other filters, like crop, resize, etc.. because they don't affect sync, but might affect the playback (eg. if you have slow filters) thus affect interpreting your testing results . If that script is in sync , then use the same script to encode audio (don't load audio directly into megui)
    Quote Quote  
  7. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    Thanks for the feedback folks. There are a few things that I will need to try out here and I will experiment and report back.

    Note: I can't go back and test the original .ts file as hello_hello suggests as this file had advertising breaks which I have since edited out to create my final mpeg file. The .ts file was then deleted. Note however that, as indicated earlier, the audio/video was in sync in both versions of these files.

    It is worth noting also that tests with Handbrake and AviDemux produced final mp4/mkv files with the audio/video in perfect sync from start to finish.

    Other tests I did showed that there were the same number of frames in the source MPEG and output .264 files (plus or minus 1 frame) so dropped frames does not seem to be an explanation for the time differences. Any ideas why MeGUI is reporting differences in the time-lengths of the audio and video files though as they should be the same?
    Quote Quote  
  8. You can also try use DirectShowSource() on the .mpg

    How did you arrive at the framecount? With the x264 log file ? or other method

    What was the frame count in the avidemux or handbrake encoded videos ? How did you arrive at the framecount ?

    Different source filters will sometimes come out will different results. You used DGIndex in megui. Avidemux and handbrake use libav / ffmpeg. So depending on how you open the video, you might get different framecounts for the same h.264 or mpeg2 video.

    But x264 will always yield the exact number of encoded frames in the log - this is the one thing that will for certain be accurate . But if you feed x264 a different number of frames - it can only encode what it receives as input (ie. the problem isn't x264)

    Same with the audio, different audio source filter might come out with slightly different number of audio samples

    What was the play time in the edited .mpg for the audio & video each ? use mediainfo (view=>text, debug=> advanced mode) . This also reports a frame count, but it might be different than say, when you indexed the video with megui
    Quote Quote  
  9. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    Some test results:

    Using the modified MeGUI avs file that you suggested (ie including FFAudioSource line) produced an output with the exact same progressive audio sync problem already mentioned.

    I am currently encoding another MeGUI mp4 output version using FFAudioSource() instead of NicMPG123Source for the audio as suggested however I am not holding out much hope that this will resolve the problem given the .avs test already discussed.

    I haven't check the data using MediaInfo but I will do that also and report the results here too.

    BTW: I obtained the frame count from both versions using Apple's QuickTime Player. This is a useful little trick that I picked up - if you load a video file into the Quicktime player and click on the time line reporting you can change that to a very accurate frame counter.
    Quote Quote  
  10. Originally Posted by Cyberpro60 View Post
    Some test results:

    Using the modified MeGUI avs file that you suggested (ie including FFAudioSource line) produced an output with the exact same progressive audio sync problem already mentioned.

    I am currently encoding another MeGUI mp4 output version using FFAudioSource() instead of NicMPG123Source for the audio as suggested however I am not holding out much hope that this will resolve the problem given the .avs test already discussed.
    The reason why I suggested testing the .avs in a media player for sync - is so you don't have to waste time encoding just to check if it's in sync (you end up wasting a lot of time each time you do 1 change)

    You can also add info() to the end of the script (preview in vdub or avspmod) and it will report the frame count, and audio samples - this way you can check different source filters

    If there wasn't a difference in the encoded video frames between megui's vs. handbrake / avidemux's output, the problem is the audio , or the muxer used by megui

    Before you even encode, there is a reported AV mismatch, so unless you fix that, everything you get will be out of sync
    Quote Quote  
  11. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    Thanks poisondeathray and others for your posts to date.

    BTW: I have conducted some more testing and, frankly, I am getting even more confused about what I am finding out.

    First up, taking your suggestion poisondeathray I amended the standard MeGui script to use Directshow as per the following .avs script:

    DirectShowSource("XFiles.mpg")
    LoadPlugin("C:\Program Files (x86)\Video\MeGUI\tools
    \avisynth_plugin\ColorMatrix.dll")
    crop(4, 10, -4, -4)
    LanczosResize(720,576) # Lanczos (Sharp)
    global MeGUI_darx = 16
    global MeGUI_dary = 9
    vid = last
    aud=DirectShowSource("XFiles.mpg")
    AudioDub(vid,aud)
    info()

    The video info displayed the following information:

    Video Frames: 174526
    Video Time : 1:56:21:040
    Audio Time : 1:56:21:040

    ie Audio and Video are both the same length.

    As you predicted, when you play this .avs file in MPC you get a video with audio/video in perfect sync from start to finish.
    You would naturally expect that if you use this same .avs file in Megui to compile both XFiles.mpg->XFiles.264 and XFiles.mp2->XFile.m4a and then mux them together using MeGUI that you would get a final .mp4 video that is in sync. Unfortunately that's not what I got. Towards the end of this video the audio progressively is drifts ahead of the video! Not by a lot mind you but still quite disconcerting. Go Figure this if you can!

    Likewise, if I transfer the same files to another machine (both running Windows 7 64 bit) and run the same exercise, I get a different set of data:

    MACHINE 2:

    Video Frames: 174525
    Video Time : 1:56:21:000
    Audio Time : 1:56:20:979

    Note that on machine 2 the same video file apparently has one frame less that the same file on Machine 1. Also, the length in time of both audio and video components is also different. Machine 1 Video was 1:56:21:040 but Machine 2 is 1:56:21:000. Unlike Machine 1 the times on Machine 2 were different also. Machine 2 audio time was 1:56:20:979.

    How can the same file produce such different results on two different machines when the same technique is used in both circumstances? Seems illogical to me. Compiling on machine 2 produced a video with audio/video slightly more out of sync than on machine 1 too.

    I seem to be gathering a load of interesting information but I am no closer to getting MeGUI to compile MP4/MKV files that I can use. What next folks?
    Quote Quote  
  12. For the machine #1 test, try a different muxer, like an old version of mkvtoolnix (v4.0)
    Did you use that same avs as input into the audio section for megui ? (or did you forget and load audio directly) ?
    Can you upload that log file from that run ?
    Could this be a playback problem ? Test other players e.g. vlc, smplayer, potplayer

    DirectShow is dependent on system installed codecs (so it might produce different results between systems) . BTW you don't need audiodub() with directshowsource() , just use audio=true (which is defalt)
    e.g.
    DirectShowSource("video.mpg", audio=true)

    Also directshow isn't necessarily frame accurate (it can cause problems when you do non linear seeks , such as will temporal filtering, as you can "lose your place" , and get mixed up frames) . It should be fine if you encode linearly. But for these reasons, it's normally only used as a last resort
    Quote Quote  
  13. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    @poisondeathray: You asked did I use the same .avs input for the audio section of MeGui. The answer to that is yes - I used the same file for both video and audio - and still got playback sync problems after encoding as indicated earlier. Maybe, as you suggest, a different muxer may resolve this issue - or perhaps it is a playback problem. I will also try a few different players too and get back with the results.

    Here is the log file you requested:

    It still seems to me that there is a fundamental problem with MeGUI if it can't produce in-sync audio/video though where Handbrake and AviDemux can - how do we fix this - manually editing the MeGUI avs scripts to tweak a proper encode doesn't seem like a very practical solution.
    Image Attached Files
    Quote Quote  
  14. Nobody is forcing you to use megui . Feel free to use handbrake or dozens of other GUIs. I certainly don't use megui or any gui anymore, but if there is a bug, maybe this info will help the developers fix it

    When I did use megui frequently, I always used the development server , it always had the newest patches and updates, I suggest you do the same (you can change it in the options)

    Interesting that there is a delay detected when you use the indexer (without the avs file, when you did it "normally"), but there was no delay written into the audio filename by DGIndex (I'm wondering if this is all a muxing problem)
    ----[Information] Delay: 200.000

    BTW if you learn how to make your own scripts and use avs input directly, you don't even need to waste time using the script creator or analyzing the file




    Anyways, the problem this time seems to be the audio encoding, there is a ~60ms difference between what it should be. Not sure why
    The video is perfect, matches the script

    This is what it should be
    ----[Information] PlayTime: 01:56:21.0400000

    Encoded video is perfect
    ---[NoImage] encoded 174526 frames
    because 174526 frames / 25 fps = 6981.04 s = 01:56:21.0400000

    Encoded audio duration is different by about 60ms
    ---[Information] File: E:\VIDEO\Movies Mpg\XFiles - audio.m4a
    ----[Information] PlayTime: 01:56:21.099

    Many encoders like Nero pads the beginning of the file , this is known, but I don't know if it's responsible for your observed sync issues . Different muxers can make a difference. For example , certain mp4box builds sometimes causes problems in my experience (and there are a bunch of threads on this topic at doom9). L-smash seems to be more stable. But muxing with an old stable MKVMerge build (e.g 4.0, should rule out these problems - if the sync is fixed , you have your answer, and if it's not, it's likely an audio encoding problem, not muxing) . Newer mkvmerge builds might cause problems seek corruption issues with certain players (this is known too)

    Sorry, Not sure why this is happening - You can also try posting in the megui thread at doom9 forums
    Last edited by poisondeathray; 7th Jun 2013 at 10:14.
    Quote Quote  
  15. I had a similar problem and i fixed with Xillisoft

    produccion de video y audio
    Quote Quote  
  16. Member
    Join Date
    Jan 2011
    Location
    Adelaide, Australia
    Search PM
    G'day,

    I found Freemake Video Converter was one of the few that would handle Aussie DTV .ts input & not loose A/V sync when transcoded to mkv... no need to transcode to mpg first. If you aren't committed to MeGUI, maybe give it a try.

    Hope this helps.

    Regards,

    Phil.
    Quote Quote  
  17. Member
    Join Date
    Sep 2006
    Location
    Australia
    Search Comp PM
    @poisondeathray

    Thanks for all your suggestions and input. This was much appreciated.

    First, I will be referring this problem to the Doom thread as you suggested as I really do like the MeGui interface better than almost all of the other X264 GUI's out there besides I would like this problem fixed.

    Second, I was using the Development thread when this problem first emerged. It was only after some testing that I went back to the stable editions to see if this was a problem introduced only in the development thread.

    Regarding your suggestions to abandon using Gui's altogether, I would be keen to get some pointers on how to do that.
    I gather you must used some sort of standardized script to achieve this but I am not sure exactly how you can handle encoding a list of video files that way.

    @the mariner

    I haven't encountered Freemake before today so I will download it and give try it out.

    BTW: I don't mind Handbrake but it is very clumsy in the way it handles some things and is much less usable than MeGUI. I particularly dislike the facilities for cropping video files. I find myself loading the video file into Megui first in order to work out the cropping levels and then plugging those values into Handrake for the final encoding. Likewise, the ability to use filters in Handbrake is particularly limited.
    Last edited by Cyberpro60; 10th Jun 2013 at 12:39. Reason: omission
    Quote Quote  
  18. this has happened to me as well.the problem is (i think) the muxing.
    meGUI and other program such as mkv merge is sometime giving you this failure product for audio being not sync.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!