anyc / avcut

Frame-accurate video cutting with only small quality loss
GNU General Public License v2.0
112 stars 13 forks source link

AVcut audio sync lost on 1080i cuts #19

Open pcrow opened 2 years ago

pcrow commented 2 years ago

I'm working with a video file recorded using a HDPrime from a cable channel in the US. The channel is being sent using H.264 in 1080i, and is a MPEG transport stream file (.ts). The video frame rate is 29.97. I can use ffmpeg to copy it into a .mp4 container, or just run with the original .ts file (though adjusting the cut timestamps since it doesn't start at zero). Either way I get the same results: The cut file's audio track falls behind significantly; several seconds or more.

I note that the output file says the frame rate is 59.94 when playing it in mplayer, and I see a reference to 28.11 fps, which makes no sense.

ffmpeg -i [file]

Input .ts file: Program 1 Stream #0:0[0x1dc5]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Stream #0:10x1dc6: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s

Output file: Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 3092 kb/s, 28.11 fps, 59.94 tbr, 90k tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Side data: audio service type: main

I'm hoping to get this working with MythTV for clipping recordings. I'm testing with an exported cutlist, and the first cut seems to be correct (I'm clipping the start of the file), but later ones are off. I suspect the problem with the sound sync is related, so once that's fixed, I'll move on.

pcrow commented 2 years ago

With a 720p source, all my cutpoints from MythTV are exact, but the audio still gets delayed.

Source:

  Duration: 01:02:59.97, start: 73839.401322, bitrate: 4492 kb/s
  Program 1 
  Stream #0:0[0x425]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
  Stream #0:1[0x426](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 5.1(side), fltp, 384 kb/s
  Stream #0:2[0x427](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s

Result:

  Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 4105 kb/s, 59.96 fps, 59.94 tbr, 90k tbn, 239.76 tbc (default)
  Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s (default)
  Stream #0:2(spa): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 192 kb/s

The result references 59.96fps instead of 59.94fps. If the video is playing back 0.02 fps to fast, that might explain the audio sync.

anyc commented 2 years ago

Sorry for the late response, I do not have much time to invest in avcut anymore.

I just released a new version with some fixes, could you test it again?

If it does not work, an example video would help analyzing the issue. If that is not (legally) possible, please build avcut with "make debug" and send the output.

pcrow commented 2 years ago

A late response is still very much appreciated. I may not get to this right away, but I will report back when I do.