VideoHelp Forum
+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 38 of 38
Thread
  1. Originally Posted by ProWo View Post
    I gave you some hints and you answer with questions instead of working off the hints.
    I am out
    You tell me to do stuff with incomplete instructions. I try and get an error message that I posted, not knowing if I should proceed or not. So, I don't know what I am doing and I am not learning anything. If that offends you, so be it.
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    Open the source in Avidemux. Set the output format (lower left) to mp4 muxer.
    Use the A and B buttons at the bottom to mark off a short section, one or two minutes.
    Save, and verify that the file plays back properly. This will be the reference file for untrunc.

    Open untrunc and give it the reference file and the bad file, it will create a third, the "fixed" file.
    Quote Quote  
  3. Originally Posted by davexnet View Post
    Open the source in Avidemux. Set the output format (lower left) to mp4 muxer.
    Use the A and B buttons at the bottom to mark off a short section, one or two minutes.
    Save, and verify that the file plays back properly. This will be the reference file for untrunc.

    Open untrunc and give it the reference file and the bad file, it will create a third, the "fixed" file.
    First, in post #23 I post the error message when I first open the MP4. Nobody has addressed it, so, I don't know if Avidemux can deal with the file or if I should click on "proceed". Also, nobody has addressed by Avidemux is recommended or required to create the reference file. So, I used this command to create a 2 minute reference file:
    Code:
    ffmpeg out.mp4 -t 00:02:00.000 -c copy to reference.mp4"
    Then, I ran untrunc-gui. The first time, I ran it without any changes in the settings tab and it generated this error:
    Code:
    Assertion failed!
    Program:  untrunc-gui.exe
    File:  src/atom.cpp, Line 481
    Expression:  end - start = = new_length
    <Abort>  <Retry>  <Ignore>
    I clicked "ignore" and it finished without any other error messages. untrunc does not seem to have the ability to generate a log file and trying to highlight and copy the displayed log does not work. Windows and VLC show the length of the fixed MP4 to be 2:52:05, which is 11 seconds longer than the original MP4. The untrunc-gui log screen shows "Duration of mp4a: 2h 51 min 54s 536ms" and "Duration of avc1: 2h 52min 5s 736ms". When I play it in VLC, it shows a length of 2:52:05 and everything is good until 1:42:22 when both the video and the audio stops. This is the MediaInfo for that MP4:
    Code:
    General
    Complete name                            : C:out_fixed.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom (isom/iso2/avc1/mp41)
    File size                                : 4.66 GiB
    Duration                                 : 2 h 52 min
    Overall bit rate                         : 3 877 kb/s
    Writing application                      : Lavf58.78.100
    IsTruncated                              : Yes
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 2 h 52 min
    Bit rate                                 : 6 402 kb/s
    Maximum bit rate                         : 20.1 Mb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Variable
    Frame rate                               : 29.937 FPS
    Minimum frame rate                       : 5.994 FPS
    Maximum frame rate                       : 120.000 FPS
    Original frame rate                      : 29.970 (30000/1001) FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.103
    Stream size                              : 7.70 GiB
    Codec configuration box                  : avcC
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 2 h 51 min
    Bit rate mode                            : Constant
    Bit rate                                 : 93.6 kb/s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 44.1 kHz
    Frame rate                               : 43.066 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 118 MiB (2%)
    Default                                  : Yes
    Alternate group                          : 1
    
    Text #1
    ID                                       : 1-CC1
    Format                                   : EIA-608
    Muxing mode                              : SCTE 128 / DTVCC Transport
    Muxing mode, more info                   : Muxed in Video #1
    Duration                                 : 2 h 52 min
    Bit rate mode                            : Constant
    Stream size                              : 0.00 Byte (0%)
    CaptionServiceName                       : CC1
    
    Text #2
    ID                                       : 1-CC3
    Format                                   : EIA-608
    Muxing mode                              : SCTE 128 / DTVCC Transport
    Muxing mode, more info                   : Muxed in Video #1
    Duration                                 : 2 h 52 min
    Bit rate mode                            : Constant
    Stream size                              : 0.00 Byte (0%)
    CaptionServiceName                       : CC3
    Next, I ran untrunc-gui again, but, this time in the "Settings" tab, I click "on":
    • "skip unknown (-s)"
    • "stretch video to match audio (-sv)"
    • "keep unknown sequences (-k)"
    Windows also shows this MP4 to be 2:52:05 long with the same "Duration" information as above. When I view this MP4 in VLC, it shows the length of 2:52:05 and plays all of the way to the end. But, the audio is out of sync with the video throughout. It seems that the 11 second difference is spread out the entire length of the viewing - gradually getting worse. Here is the MediaInfo if that MP4:
    Code:
    General
    Complete name                            : C:out.mp4_fixed-s1-k-sv.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom (isom/iso2/avc1/mp41)
    File size                                : 7.82 GiB
    Duration                                 : 2 h 52 min
    Overall bit rate                         : 6 507 kb/s
    Writing application                      : Lavf58.78.100
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 2 h 52 min
    Bit rate                                 : 6 402 kb/s
    Maximum bit rate                         : 20.1 Mb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Variable
    Frame rate                               : 29.937 FPS
    Minimum frame rate                       : 5.994 FPS
    Maximum frame rate                       : 120.000 FPS
    Original frame rate                      : 29.970 (30000/1001) FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.103
    Stream size                              : 7.70 GiB (98%)
    Codec configuration box                  : avcC
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 2 h 51 min
    Bit rate mode                            : Constant
    Bit rate                                 : 93.6 kb/s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 44.1 kHz
    Frame rate                               : 43.066 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 118 MiB (1%)
    Default                                  : Yes
    Alternate group                          : 1
    
    Text #1
    ID                                       : 1-CC1
    Format                                   : EIA-608
    Muxing mode                              : SCTE 128 / DTVCC Transport
    Muxing mode, more info                   : Muxed in Video #1
    Duration                                 : 2 h 52 min
    Bit rate mode                            : Constant
    Stream size                              : 0.00 Byte (0%)
    CaptionServiceName                       : CC1
    
    Text #2
    ID                                       : 1-CC3
    Format                                   : EIA-608
    Muxing mode                              : SCTE 128 / DTVCC Transport
    Muxing mode, more info                   : Muxed in Video #1
    Duration                                 : 2 h 52 min
    Bit rate mode                            : Constant
    Stream size                              : 0.00 Byte (0%)
    CaptionServiceName                       : CC3
    So, it looks like untrunc is able to fix the mismatched sync, but, it is not exact. I am not sure what to try next.
    Quote Quote  
  4. Originally Posted by Nilzzon View Post
    TMPGEnc MPEG Smart Renderer
    And, what am I supposed to do with this app? The description does not mention the problem I am dealing with.
    Quote Quote  
  5. OK, it looks like I have a solution. After running untrunc, I end up with an MP4 where the video (via info from MediaInfo) is 2:51:54 long (the original length) and the audio is 2:52:05 long. A quick look in VLC seems to indicate that the 11 second difference on syncing the audio and video is evenly spread out. Doing a bit a math, the video is 0.998915331556 times as long as the audio. So, I decided to try the following command:
    Code:
    ffmpeg" -i out_of_sync.mp4 -filter_complex "[0:v]setpts=1.0*PTS[v];[0:a]atempo=0.998915331556[a]" -map "[v]" -map "[a]" -crf 16 out_fix.mp4
    This is supposed to change the speed/rate of the audio. (The "-crf 16" is just trying to retain the original quality and the "16" can be adjusted to whatever your original quality is.) The resulting MP4 seems to have the audio and video in sync!

    I will post a final post for the thread that recaps the thread and solution for any future readers.
    Quote Quote  
  6. **************************************
    This is a recap of the thread issue and the solution
    **************************************

    I have an H264 MP4 that I downloaded from a streaming site via the Firefox add-on "Video DownloadHelper". Windows and VLC tells me that it is 2:51:54 long. At the 1:57:07 mark, the video track speeds up and then stops before the end, but, the audio track continues at normal speed to the end. VLC shows the frame rate to be 94.126760 (yeah, that's weird!). I downloaded that file at least 5 times and the problem starts at the same timestamp each time. When I stream the video in Firefox, everything works fine all of the way through to the end.

    It was suggested that I use untrunc to correct the problem - an app that I have never used before. It needs a "reference file" that has all of the attributes/setting that you want for the resulting corrected file. It was suggested that I use Avidemux (another app I have never used) to create this reference file, but, instead I used this ffmpeg command to create a 2 minute long file from the beginning of the MP4:
    Code:
    ffmpeg out.mp4 -t 00:02:00.000 -c copy to reference.mp4"
    Then, I ran untrunc-gui without clicking "on" any of the checkboxes in the "Settings" tab", but, it did not run properly (see post #34 for that information). Next, I ran untrunc-gui again, but, this time in the "Settings" tab, I click "on":
    • "skip unknown (-s)"
    • "stretch video to match audio (-sv)"
    • "keep unknown sequences (-k)"
    This ran without any errors and generated a "fixed" MP4 that was 2:52:05 in both Windows and VLC - 11 seconds longer than the original. Viewing it in VLC, everything starts off fine, but, gradually the video and audio tracks were out of sync by 11 seconds by the end. MediaInfo confirmed that the video and audio tracks were different lengths. I remembered the ffmpeg "-filter_complex & setpts" switch where you can change the speed of either the audio, video, or, both. Since MediaInfo told me that the audio was longer than the original length of the file, I decided that I needed to speed up the audio, or, in other words, reduce/compress the length of the audio. So (warning: MATH!), I divided the original 2:51:54 length (10314.536 seconds) by the fixed 2:52:05 length (10325.736 seconds) to come up with a factor of 0.998915331556. Next, I ran this command:
    Code:
    ffmpeg" -i out_of_sync.mp4 -filter_complex "[0:v]setpts=1.0*PTS[v];[0:a]atempo=0.998915331556[a]" -map "[v]" -map "[a]" -crf 16 out_new.mp4
    This command does not change the speed of the video track, changes the audio track speed, and, tries to retain the original overall quality (via "-crf 16") since the file is being re-encoded. This resulted in an MP4 where it is the original length, and, the audio and video tracks are in sync. SUCCESS!

    The end result is that I was able to fix the MP4. But, I did not learn what might have caused this problem, what app to use to discover where/how/why the problem occurred, or, how it was fixed (meaning, I know that untrunc fixed it but I don't know what it changed/fixed). Simply, I just wanted to know exactly what was broken, but, I guess sometimes it is not worth knowing (for instance: "just reboot the computer to fix that") when you have a tool that can fix it.
    Quote Quote  
  7. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Most of the times I have encountered this is when I have inadvertantly joined 2 segments with different formats, particularly the AUDIO. Joining these videos gives different lengths for audio and video. Other mismatches cause similar problems but almost all that I have encounteredd have been from joining 2 segments of un-similar formats.

    Joining 44.1k sample rate with 48k sample rate with ffmpeg delivers the following mediainfo.

    Video
    ID : 1
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : High@L3.1
    Format settings : CABAC / 3 Ref Frames
    Format settings, CABAC : Yes
    Format settings, Reference frames : 3 frames
    Codec ID : avc1
    Codec ID/Info : Advanced Video Coding
    Duration : 15 min 54 s
    Source duration : 15 min 54 s
    Bit rate : 792 kb/s
    Width : 854 pixels
    Height : 480 pixels


    Audio
    ID : 2
    Format : AAC LC
    Format/Info : Advanced Audio Codec Low Complexity
    Codec ID : mp4a-40-2
    Duration : 17 min 18 s
    Bit rate mode : Constant
    Bit rate : 101 kb/s
    Channel(s) : 2 channels
    Channel layout : L R
    Sampling rate : 44.1 kHz
    Frame rate : 43.066 FPS (1024 SPF)
    Compression mode : Lossy
    Quote Quote  



Similar Threads

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