VideoHelp Forum




+ Reply to Thread
Page 2 of 3
FirstFirst 1 2 3 LastLast
Results 31 to 60 of 62
  1. Is the fps correctly detected/set for encoding (i.e. exactly 50 fps)? Look into your encoding log.

    Otherwise maybe the m2ts files are broken or something (vfr/gaps)? Though that isn't really typical for camera recordings...
    Things you could try: replace "LWLibavVideoSource(filename)" with "LWLibavVideoSource(filename, fpsnum=25, fpsden=1)"
    Or:
    Replace LWLibavVideoSource(filename)" with "FFVideoSource(filename)" and
    replace LWLibavAudioSource(filename)" with "FFAudioSource(filename)"
    Or:
    Replace LWLibavVideoSource(filename)" with "FFVideoSource(filename, fpsnum=25, fpsden=1)" and
    replace LWLibavAudioSource(filename)" with "FFAudioSource(filename)"

    (non-free alternative source filter: http://rationalqm.us/dgdecnv/dgdecnv.html)
    Quote Quote  
  2. Also try threads=1 in the source filter . Sometimes l-smash and ffms2 have issues threading



    Different length A/V is a common problem with camcorders (the metadata in the folder structure ensures seamless join) . If you attempt to join as-is you will go out of sync . You should be able to determine that right away with a A+B+C+D+E script .

    There is a program by neuron2/donald graft/videoh called "joints" that attempts to address this if you don't have the intact folder structure. It's worth a try
    https://forum.doom9.org/showthread.php?t=149441

    Otherwise I would try to edit the clips in an editor so they line up perfectly before joining (but if you're doing this you might as well just use the editor)

    When using avs, always try joining using the script before. You can test for AV sync by playing the script before wasting hours or days encoding. You have other issues about playback (old hardware), but I mean as a general rule. Never join after - it reduces your chances because you also introduce other variables. Not all videos will "join" afterwards successfully. Your chances increase if you use --stitchable (if using x264) , but even that isn't necessarily 100% successful .
    Quote Quote  
  3. @sneaker: Yes, the video 50 fps is correct in the log. The problem seems to be with the audio, as the resulting video lenght is IDENTICAL to the input.
    @poisondeathray: I'm gonna try what you said. I've previously successfully joined MP4 files (yesterday I joined 3x1080p 30fps files encoded with MeGUI, but the source wasn't m2ts/camcorder) using this ffmpeg batch:
    Code:
    ffmpeg -i 1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
    ffmpeg -i 2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
    ffmpeg -i 3.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate3.ts
    ffmpeg -i "concat:intermediate1.ts|intermediate2.ts|intermediate3.ts" -c copy -bsf:a aac_adtstoasc output.mp4
    pause
    . It works without any issues, no errors, you can try it if you want, it is a very good and fast way to join MP4 files losslessly.
    Quote Quote  
  4. Yes, the ffmpeg concat protocol method is very good too . But it's actually better to use the concat demuxer method with ffmpeg , which joins at the stream level, not container level
    https://trac.ffmpeg.org/wiki/Concatenate

    It works where some other methods fail. But the only 100% reliable method for spanned camcorder videos is with the folder structure
    Quote Quote  
  5. Originally Posted by bloodhand View Post
    Code:
    LoadPlugin("D:\Programs\Prelucrare Filme\MeGUI\tools\lsmash\LSMASHSource.dll")
    Load_Stdcall_Plugin("D:\Programs\Prelucrare Filme\MeGUI\tools\avisynth_plugin\yadif.dll")
    function VideoAndAudio(string filename)
    {
      v = LWLibavVideoSource(filename) # get video
      a = LWLibavAudioSource(filename) # get audio
      AudioDub(v,a) # join them
    }
    
    v1 = VideoAndAudio("in1.m2ts") # get video and audio of each source clip
    Yadif(mode=1, order=1)
    # other filtering goes here
    That script won't get you anything but an error. But assuming you fix that and still have A/V sync errors -- what exactly is the nature of the error? Is it in sync at the beginning? Is it in sync for a while then suddenly get out of sync? Does the sync start out OK but get progressively worse? All of these problems can be addressed one way or another. But the fix is different for each.
    Quote Quote  
  6. I said it in my other posts: it is in sync at around 00:15:00 of the video (where there is talking and I cand identify sync) and it is out of sync at about 00:30:00, but it is in sync again at the end, about 00:55:00. It seems it's ok at the beginning and at the end, but it gets out of sync in between, but no progressive pattern.
    Quote Quote  
  7. So, muxing the encoded MP4 file with the original AC3 audio stream from the m2ts (Dolby AC3) with mkv toolnix no longer gives sync issue. So, the problem is the encoded audio. Somehow, 1 second gets erased, therefore desync appears on certain areas. I didn't accoplish to extract the ac3 stream from the m2ts and encoding it with any tool is giving 1 second loss. If I could find a way to have the full audio lenght, I could encode video with MeGUI and then mux it with the full lenght encoded audio. Let's see what tsdemuxer does and if the ac3 resulted file has full lenght.

    BTW, I forgot to say: clips are not the original from the camcorder, as it has an introduction at the beggining and each part is faded-out to black at the end and some random writing appears from time to time. So, it's not the original stuff.
    Last edited by bloodhand; 9th Feb 2017 at 11:50.
    Quote Quote  
  8. tsdemuxer says this (for the 1st of the 5 files):
    pid=4113 (0x1011), ch=1, id=1, type=0x1b (264), stream=0xe0, fps=25.00, len=3548720ms, fn=88719, head=+31ms, tail=-0ms
    pid=4352 (0x1100), ch=1, id=2, type=0x81 (ac3), stream=0xfd, fps=31.25, len=3548752ms, fn=110860

    What should I do next?
    Quote Quote  
  9. Originally Posted by bloodhand View Post
    I said it in my other posts: it is in sync at around 00:15:00 of the video (where there is talking and I cand identify sync) and it is out of sync at about 00:30:00, but it is in sync again at the end, about 00:55:00. It seems it's ok at the beginning and at the end, but it gets out of sync in between, but no progressive pattern.
    That is just one of your source clips or all five joined together? Assuming just one clip, it can't be fixed by remuxing or a stream fixer, and you can identify exactly where the audio goes out and where it comes back into sync (or it doesn't matter exactly where) , here's one way you could address it in AviSynth:

    Code:
    LoadPlugin("D:\Programs\Prelucrare Filme\MeGUI\tools\lsmash\LSMASHSource.dll")
    Load_Stdcall_Plugin("D:\Programs\Prelucrare Filme\MeGUI\tools\avisynth_plugin\yadif.dll")
    function VideoAndAudio(string filename)
    {
      v = LWLibavVideoSource(filename) # get video
      a = LWLibavAudioSource(filename) # get audio
      AudioDub(v,a) # join them
    }
    
    v1 = VideoAndAudio("in1.m2ts") # get video and audio of each source clip
    
    p1 = v1.Trim(0,999) # the first part of the video, audio in sync
    p2a = v1.Trim(1000, 1999) # the second part of the video with the audio delayed by 1 second
    p2b = v1.Trim(1025, 2024) # audio from 1 second later 
    p2 =  AudioDub(p2a, p2b) # video from p2a, audio from p2b, ie audio from p2b moved forward 1 second
    p3 = v1. Trim(2000,0) # end part of video
    
    v1 = p1++p2++p3
    
    Yadif(v1, mode=1, order=1)
    Of course, there may be obvious audio discontinuities at the trim points.
    Quote Quote  
  10. This is just for one clip. I don't want to do any cutting, unfortunately.
    Having the info from tsdemuxer, my bet is to resample audio to 25fps. But what's with the "head=+31ms, tail=-0ms" on the video? Does this mean +31ms delay at the start and this delay goes down until 0ms at the end of video?
    Quote Quote  
  11. I converted original ac3 to wav, then changed the tempo to obtain an equal lenght to the encoded video, saved it, converted it to aac, now muxing with video. I will test, I surely hope this was it.
    Quote Quote  
  12. Originally Posted by bloodhand View Post
    I converted original ac3 to wav, then changed the tempo to obtain an equal lenght to the encoded video, saved it, converted it to aac, now muxing with video. I will test, I surely hope this was it.
    Why would that help? You said the audio is in sync at the start and end but out of sync in the middle. So the total length of the audio isn't the problem.
    Quote Quote  
  13. I don't know, because I can't really tell when it gets out of sync as I can only check in certain places in the video file, where there is talking and speaker's face is on the screen. But it didn't work anyway.

    I'm trying to switch to MediaCoder to see if I will get the desired results.
    Quote Quote  
  14. Seems you're just tyring a bunch of things out randomly but none of them are probably going to work

    Are these problems really there? Or did one of the suggestions actually work and you just don't know it ? How "old" is your equipment ? What is it exactly?

    If you cannot playback 1080p50 correctly , how are you diagnosing "sync ?"

    You might repeat the tests but encode with SD. Something like 640x360 to be sure. Just to test if there is an issue in the first place.


    How to do this? What to use to open avs files for playing?

    LE: Never mind, I figured it out. But I can't check, as the bitrate is very high and my CPU cannot play it fluently. I have a pretty old equipment, I had to wait 24h for 1h12m10s 1080p 50fps encoding... But this is all I have. I will try to open avs without yadif in the script.

    LLE: No, the sync issue is present within the .avs too. Wish I knew this in the first place - 24h wasted. I will try to open the MP4 I created from M2TS and check.
    Quote Quote  
  15. I have an Intel Core 2 Duo T5500 1,66GHz. I'm testing on MPC-HC with overlay and it doesn't lose frames anymore. I also test on a 1080p TV with my HDD connected on it's USB port.

    I will redo everything again in 360p and post results. I'm pretty tired right now so it's a mess in that folder: will delete everything and redo.
    Quote Quote  
  16. Many TV's don't support 1080p50/60 . It's AVC L4.2. Most TV sets only support AVC L4.1

    Maybe consider 1280x720p50 for the final version. That's more compatible with devices, (if encoded properly, blu-ray). That will help your playback and your goal to use lower bitrates with fixed media capacity goals
    Quote Quote  
  17. For those lower resolution tests, I would even consider lower than 360p (but enough that you can see mouths move and assess sync) and single rate deinterlacing to 25p, and using ultrafast preset. You only want to determine if there is a problem in the first place. Half the number of frames and reduced frame size with ultrafast should be much faster for encoding
    Quote Quote  
  18. Well, I cleaned up and started from scratch. Audio was still shorter when using m2ts as input. So i losslessly converted m2ts to mp4 using ffmpeg. Now, when opening the mp4 in MeGUI, audio is the same lenght as video. I encoded only audio to QAAC and muxed it with the input MP4 video, which is original interlaced video. I did this because my TV automatically deinterlaces the original video and this ensures smoothest playback. Audio seems to be approx. in sync with video. The desync that still happens in some middle areas MIGHT have to do with the lag the TV may do, maybe because those areas have higher bitrate.

    To be sure of it, the next step will be to encode the video to 360p 25fps with ultra fast preset and test on the notebook with both version of the encoded audio: the shorter one as well the same lenght one. Remains to be seen if desync still occurs and which is the best of the two.

    After that, I plan to encode each part to 1080p 50fps, because the videos are intended to be played only on PC/notebook (but for sure a newer equipment), then merge them with ffmpeg concatenate, then split to desired sizes calculated before. For the TV, original m2ts can be used from external HDD or USB flash, because the TV does the deinterlacing on-the-fly, therefore any framedrops are avoided. I don't think it's a good idea to make another interlaced compressed version, because the lower quality may affect interlaced fields' horizontal lines.
    Quote Quote  
  19. Now, further testing with 360p shows that actually the sound desyncs gradually until the end, approx. 500ms before the video at the half and approx. 1000ms before the video at the end of the video. Doesn't matter if I use the shorter or the same lenght audio file. I guess I should do something with the audio file, to stretch it so it gets 1000ms at the end, this will gradually increase the timing of the audio since the beggining. So what I'm gonna try is to encode the sound to wave, edit it and stretch it with x ms, then load as external audio and test on-the-fly also adjusting delay.
    Last edited by bloodhand; 10th Feb 2017 at 09:05.
    Quote Quote  
  20. OK, so first I tried stretching the audio to make it the same size as the video. This now gives me perfect sync at the end, but now audio is ahead of video at the beggining and gradually gets in sync until the end. Now I've got it: I have to stretch the audio more. Of course, now it's very clear I have to delay the entire audio to make it sync after the stretch. I will now do the testing by trial and error, I've got no other options than stretch the wav and load as external audio in player along 360p footage. Then sync by delaying audio on-the-fly at the beggining and then test middle and end to see if the same delay is ok for that. If not, I have to readjust the stretching and find the ideal stretch size + on-the-fly delay to obtain sync everywhere. After that, I will encode the wav to aac adding the delay in MeGUI and muxing at the end.
    Last edited by bloodhand; 10th Feb 2017 at 09:22.
    Quote Quote  
  21. AviSynth:
    DelayAudio()
    TimeStretch()

    Pretty much any dual core CPU can play a script like this in real time:

    Code:
    v = LWLibavVideoSource(filename)
    a = LWLibavAudioSource(filename)
    AudioDub(v,a)
    TimeStretch(...)
    DelayAudio(...)
    It would be much simpler and faster to make your audio adjustments this way.
    Quote Quote  
  22. Thanks for the tip, I will try that, with tempo substring.

    LE: It was easier than I thought and my initial beliefs were true. I only had to stretch the audio to the video's lenght (I did this before using audacity, but I probabbly loaded the wrong external wav file). The string was:
    Code:
    TimeStretch(tempo=(100.0*3547.52)/3548.76)
    3547.52 = orignal audio time (in seconds)
    3538.72 = original video time (in seconds)
    I no longer needed to use DelayAudio().

    I guess I can use this avs as input for the MeGUI conversion. I believe the same TimeStretch settings will work for all parts.
    Last edited by bloodhand; 10th Feb 2017 at 10:59.
    Quote Quote  
  23. That doesn't jibe with your earlier claim that the audio of a single segment was in sync at the start, off in the middle, then in sync again at the end. This is why I asked you to describe precisely how the audio was out of sync in the individual clips.
    Quote Quote  
  24. Yes, that's my bad, I'm very sorry. It is because i was playing 1920x1080px50fps which my machine couldn't handle properly and because of video framedrops and delayed playing, it made me thought it was in sync at the beggining and at the end. But with 360p, everything was clear enough. And because my first encoding included a part from the first m2ts and one from the second m2ts, so the end was actually the beggining of second m2ts and all begginings have audio in sync with video.
    Last edited by bloodhand; 10th Feb 2017 at 11:11.
    Quote Quote  
  25. Now what's your recommendation:
    1) Encode each m2ts with the updated avs script for timestretch of audio, then merge the 5 outcoming mp4 and split into the 4 desired files?
    or
    2) Load all 5 files merged as with the initial script, with the same timestretch already applied in the avs for each audio (assuming it is the same for al clips) and create 4 separate cutted avs for each final part? Of course, this means to first load each m2ts separately and compare audio and video lenght to see if the same timestrech will fit.
    Last edited by bloodhand; 10th Feb 2017 at 11:15.
    Quote Quote  
  26. I'd check the audio of each segment and adjust it accordingly. Then load them all into one script and check the sync. If all is OK I'd encode the script.

    Code:
    function VideoAndAudio(string filename)
    {
      v = LWLibavVideoSource(filename) # get video
      a = LWLibavAudioSource(filename) # get audio
      AudioDub(v,a) # join them
    }
    
    v1 = VideoAndAudio("file1.m2ts").TimeStretch(...).DelayAudio(...) # stretch and delay as necessary
    v2 = VideoAndAudio("file2.m2ts").TimeStretch(...).DelayAudio(...)
    v3 = VideoAndAudio("file3.m2ts").TimeStretch(...).DelayAudio(...)
    v4 = VideoAndAudio("file4.m2ts").TimeStretch(...).DelayAudio(...)
    v5 = VideoAndAudio("file5.m2ts").TimeStretch(...).DelayAudio(...)
    
    # to check an individual segment enable the next line, change v1 to v2, etc.
    # Return(v1)
    # if you enable the above line the rest of the script won't be executed
    # and you should be able to play (no need to encode) the script to test it.
    
    v1++v2++v3++v4++v5 # join all five
    Yaddif(mode=1, order=1) # or whatever
    One thing I'm not sure about is how good the quality of AviSynth's TimeStretch() function is. I recommend you compare it to Audacity() or whatever other alternatives you have.
    Quote Quote  
  27. This is what I've thought it's the best option, especially that I already have the encoded video of the first of the 4 parts.

    And it's the best option because for the 2nd part, the lenght difference between audio and video is not right the same as the 1st part.
    Last edited by bloodhand; 10th Feb 2017 at 13:39.
    Quote Quote  
  28. Many, many thanks to all who gave me a hand in order to figure out the issue. Also, thanks for the patience and really wishing to help. I've opened each part separately to calculate the video and audio lenght, then added all data to the main script and it's working with no issues. I've finished the 2nd part already and everything is fine.
    Quote Quote  
  29. It sounds like you are converting each source file one by one. If you disable the Return() line in the earlier script you can encode them all at once into one big file.
    Quote Quote  
  30. No, I don't. I'm using all the 5 inputs to directly obtain the 4 desired outputs. I only used separate inputs to calculate timings for the stretch...
    Quote Quote  



Similar Threads

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