Log in

View Full Version : How to fix this source? Audio gets out of sync (Skipping frames or something)


twazerty
17th January 2010, 21:49
I have a mkv with a videoerror. Playing the mkv file with mpc goes perfect. But you will see a videoerror. When I mux it to m2ts with tsMuxer you see that the audio gets out of sync on the moment the videoerror appears. The reason I posted this in Avisynth section is because the source needs to be reencoded and then muxed to tsMuxer. But after I encoded it with x264 (Avisynth/ffdshow used) and muxed to m2ts the audio is still out of sync. I tried it with my own AVCHDCoder and with RipBot264.

Source:
25fps 1280x720
Target:
23.976fps 1280x720

How can I deliver x264 a stream without a hickup? How to "fix" it in avisynth? (Note that the source plays without getting out of sync)

I created a sample for you: http://www.mediafire.com/?l1timzmzjdt (16MB)

This is my log:
21:35:13 Demuxing with MKVExtract: "E:\NetBeansProjects\AVCHDCoder\Tools\mkvtoolnix\mkvextract.exe" tracks "D:\Controleren\Source.mkv" 2:"K:\AVCHDCoder Temp\Sample - item 1\Sample 1.ac3"
21:35:14 Calculated bitrate: 17616
21:35:14 Total Subtitles size: -1.0
21:35:14 Creating AVS file: DirectShowsource("D:\Controleren\Source.mkv",fps=25.000,audio=false).ConvertToYV12().ConvertFPS(23.976).addborders(0,0,0,0)
21:35:14 Encoding Pass 1: "E:\NetBeansProjects\AVCHDCoder\Tools\X264\32bit\x264.exe" --pass 1 --vbv-bufsize 18000 --vbv-maxrate 18000 --bitrate 17616 --level 4.1 --stats "K:\AVCHDCoder Temp\Sample - item 1\Sample.stats" --keyint 24 --min-keyint 2 --ipratio 1.1 --pbratio 1.1 --fps 23.976 --sar 1:1 --weightp 0 --nal-hrd --aud --output NUL "K:\AVCHDCoder Temp\Sample - item 1\Sample.avs"
21:35:34 Encoding Pass 2: "E:\NetBeansProjects\AVCHDCoder\Tools\X264\32bit\x264.exe" --pass 2 --vbv-bufsize 18000 --vbv-maxrate 18000 --bitrate 17616 --level 4.1 --stats "K:\AVCHDCoder Temp\Sample - item 1\Sample.stats" --keyint 24 --min-keyint 2 --me umh --direct auto --psy-rd 1.0:0.25 --ipratio 1.1 --pbratio 1.1 --fps 23.976 --sar 1:1 --weightp 0 --nal-hrd --aud --output "K:\AVCHDCoder Temp\Sample - item 1\Sample.264" "K:\AVCHDCoder Temp\Sample - item 1\Sample.avs"
21:36:29 Creating META file: MUXOPT --no-pcr-on-video-pid --new-audio-pes --avchd --vbr --custom-chapters=00:00:00.000;00:00:21.647 --vbv-len=500
21:36:29 Creating META file: V_MPEG4/ISO/AVC, "K:\AVCHDCoder Temp\Sample - item 1\Sample.264", fps=23.976, level=4.1, insertSEI, contSPS
21:36:29 Creating META file: A_AC3, "K:\AVCHDCoder Temp\Sample - item 1\Sample 1.ac3", timeshift=23ms, lang=und
21:36:29 Muxing with TsMuxer: "E:\NetBeansProjects\AVCHDCoder\Tools\tsMuxeR_1.10.6\tsMuxeR.exe" "K:\AVCHDCoder Temp\Sample - item 1\Sample.META" "K:\AVCHDCoder Temp\Sample - item 1"

Inspector.Gadget
17th January 2010, 22:04
Start over from the original disc, it will be way less of a pain in the neck.

twazerty
17th January 2010, 22:27
Start over from the original disc, it will be way less of a pain in the neck.

Not possible because this was an DVB-S recorded stream. Also people can throw all kinds of files to AVCHDCoder. In want to update AVCHDCoder so it can deal with this kind of files. I have more of these files that will go out of sync after a videoerror.

twazerty
20th January 2010, 08:23
Tried it with CoreAVC as decoder instead of ffdshow, but no luck. Still the same problem. I am sure the solution should be in avisynth. Does anyone know a solution?

Emulgator
20th January 2010, 09:00
When I watch this .mkv i get the impression that transmission of the .ts just got interrupted for some 0.3..0.5s while recording.
this will happen more or less often anyway with DVB, especially with DVB-S. Muxers fail on daily basis, no, actually per second.
And birds do fly, and clouds pass by;-)
I see no chance to bridge this on avisynth or decoder side, because if you change container (and you say you need to)
the missing parts will end somewhere else, thus shifting around and causing desync.
But never say never, a stream fixer for MPEG-2 was there (VideoReDo->QuickStreamFix).
But the downside with VRD was: if video frames were badly corrupted, these had to be discarded and audio had to be cut to match video in sync.
But you might want to keep whatever asset you got more time units of (lets say audio)
and just extend the missing part of the other asset (repeat frames, interpolate frames) to match the duration.

I would decompress into elementaries and do manual editing, if it is worth it and happens not too often...
(I once had to fix and resync a live concert recording manually
where faulty camera tape of 2 cameras would lead to more than 80 dropouts through 2 hours, PITA, 2 weeks.)

twazerty
20th January 2010, 11:01
Why doesn't it fail while playing? MPC or another player plays it in sync.

I do get the part of a muxer. I understand that it can go out of sync while muxing into another container. But this is what I don't understand:
While encoding with x264 3 other apps are running: Avisynth, Haali Media splitter and a decoder (ffdshow or CoreAVC). While playing the source with MPC, Haali is also running. It looks like Haali is doing the job perfectly. And I see Avisynth as the "player" while encoding.

I am convinced that there is an easy solution because I once had another file with the same problem. This time it was muxed into a m2ts container. Playback was perfect and after encoding it went out of sync. I couldn't get it fixed. Somebody else did make a perfect encoding. He doesn't want to tell me how he did it. He told MeGUI was the solution. But I can't accept that as solution because it is a GUI. When MeGUI can do it other tools can do it as well. It has to be inside Avisynth and/or a decoder.

BTW I know DVB-S can be a hardass

7ekno
20th January 2010, 23:58
I would try reading it in Avisynth with FFMS2, DSS2, DGAVCIndex and NVTools ...

My dealings with AVCHDLite streams show major differences between all the above methods of reading ...

I believe MeGUI defaults to DSS2 with MKV input, so that may well be the reason MeGUI does it fine ...

7ek

poisondeathray
21st January 2010, 01:44
Your sample works fine for me , after re-encoding then placing in either .mkv, .mp4, or .m2ts containers

I think you forgot to resample the audio in your framerate conversion

For the video, all I used was (and using haali, ffdshow):


Directshowsource("Source.mkv",fps=25)
AssumeFPS(24000,1001)


For the audio, I used eac3to for the slowdown

Then muxed with tsmuxer

twazerty
21st January 2010, 08:26
@7ekno, I will try it with different decoders.
@poisondeathray, audio isn't the problem. Because my encoded file is in sync. After the video error it goes out of sync immediately. My scripts don't mess with the videoduration (I hate that) so the audio don't need slowdown's or speedup's. My solutions are working for almost a year. Everything is much easier if you don't mess with the videoduration. (Audio and subs are automatically right)

I'll try your script here to see if it goes out of sync.

poisondeathray
21st January 2010, 15:22
The script I used is in sync for your sample, but only if you resample the audio. So both audio & video duration will change. This is how PAL slowdown is normally done. You can't use AssumeFPS, and not change the audio, because it changes the frame rate, but not the frame count.


My scripts don't mess with the videoduration (I hate that) so the audio don't need slowdown's or speedup's.


Actually they do mess with the duration. ConvertFPS can change the duration slightly, so subs can still go out of sync.

I did a test with ConvertFPS , and it still is in sync for me (after the glitch). I encoded both audio & video with the script. The reason I used AssumeFPS too, is that 23.976 is just an approximation


DirectShowSource("Source.mkv", fps=23.976, convertfps=true, audio=true)
AssumeFPS(24000,1001,sync_audio=true)


http://www.mediafire.com/?idzmdmmdlwe

twazerty
21st January 2010, 17:41
The script I used is in sync for your sample, but only if you resample the audio. So both audio & video duration will change. This is how PAL slowdown is normally done. You can't use AssumeFPS, and not change the audio, because it changes the frame rate, but not the frame count.



Actually they do mess with the duration. ConvertFPS can change the duration slightly, so subs can still go out of sync.

I did a test with ConvertFPS , and it still is in sync for me (after the glitch). I encoded both audio & video with the script. The reason I used AssumeFPS too, is that 23.976 is just an approximation


DirectShowSource("Source.mkv", fps=23.976, convertfps=true, audio=true)
AssumeFPS(24000,1001,sync_audio=true)


http://www.mediafire.com/?idzmdmmdlwe

Played your file here but it is not in sync. Tried it with MPC and Nero ShowTime.

poisondeathray
21st January 2010, 19:07
weird, it works for me. MPC, kmplayer, VLC, etc... Maybe you have a playback issue? For MPC, I'm using haali, ffdshow for video & (AC3) audio decoding. Try VLC, as that works independent of your system directshow decoders. The convertfps version might be off by a few ms, but that's hardly perceptible. The assumefps version pal slowdown is perfect.

EDIT: interesting, but SMPlayer plays it out of sync! So it seems player / decoder dependent. The AssumeFPS Pal slowdown version works in all players

twazerty
21st January 2010, 19:22
weird, it works for me. MPC, kmplayer, VLC, etc... Maybe you have a playback issue? For MPC, I'm using haali, ffdshow for video & (AC3) audio decoding. Try VLC, as that works independent of your system directshow decoders. The convertfps version might be off by a few ms, but that's hardly perceptible. The assumefps version pal slowdown is perfect.

EDIT: interesting, but SMPlayer plays it out of sync! So it seems player / decoder dependent. The AssumeFPS Pal slowdown version works in all players

Nope also in VLC your encoded file gets out of sync.

poisondeathray
21st January 2010, 19:32
Really? I'm using VLC 0.9.9 . I even re-downloaded the file in case it was different from the one I uploaded. It's in sync for me

twazerty
22nd January 2010, 15:34
Really? I'm using VLC 0.9.9 . I even re-downloaded the file in case it was different from the one I uploaded. It's in sync for me

1.0.3 here :)

Total Media Theatre and WMP are also going out of sync. Also burned your file to dics and tested it in my blu-ray player. Result: Also out of sync. Also tested it with SMPlayer but then the whole video is out of sync.

poisondeathray
22nd January 2010, 15:59
I can't explain it

Even your source.mkv, when muxed with tsmuxer (with nothing re-encoded) is in sync for me with MPC, MPCHC, KMPlayer, VLC, etc...

Are you using the new or old haali splitter? But that doesn't explain why a blu-ray player would play it out of sync...