News:

--

Main Menu

Audio desync when editing mp4 file in copy mode

Started by Bangaio, June 03, 2017, 05:12:28 PM

Previous topic - Next topic

Bangaio

avidemux_r170603_win64Qt5_424.zip

When editing the mp4 file in copy mode, the audio becomes desynced. (MP4v2 muxer)
mp4 file is from a livestream captured in ts and then converted to mp4 in copy mode (both using ffmpeg)

I tried editing the .ts file without converting to mp4, but avidemux hanged when trying to open it. And in my experience editing .ts files causes audio dropouts anyway.

I don't know if this is an issue of the video or of avidemux, since it doesn't happen with every video.

Files (mp4 original, mp4 edited, ts original):
https://mega.nz/#!bNdCAIaB!zhpqd6FQtDUgitLJRH9t6umZ10PBaP-_KML6CGkDg3k

Thanks in advance!


eumagga0x2a

A few observations:


  • the provided .ts sample is not the same video as the .mp4 sample;
  • Avidemux tries unsuccessfully to index the .ts until killed:

    [extractSPSInfo_lavcodec] 18:39:32-805  Incoming SPS info

    0000 : d.(�r0..n�D...�.  64 00 28 ac 72 30 14 01 6e c0 44 00 00 0f a4 00
    0010 : .���..А.z.��.�.  03 a9 83 8a 00 03 d0 90 00 7a 13 bd ee 03 e1 10
    0020 : �  8a
    [extractSPSInfo_lavcodec] 18:39:32-805  converted SPS info

    0000 : .M@.��."gd.(�r0.  01 4d 40 1f ff e1 00 22 67 64 00 28 ac 72 30 14
    0010 : .n�D...�..���..�  01 6e c0 44 00 00 0f a4 00 03 a9 83 8a 00 03 d0
    0020 : �.z.��.�.�  90 00 7a 13 bd ee 03 e1 10 8a
    [extractSPSInfo_mp4Header] 18:39:32-805  Parser created
    [extractSPSInfo_mp4Header] 18:39:32-805  Codec created
    [extractSPSInfo_mp4Header] 18:39:32-805  Context created
    [adm_lavLogCallback] 18:39:32-805  [lavc] Overread VUI by 8 bits
    [adm_lavLogCallback] 18:39:32-805  [lavc] SPS decoding failure, trying again after escaping the NAL
    [adm_lavLogCallback] 18:39:32-805  [lavc] Invalid UE golomb code
    [adm_lavLogCallback] 18:39:32-805  [lavc] Overread VUI by 8 bits
    [adm_lavLogCallback] 18:39:32-805  [lavc] Decoding sps 0 from avcC failed
    [adm_lavLogCallback] 18:39:32-805  [lavc] AVC-parser: nal length size invalid
    Used bytes 0/42 (+5)
    [extractSPSInfo_mp4Header] 18:39:32-805  Failed to extract SPS info
    [extractSPSInfo_mp4Header] 18:39:32-805  Width  : 0
    [extractSPSInfo_mp4Header] 18:39:32-805  Height : 0
    [adm_lavLogCallback] 18:39:32-805  [lavc] findValidSPS no valid SPS found
    [extractSPSInfo_mp4Header] 18:39:32-805  Cannot get sps info from lavcodec
    [extractSPSInfo] 18:39:32-805  Failed


  • ffmpeg refuses to remux the transport stream unless the option mentioned in the error is added to the command line:

    [mp4 @ 0x564a7e7f6dc0] Malformed AAC bitstream detected: use the audio bitstream filter 'aac_adtstoasc' to fix it ('-bsf:a aac_adtstoasc' option with ffmpeg)

  • The refineFps() function from the Mp4 demuxer in Avidemux results in wrong FPS value when loading the provided .mp4 which is a know issue. With the function bypassed the detected FPS value becomes correct;
  • With audio delay set to -1300 ms Avidemux remuxes the mp4 just fine.

Bangaio

- Yes to convert to mp4 in ffmpeg you have to add the aac_adtstoasc filter, forgot to mention that.

- How can i bypass the refineFps() option?

- I been editing other videos from the same livestream and -1300ms shift seems to work pretty well most of the time, so that's good.

Thanks.

eumagga0x2a

Quote from: Bangaio on June 07, 2017, 05:19:23 PM
- How can i bypass the refineFps() option?

This is possible only if you build Avidemux from source yourself (which implies that you use either Linux or macOS): In avidemux_plugins/ADM_demuxers/Mp4/ADM_mp4.cpp in the function MP4Header::refineFps add

    return true;

straight after the opening curly bracket and (re)build Avidemux.