Opened 5 years ago

Closed 3 years ago

#4166 closed defect (needs_more_info)

MPEG4 and LibXVid in AVI lose audio sync after some time

Reported by: ramitbhalla Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: async
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug: This happens only with the AVI container using MPEG4 or Libxvid codecs (if using a MP4 container it works fine).

When trying to recode a video into DIVX/MPEG4 in AVI container the audio loses sync after a while progressively.

The original file is 880MB but can't be split since this is a progressive issue. The original file can be downloaded here:
http://mcebuddy:mcebuddy@files.mcebuddy2x.com/upload/DWSpiro/In%20the%20Heat%20of%20the%20Night_WHDHDT2_2014_11_23_18_58_00.wtv

Here is the command used to reproduce the issue (the scale is just to speed up the conversion but has no effect on the sync with or without)

How to reproduce:

ffmpeg -i "In the Heat of the Night_WHDHDT2_2014_11_
23_18_58_00.wtv" -vcodec mpeg4 -acodec ac3 -ab 128k -b 400 -vf scale=320:-1 test.avi
ffmpeg version N-68199-g5fe026f Copyright (c) 2000-2014 the FFmpeg developers
  built on Dec  3 2014 23:46:55 with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-lib
opencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[mpeg2video @ 03a78060] Invalid frame dimensions 0x0.
    Last message repeated 30 times
Input #0, wtv, from 'In the Heat of the Night_WHDHDT2_2014_11_23_18_58_00.wtv':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    Title           : In the Heat of the Night
    WM/SubTitle     : Trundel's Will Be Done
    WM/SubTitleDescription: Harriet DeLong asks Chief Gillespie to mediate a custody dispute when a wealthy woman attemp
ts to take guardianship of her nephew.
    genre           : Drama;General;Series
    WM/OriginalReleaseTime: 0
    WM/MediaCredits : Carroll O'Connor/Howard E. Rollins/Anne-Marie Johnson/Alan Autry/Denise Nicholas/David Hart/Christ
ian LeBlanc/Peter Gabb/Hugh O'Connor/Dennis Lipscomb/Jill Carroll;;;
    service_provider: WHDHDT2
    service_name    : WHDHDT2 (WHDH-DT2)
    WM/MediaNetworkAffiliation: Independent
    WM/MediaOriginalChannel: 7
    WM/MediaOriginalChannelSubNumber: 2
    WM/MediaOriginalBroadcastDateTime: 1992-03-03T05:00:00Z
    WM/MediaOriginalRunTime: 38929878258
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: true
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-PG
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2014-11-23 23:58:07
    WM/WMRVSeriesUID: !MCSeries!48125534
    WM/WMRVServiceID: !MCService!49477459
    WM/WMRVProgramID: !MCProgram!28410666
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 3
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: 4294966996
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: false
    Duration        : 38929904508
    WM/WMRVEndTime  : 2014-11-24 01:03:00
    WM/WMRVBitrate  : 2.917057
    WM/WMRVKeepUntil: 4294967295
    WM/WMRVActualSoftPrePadding: 412
    WM/WMRVActualSoftPostPadding: 180
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : false
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 240
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 255
    WM/MediaThumbRatingLevel: 255
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 4
    WM/MediaThumbAspectRatioY: 3
    WM/MediaThumbTimeStamp: 4646161835318323993
  Duration: 01:04:52.72, start: 1.563819, bitrate: 1852 kb/s
    Stream #0:0[0x17](eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:1[0x18]: Video: mpeg2video (Main), yuv420p(tv), 704x480 [SAR 10:11 DAR 4:3], max. 15000 kb/s, 29.97 fps, 5
9.94 tbr, 10000k tbn, 59.94 tbc
    Stream #0:2[0x19]: Subtitle: eia_608
Please use -b:a or -b:v, -b is ambiguous
[mpeg4 @ 03ac80e0] Bitrate 400 is extremely low, maybe you mean 400k
The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, avi, to 'test.avi':
  Metadata:
    WM/MediaClassPrimaryID: db9830bd-3ab3-4fab-8a371a995f7ff74
    WM/MediaClassSecondaryID: ba7f258a-62f7-47a9-b21f4651c42a000
    INAM            : In the Heat of the Night
    WM/SubTitle     : Trundel's Will Be Done
    WM/SubTitleDescription: Harriet DeLong asks Chief Gillespie to mediate a custody dispute when a wealthy woman attemp
ts to take guardianship of her nephew.
    IGNR            : Drama;General;Series
    WM/OriginalReleaseTime: 0
    ILNG            : en-us
    WM/MediaCredits : Carroll O'Connor/Howard E. Rollins/Anne-Marie Johnson/Alan Autry/Denise Nicholas/David Hart/Christ
ian LeBlanc/Peter Gabb/Hugh O'Connor/Dennis Lipscomb/Jill Carroll;;;
    service_provider: WHDHDT2
    service_name    : WHDHDT2 (WHDH-DT2)
    WM/MediaNetworkAffiliation: Independent
    WM/MediaOriginalChannel: 7
    WM/MediaOriginalChannelSubNumber: 2
    WM/MediaOriginalBroadcastDateTime: 1992-03-03T05:00:00Z
    WM/MediaOriginalRunTime: 38929878258
    WM/MediaIsStereo: true
    WM/MediaIsRepeat: true
    WM/MediaIsLive  : false
    WM/MediaIsTape  : false
    WM/MediaIsDelay : false
    WM/MediaIsSubtitled: false
    WM/MediaIsMovie : false
    WM/MediaIsPremiere: false
    WM/MediaIsFinale: false
    WM/MediaIsSAP   : false
    WM/MediaIsSport : false
    WM/ParentalRating: TV-PG
    WM/Provider     : MediaCenterDefault
    WM/VideoClosedCaptioning: true
    WM/WMRVEncodeTime: 2014-11-23 23:58:07
    WM/WMRVSeriesUID: !MCSeries!48125534
    WM/WMRVServiceID: !MCService!49477459
    WM/WMRVProgramID: !MCProgram!28410666
    WM/WMRVRequestID: 0
    WM/WMRVScheduleItemID: 0
    WM/WMRVQuality  : 3
    WM/WMRVOriginalSoftPrePadding: 420
    WM/WMRVOriginalSoftPostPadding: 180
    WM/WMRVHardPrePadding: 4294966996
    WM/WMRVHardPostPadding: 0
    WM/WMRVATSCContent: true
    WM/WMRVDTVContent: true
    WM/WMRVHDContent: false
    Duration        : 38929904508
    WM/WMRVEndTime  : 2014-11-24 01:03:00
    WM/WMRVBitrate  : 2.917057
    WM/WMRVKeepUntil: 4294967295
    WM/WMRVActualSoftPrePadding: 412
    WM/WMRVActualSoftPostPadding: 180
    WM/WMRVContentProtected: false
    WM/WMRVContentProtectedPercent: 0
    WM/WMRVExpirationSpan: 9223372036854775807
    WM/WMRVInBandRatingSystem: 255
    WM/WMRVInBandRatingLevel: 255
    WM/WMRVInBandRatingAttributes: 0
    WM/WMRVWatched  : false
    WM/MediaThumbWidth: 352
    WM/MediaThumbHeight: 240
    WM/MediaThumbStride: 1056
    WM/MediaThumbRet: 0
    WM/MediaThumbRatingSystem: 255
    WM/MediaThumbRatingLevel: 255
    WM/MediaThumbRatingAttributes: 0
    WM/MediaThumbAspectRatioX: 4
    WM/MediaThumbAspectRatioY: 3
    WM/MediaThumbTimeStamp: 4646161835318323993
    ISFT            : Lavf56.15.102
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 320x218 [SAR 109:120 DAR 4:3], q=2-31, 0 kb/s, 29.97 fps, 29
.97 tbn, 29.97 tbc
    Metadata:
      encoder         : Lavc56.13.100 mpeg4
    Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc56.13.100 ac3
Stream mapping:
  Stream #0:1 -> #0:0 (mpeg2video (native) -> mpeg4 (native))
  Stream #0:0 -> #0:1 (ac3 (native) -> ac3 (native))
Press [q] to stop, [?] for help
[ac3 @ 03a27fe0] delta bit allocation strategy reserved7.85 bitrate= 225.3kbits/s dup=0 drop=2
[ac3 @ 03a27fe0] error decoding the audio block
[ac3 @ 03a27fe0] frame sync error
Error while decoding stream #0:0: Invalid data found when processing input
frame=116600 fps=504 q=31.0 Lsize=  106104kB time=01:04:53.18 bitrate= 223.3kbits/s dup=0 drop=3
video:39646kB audio:60806kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 5.626378%

Change History (11)

comment:1 Changed 5 years ago by cehoyos

  • Keywords async added

Needs -async 1.

comment:2 Changed 5 years ago by ramitbhalla

Perfect thanks that worked. Does it mean that all AVI containers with MPEG4 need async 1? If not how does one tell when it's required?

comment:3 Changed 5 years ago by ramitbhalla

That worked with one file, with another sample it didn't work, it' still out of sync. Again with MP4 container it works fine with AVI container it goes out of sync, even with the -async 1.

The file is available here (too large):
http://mcebuddy:mcebuddy@files.mcebuddy2x.com/upload/The%20Office.ts

comment:4 Changed 5 years ago by cehoyos

I tested the following command line:

$ ffmpeg -i The\ Office.ts -qscale 2 out.avi

How can I reproduce A/V desync for the output file?

comment:5 Changed 5 years ago by ramitbhalla

Exact same command as the first file:

ffmpeg -i "The Office.ts" -vcodec mpeg4 -acodec ac3 -ab 128k -b 400 -vf scale=320:-1 test.avi

comment:6 Changed 5 years ago by cehoyos

How can I reproduce A/V desync with the output file I produced with my command line?

comment:7 Changed 5 years ago by ramitbhalla

I didn't understand your question - if you're asking about the playback, I used WMP 12 (windows 7) to check the output playback.

comment:8 Changed 5 years ago by cehoyos

I tested the output file with MPlayer, vlc and FFplay: All three play the file in sync.
Is the issue only reproducible with WMP?

comment:9 Changed 5 years ago by compn

@ ramitbhalla, its possible that ac3 in avi might be causing problems, use mp3 codec instead? or mkv container.

comment:10 Changed 5 years ago by ramitbhalla

It's true, mp3 works fine. I thought the dev team would like to know about the bug hence I reported it.

comment:11 Changed 3 years ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from new to closed

The original wtv file is now an additional real-world sample for ticket #4674.
I am unable to reproduce any issue related to the transport stream The Office.ts, please reopen if you can explain how I can reproduce the problem.

Note: See TracTickets for help on using tickets.