VideoHelp Forum




+ Reply to Thread
Results 1 to 22 of 22
  1. Hello
    Almost all MPEG-TS (DVB-C recordings with Mythtv) to mkv conversions with mkvmerge have a wrong duration in the mkv file.
    This happens also when I use --split.

    What can I do to fix this?
    Does it happen because of corrupt data in the beginning? Does skipping inside the file fix this (how is it done)?

    Code:
    mkvmerge -o 10017_20120217195000.mkv 10017_20120217195000.mpg
    Code:
    General
    ID                                       : 82 (0x52)
    Complete name                            : 10017_20120217195000.mpg
    Format                                   : MPEG-TS
    File size                                : 3.67 GiB
    Duration                                 : 34mn 39s
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 15.2 Mbps
    
    Video
    ID                                       : 60 (0x3C)
    Menu ID                                  : 1 (0x1)
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4.0
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Codec ID                                 : 27
    Duration                                 : 34mn 38s
    Bit rate                                 : 14.0 Mbps
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate                               : 25.000 fps
    Standard                                 : Component
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Interlaced
    Scan order                               : Top Field First
    Bits/(Pixel*Frame)                       : 0.271
    Stream size                              : 3.40 GiB (92%)
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 64 (0x40)
    Menu ID                                  : 1 (0x1)
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Mode extension                           : CM (complete main)
    Format settings, Endianness              : Big
    Codec ID                                 : 129
    Duration                                 : 34mn 39s
    Bit rate mode                            : Constant
    Bit rate                                 : 384 Kbps
    Channel(s)                               : 6 channels
    Channel positions                        : Front: L C R, Side: L R, LFE
    Sampling rate                            : 48.0 KHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossy
    Delay relative to video                  : -728ms
    Stream size                              : 95.2 MiB (3%)
    Language                                 : German
    Language, more info                      : Clean effects
    Code:
    General
    Unique ID                                : 71472755369825805954965999584523238553 (0x35C526E7FEB1354E0A4E1784E176BC99)
    Complete name                            : 10017_20120217195000.mkv
    Format                                   : Matroska
    Format version                           : Version 4 / Version 2
    File size                                : 3.57 GiB
    Duration                                 : 2h 33mn
    Overall bit rate                         : 3 335 Kbps
    Encoded date                             : UTC 2014-02-05 00:05:57
    Writing application                      : mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  8 2014 15:19:56
    Writing library                          : libebml v1.3.0 + libmatroska v1.4.1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4.0
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Format settings, GOP                     : M=4, N=28
    Codec ID                                 : V_MPEG4/ISO/AVC
    Bit rate                                 : 2 884 Kbps
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Variable
    Original frame rate                      : 25.000 fps
    Standard                                 : Component
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Interlaced
    Scan order                               : Bottom Field First
    Default                                  : Yes
    Forced                                   : No
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 2
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Mode extension                           : CM (complete main)
    Format settings, Endianness              : Big
    Codec ID                                 : A_AC3
    Duration                                 : 2h 33mn
    Bit rate mode                            : Constant
    Bit rate                                 : 384 Kbps
    Channel(s)                               : 6 channels
    Channel positions                        : Front: L C R, Side: L R, LFE
    Sampling rate                            : 48.0 KHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossy
    Delay relative to video                  : -588ms
    Stream size                              : 422 MiB (12%)
    Language                                 : German
    Default                                  : Yes
    Forced                                   : No
    Quote Quote  
  2. What can I do to fix this?
    - check your ts stream for errors and fixing them using Cypheros TS-Doctor or similar tools might help
    - remuxing the ts to m2ts using tsMuxeR or ffmpeg and then feeding the output to mkvmerge might help
    - report the problem to the mkvtoolnix bug tracker and ask Mosu (mkvtoolnix developer) to look at it
    Quote Quote  
  3. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    Please provide a ts video sample.
    Quote Quote  
  4. Also by cleaning them with TS-Doctor before I have conversions with wrong durations.

    Here is a sample.
    http://minerva11.mine.bz/public/winx/10017_20120217195000_5min.mpg
    Quote Quote  
  5. I thought you had transport streams,... not program streams,...
    Quote Quote  
  6. Given the video is interlaced..... I'd try remuxing while specifying a frame rate. If 25fps doesn't fix it, try 50i or 50p. If the video is playing correctly it could be something to do with the way the frame rate is being "interpreted".

    If none of that works I'd try remuxing the ts file as a new ts file with tsmuxer, then remuxing the new ts file with MKVMergeGUI.
    Quote Quote  
  7. Original:
    Duration : 34mn 39s

    Created mkv:
    Duration : 2h 33mn


    With tsMuxer, muxing a new m2ts (which is fine) and afterwards mkvmerge, the mkv has the wrong duration.
    I noticed the following in the tsMuxeR log, can it be the source of the problem, it is audio?

    Network Optix tsMuxeR. Version 2.6.12. www.networkoptix.com
    Decoding AC3 stream (track 2): Bitrate: 384Kbps Sample Rate: 48KHz Channels: 5.1
    Decoding H264 stream (track 1): Profile: High@4.0 Resolution: 1920:1080i Frame rate: 25
    H.264 muxing fps is not set. Get fps from stream. Value: 25
    H264 bitstream changed: insert pict timing and buffering period SEI units
    B-pyramid level 1 detected. Shift DTS to 2 frames
    B-pyramid level 2 detected. Shift DTS to 3 frames
    AC3 stream (track 2): bad frame detected at position00:09:52,831. Resync stream.
    Decoding AC3 stream (track 2): Bitrate: 384Kbps Sample Rate: 48KHz Channels: 5.1
    AC3 stream (track 2): bad frame detected at position00:09:55,039. Resync stream.
    Decoding AC3 stream (track 2): Bitrate: 384Kbps Sample Rate: 48KHz Channels: 5.1
    Processed 51929 video frames
    Flushing write buffer
    Mux successful complete
    Muxing time: 1 min 0 sec

    I fixed the input file with TS-Doctor (tsMuxeR recognizes these) . Up to here the duration is still correct. The mkvmerge file created this way has also the wrong duration.

    Any other ideas?
    Last edited by bruchmann; 5th Feb 2014 at 16:43.
    Quote Quote  
  8. I checked the created mkv on the position where the resync stream happend due to AC3 bad frame with tsMuxeR, there is a video glitch. Also when skipping after this position the time jumps to 2 hours. This explains the problem.

    As I also had the problem with TS-Doctor created files, are there any other options I have to fix the original TS file?
    Quote Quote  
  9. Given the audio appears to be the problem, I'd try remuxing with MKVMergeGUI without the audio. If the video on it's own results in the correct duration then you've confirmed it's the audio. You might need to re-encode it.
    Or maybe try giving Delaycut a look at it. Or even extracting the AC3 with HD-DVD/Blu-Ray Stream Extractor. If eac3to finds any problems when extracting, hopefully it'll fix them.
    Quote Quote  
  10. I'm a Super Moderator johns0's Avatar
    Join Date
    Jun 2002
    Location
    canada
    Search Comp PM
    The problem you have is you are converting your files to variable framerates,stick to constant frame rates.
    I think,therefore i am a hamster.
    Quote Quote  
  11. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    I have no problem remuxing your sample in mkv using mkvmerge 6.7.0 w/o timecodes. There is no wrong duration and the MKVs are playing fine in VLC, no matter if AVC is VFR or CFR.
    Quote Quote  
  12. running the audio through delaycut (without any additional options) might help
    Quote Quote  
  13. Originally Posted by Endoro View Post
    I have no problem remuxing your sample in mkv using mkvmerge 6.7.0 w/o timecodes. There is no wrong duration and the MKVs are playing fine in VLC, no matter if AVC is VFR or CFR.

    Sorry, I provided a wrong link, the complete movie you can find here:
    http://minerva11.mine.bz/public/winx/10017_20120217195000.mpg
    Quote Quote  
  14. Originally Posted by johns0 View Post
    The problem you have is you are converting your files to variable framerates,stick to constant frame rates.
    He's just remuxing, not converting. Using MKVMergeGUI shouldn't be a problem when remuxing VFR video.
    I know MediaInfo reports the frame rate as variable, but chances are it's not. Although MediaInfo only reports the frame rate as variable for the remuxed MKV, and doesn't specify variable or constant for the original TS file.
    Quote Quote  
  15. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    please have a look at my workflow to deal with such TS files:
    Code:
    C:\Users\Endoro>timecodeanalysis 10017_20120217195000.mpg
    Time code analysis for "10017_20120217195000.mpg"
    Progress: 100%
    Track ID 0: video (MPEG-4p10/AVC/h.264)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
         20 ms      51919    1038380 ms     1038380 ms      51919
    Track ID 1: audio (AC3/EAC3)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
         32 ms      64942    2078144 ms     2078144 ms      64942
    
    C:\Users\Endoro>mkvmerge --output-charset utf-8 --ui-language en -o 10017_20120217195000.mkv 10017_20120217195000.mpg
    mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  8 2014 15:10:52
    '10017_20120217195000.mpg': Using the demultiplexer for the format 'MPEG transport stream'.
    '10017_20120217195000.mpg' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
    '10017_20120217195000.mpg' track 1: Using the output module for the format 'AC3'.
    The file '10017_20120217195000.mkv' has been opened for writing.
    '10017_20120217195000.mpg' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 1920/1080.
    Progress: 100%
    The cue entries (the index) are being written...
    Muxing took 47 seconds.
    
    C:\Users\Endoro>timecodeanalysis 10017_20120217195000.mkv
    Time code analysis for "10017_20120217195000.mkv"
    Progress: 100%
    Track ID 0: video (MPEG-4p10/AVC/h.264)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
          0 ms          1          0 ms           0 ms          1
         20 ms     103886    2077720 ms     2077720 ms     103887
         40 ms          1         40 ms     2077760 ms     103888
         60 ms          6        360 ms     2078120 ms     103894
         80 ms          1         80 ms     2078200 ms     103895
        140 ms          1        140 ms     2078340 ms     103896
        588 ms          1        588 ms     2078928 ms     103897
        980 ms          1        980 ms     2079908 ms     103898
    7128072 ms          1    7128072 ms     9207980 ms     103899
    Track ID 1: audio (AC3/EAC3)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
         32 ms      64939    2078048 ms     2078048 ms      64939
       1120 ms          1       1120 ms     2079168 ms      64940
    1983668 ms          1    1983668 ms     4062836 ms      64941
    5144416 ms          1    5144416 ms     9207252 ms      64942
    
    C:\Users\Endoro>mkvextract --output-charset utf-8 --ui-language en tracks 10017_20120217195000.mkv 0:10017_20120217195000.264 1:10017_20120217195000.ac3
    Extracting track 0 with the CodecID 'V_MPEG4/ISO/AVC' to the file '10017_20120217195000.264'. Container format: AVC/h.264 elementary stream
    Extracting track 1 with the CodecID 'A_AC3' to the file '10017_20120217195000.ac3'. Container format: Dolby Digital (AC3)
    Progress: 99%
    mtx ex: No error (type: N3mtx5mm_io13end_of_file_xE)
    Progress: 100%
    
    C:\Users\Endoro>mkvmerge --output-charset utf-8 --ui-language en -o 10017_20120217195000.Remux.mkv 10017_20120217195000.264 10017_20120217195000.ac3
    mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  8 2014 15:10:52
    '10017_20120217195000.264': Using the demultiplexer for the format 'AVC/h.264'.
    '10017_20120217195000.ac3': Using the demultiplexer for the format 'AC3'.
    '10017_20120217195000.264' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
    '10017_20120217195000.ac3' track 0: Using the output module for the format 'AC3'.
    The file '10017_20120217195000.Remux.mkv' has been opened for writing.
    '10017_20120217195000.264' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 1920/1080.
    Progress: 100%
    The cue entries (the index) are being written...
    Muxing took 43 seconds.
    
    C:\Users\Endoro>timecodeanalysis 10017_20120217195000.Remux.mkv
    Time code analysis for "10017_20120217195000.Remux.mkv"
    Progress: 100%
    Track ID 0: video (MPEG-4p10/AVC/h.264)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
         20 ms     103899    2077980 ms     2077980 ms     103899
    Track ID 1: audio (AC3/EAC3)
      duration     frames        Sum(t)        cSum(t)    cSum(f)
         32 ms      64942    2078144 ms     2078144 ms      64942
    
    C:\Users\Endoro>mediainfo 10017_20120217195000.*mkv
    General
    Unique ID                                : 214135067909871359475088890763684030342 (0xA118E9F82CD3921882BC5037D11F2786)
    Complete name                            : C:\Users\Endoro\10017_20120217195000.mkv
    Format                                   : Matroska
    Format version                           : Version 4 / Version 2
    File size                                : 3.57 GiB
    Duration                                 : 2h 33mn
    Overall bit rate                         : 3 335 Kbps
    Encoded date                             : UTC 2014-02-07 15:01:13
    Writing application                      : mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  8 2014 15:10:52
    Writing library                          : libebml v1.3.0 + libmatroska v1.4.1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4.0
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Format settings, GOP                     : M=4, N=28
    Codec ID                                 : V_MPEG4/ISO/AVC
    Bit rate                                 : 2 884 Kbps
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Variable
    Original frame rate                      : 25.000 fps
    Standard                                 : Component
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Interlaced
    Scan order                               : Bottom Field First
    Default                                  : Yes
    Forced                                   : No
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 2
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Mode extension                           : CM (complete main)
    Format settings, Endianness              : Big
    Codec ID                                 : A_AC3
    Duration                                 : 2h 33mn
    Bit rate mode                            : Constant
    Bit rate                                 : 384 Kbps
    Channel count                            : 6 channels
    Channel positions                        : Front: L C R, Side: L R, LFE
    Sampling rate                            : 48.0 KHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossy
    Delay relative to video                  : -588ms
    Stream size                              : 422 MiB (12%)
    Language                                 : German
    Default                                  : Yes
    Forced                                   : No
    
    General
    Unique ID                                : 213039916239423932916369749962828881306 (0xA045FED2C3F4659A938BD357E5711D9A)
    Complete name                            : C:\Users\Endoro\10017_20120217195000.Remux.mkv
    Format                                   : Matroska
    Format version                           : Version 4 / Version 2
    File size                                : 3.57 GiB
    Duration                                 : 34mn 38s
    Overall bit rate                         : 14.8 Mbps
    Encoded date                             : UTC 2014-02-07 15:10:17
    Writing application                      : mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  8 2014 15:10:52
    Writing library                          : libebml v1.3.0 + libmatroska v1.4.1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4.0
    Format settings, CABAC                   : Yes
    Format settings, ReFrames                : 4 frames
    Format settings, GOP                     : M=4, N=28
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 34mn 38s
    Bit rate                                 : 14.1 Mbps
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 fps
    Standard                                 : Component
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Interlaced
    Scan order                               : Bottom Field First
    Bits/(Pixel*Frame)                       : 0.272
    Stream size                              : 3.41 GiB (95%)
    Default                                  : Yes
    Forced                                   : No
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 2
    Format                                   : AC-3
    Format/Info                              : Audio Coding 3
    Mode extension                           : CM (complete main)
    Format settings, Endianness              : Big
    Codec ID                                 : A_AC3
    Duration                                 : 34mn 38s
    Bit rate mode                            : Constant
    Bit rate                                 : 384 Kbps
    Channel count                            : 6 channels
    Channel positions                        : Front: L C R, Side: L R, LFE
    Sampling rate                            : 48.0 KHz
    Bit depth                                : 16 bits
    Compression mode                         : Lossy
    Stream size                              : 95.1 MiB (3%)
    Default                                  : Yes
    Forced                                   : No
    Muxing directly TS --> MKV with preserved time codes leads to a defective file with a wrong duration and seeking doesn't work (10017_20120217195000.mkv).
    Muxing without time codes is working here. The resulting MKV plays fine (except the short start sequence with a destroyed GOP), you get the right duration and seeking also works (10017_20120217195000.Remux.mkv).

    Time code analysis may help in such cases. If you have a file with VFR, you can specifically change widely differing time codes.
    Quote Quote  
  16. Where does timecodeanalysis come from? (never heard of it)
    Quote Quote  
  17. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    "Analysis" is a simple evaluation of the frequency of frame durations. You can also calculate statistical deviations to remove or replace time codes behind the borders
    Quote Quote  
  18. got a link to the tool?
    Quote Quote  
  19. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    It's a simple Windows cmd shell 'Batch' script to count the frequencies and make some basic calculations. To get the time codes from ts/mpg I used ffprobe (very slow!) and for MKV mkvextract. My ffprobe script is not good enough for publishing , but for MKV:
    Code:
    @ECHO OFF &SETLOCAL disableDelayedExpansion
    SET "TCodeFile=%random%.txt"
    IF "%~1"=="" ECHO(Missing mkv name.&EXIT /b 1
    IF NOT EXIST "%~1" ECHO("%~1" not found.&EXIT /b 1
    ECHO(Time code analysis for "%~1"
    FOR /f "tokens=1*delims=:" %%a IN ('mkvmerge -i "%~1"^|findstr /nir "Track ID"') DO (
    	FOR /f "tokens=3delims=: " %%c IN ("%%~b") DO (
    		SET "tID%%a=%%c"
    		SET "dID%%c=%%b"
    		CALL SET "ParmLine=%%ParmLine%% %%c:"%temp%\%%c%TCodeFile%""
    	)
    )
    mkvextract timecodes_v2 "%~1" %ParmLine:~1% || EXIT /b 1
    FOR /f "tokens=1*delims==" %%a IN ('SET "tID"') DO CALL:processTrack "%%~b"
    FOR /f "tokens=1*delims==" %%a IN ('SET "tID"') DO DEL "%temp%\%%~b%TCodeFile%"
    GOTO:EOF
    
    :processTrack tID
    CALL ECHO(%%dID%~1%%
    IF NOT EXIST "%temp%\%~1%TCodeFile%" ECHO("%temp%\%~1%TCodeFile%" NOT found.&EXIT /b 1
    AWK "{f2=f1;f1=$1;if (NR>2) a[f1-f2]++}; END {printf(\"%%10s %%10s %%13s %%14s %%11s\", \"duration\",\"frames\",\"Sum(t)\",\"cSum(t)\",\"cSum(f)\n\");for (i in a) {sumt=i*a[i];csumt+=i*a[i];csumf+=a[i];printf(\"%%7s ms %%10s %%10s ms %%11s ms %%10s\n\",i,a[i],sumt,csumt,csumf)}}" "%temp%\%~1%TCodeFile%"
    EXIT /b
    PS: the best tool for cli statistics is SPSS.
    Quote Quote  
  20. @endoro
    I tried the workflow, but noticed a big sound shift from about 1 second.
    Clear to hear at 03:30, where the Chinese man says: "...how (see his mouth open)...entjeedentjee (after, closes is mouth)", before the next scene shows.

    I noticed big sound shifts also, when I used TsMuxer.
    Quote Quote  
  21. batch expert Endoro's Avatar
    Join Date
    Dec 2013
    Location
    Bozen
    Search PM
    The value of the original audio delay (-728 ms) is lost if you multiplex raw video/audio tracks. Just restore this delay to get a synchronous video.
    Quote Quote  
  22. There was a glitch in the TS movie. The easiest way was to use TS-Doctor and afterwards use avconv/ffmpeg. Using avconv also gave me fast skipping, which I missed with all other tools I used.
    Quote Quote  



Similar Threads

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