Opened 11 years ago

Closed 9 years ago

#2263 closed enhancement (fixed)

Read second SeekHead in Matroska files

Reported by: eelco Owned by:
Priority: wish Component: avformat
Version: git-master Keywords: mkv h264 bounty
Cc: rodger.combs@gmail.com Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I have an MKV file for which using -ss is very slow. It plays fine in players like VLC and MplayerX.

Normally, FFmpeg jumps to the keyframe before the seeking point and starts decoding from there. With this file, it seems to start at the beginning.

The sample file included is the first 15MB of a larger file. Seeking to a later point in the file is even slower.

ffprobe information (note there is a keyframe at 10.427)

> ./ffprobe -of compact -show_frames ~/Desktop/ffmpeg-ss-bug/slow-ss.mkv | grep 'video|key_frame=1'
ffprobe version N-49823-g7ff1a4b Copyright (c) 2007-2013 the FFmpeg developers
  built on Feb 12 2013 15:45:24 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Users/eelco/Projects/Beamer/FFmpeg/build --enable-gpl --enable-version3 --enable-libx264 --disable-shared --enable-static --enable-libtheora --enable-libvorbis --enable-libvo-aacenc --disable-doc --extra-cflags='-DMACOSX_DEPLOYMENT_TARGET=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -I/Users/eelco/Projects/Beamer/FFmpeg/build/include' --extra-ldflags='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -L/Users/eelco/Projects/Beamer/FFmpeg/build/lib'
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.102 / 54. 91.102
  libavformat    54. 62.100 / 54. 62.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 37.101 /  3. 37.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '/Users/eelco/Desktop/ffmpeg-ss-bug/slow-ss.mkv':
  Metadata:
    creation_time   : 2012-12-09 16:32:15
  Duration: 01:33:24.19, start: 0.000000, bitrate: 21 kb/s
    Chapter #0.0: start 0.000000, end 316.316000
    Metadata:
      title           : 00:00:00.000
    Chapter #0.1: start 316.316000, end 651.985000
    Metadata:
      title           : 00:05:16.316
    Chapter #0.2: start 651.985000, end 1186.310000
    Metadata:
      title           : 00:10:51.985
    Chapter #0.3: start 1186.310000, end 1669.835000
    Metadata:
      title           : 00:19:46.310
    Chapter #0.4: start 1669.835000, end 1970.552000
    Metadata:
      title           : 00:27:49.835
    Chapter #0.5: start 1970.552000, end 2434.974000
    Metadata:
      title           : 00:32:50.552
    Chapter #0.6: start 2434.974000, end 2811.976000
    Metadata:
      title           : 00:40:34.974
    Chapter #0.7: start 2811.976000, end 3120.534000
    Metadata:
      title           : 00:46:51.976
    Chapter #0.8: start 3120.534000, end 3535.157000
    Metadata:
      title           : 00:52:00.534
    Chapter #0.9: start 3535.157000, end 3623.411000
    Metadata:
      title           : 00:58:55.157
    Chapter #0.10: start 3623.411000, end 3859.314000
    Metadata:
      title           : 01:00:23.411
    Chapter #0.11: start 3859.314000, end 4259.672000
    Metadata:
      title           : 01:04:19.314
    Chapter #0.12: start 4259.672000, end 4530.317000
    Metadata:
      title           : 01:10:59.672
    Chapter #0.13: start 4530.317000, end 4869.782000
    Metadata:
      title           : 01:15:30.317
    Chapter #0.14: start 4869.782000, end 4968.630000
    Metadata:
      title           : 01:21:09.782
    Chapter #0.15: start 4968.630000, end 5604.192000
    Metadata:
      title           : 01:22:48.630
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32
    Metadata:
      title           : English TRUE-HD
    Stream #0:2(swe): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Metadata:
      title           : Swedish AC3
    Stream #0:3(swe): Subtitle: dvd_subtitle (default)
    Metadata:
      title           : Swedish
    Stream #0:4(eng): Subtitle: dvd_subtitle
    Metadata:
      title           : English
frame|media_type=video|key_frame=1|pkt_pts=0|pkt_pts_time=0.000000|pkt_dts=0|pkt_dts_time=0.000000|pkt_duration=N/A|pkt_duration_time=N/A|pkt_pos=6670|pkt_size=148182|width=1920|height=1080|pix_fmt=yuv420p|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|reference=3
frame|media_type=video|key_frame=1|pkt_pts=10427|pkt_pts_time=10.427000|pkt_dts=10427|pkt_dts_time=10.427000|pkt_duration=41|pkt_duration_time=0.041000|pkt_pos=13743718|pkt_size=99527|width=1920|height=1080|pix_fmt=yuv420p|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=250|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|reference=3
[matroska,webm @ 0x101806600] Read error

timing of -ss (about 6-8x slower than other MKVs)

> time ./ffmpeg "-ss" "11" "-i" ~/Desktop/ffmpeg-ss-bug/slow-ss.mkv  "-f" "image2" "-vframes" "1" /dev/null
ffmpeg version N-49823-g7ff1a4b Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 12 2013 15:45:24 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Users/eelco/Projects/Beamer/FFmpeg/build --enable-gpl --enable-version3 --enable-libx264 --disable-shared --enable-static --enable-libtheora --enable-libvorbis --enable-libvo-aacenc --disable-doc --extra-cflags='-DMACOSX_DEPLOYMENT_TARGET=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -I/Users/eelco/Projects/Beamer/FFmpeg/build/include' --extra-ldflags='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -L/Users/eelco/Projects/Beamer/FFmpeg/build/lib'
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.102 / 54. 91.102
  libavformat    54. 62.100 / 54. 62.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 37.101 /  3. 37.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '/Users/eelco/Desktop/ffmpeg-ss-bug/slow-ss.mkv':
  Metadata:
    creation_time   : 2012-12-09 16:32:15
  Duration: 01:33:24.19, start: 0.000000, bitrate: 21 kb/s
    Chapter #0.0: start 0.000000, end 316.316000
    Metadata:
      title           : 00:00:00.000
    Chapter #0.1: start 316.316000, end 651.985000
    Metadata:
      title           : 00:05:16.316
    Chapter #0.2: start 651.985000, end 1186.310000
    Metadata:
      title           : 00:10:51.985
    Chapter #0.3: start 1186.310000, end 1669.835000
    Metadata:
      title           : 00:19:46.310
    Chapter #0.4: start 1669.835000, end 1970.552000
    Metadata:
      title           : 00:27:49.835
    Chapter #0.5: start 1970.552000, end 2434.974000
    Metadata:
      title           : 00:32:50.552
    Chapter #0.6: start 2434.974000, end 2811.976000
    Metadata:
      title           : 00:40:34.974
    Chapter #0.7: start 2811.976000, end 3120.534000
    Metadata:
      title           : 00:46:51.976
    Chapter #0.8: start 3120.534000, end 3535.157000
    Metadata:
      title           : 00:52:00.534
    Chapter #0.9: start 3535.157000, end 3623.411000
    Metadata:
      title           : 00:58:55.157
    Chapter #0.10: start 3623.411000, end 3859.314000
    Metadata:
      title           : 01:00:23.411
    Chapter #0.11: start 3859.314000, end 4259.672000
    Metadata:
      title           : 01:04:19.314
    Chapter #0.12: start 4259.672000, end 4530.317000
    Metadata:
      title           : 01:10:59.672
    Chapter #0.13: start 4530.317000, end 4869.782000
    Metadata:
      title           : 01:15:30.317
    Chapter #0.14: start 4869.782000, end 4968.630000
    Metadata:
      title           : 01:21:09.782
    Chapter #0.15: start 4968.630000, end 5604.192000
    Metadata:
      title           : 01:22:48.630
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32
    Metadata:
      title           : English TRUE-HD
    Stream #0:2(swe): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Metadata:
      title           : Swedish AC3
    Stream #0:3(swe): Subtitle: dvd_subtitle (default)
    Metadata:
      title           : Swedish
    Stream #0:4(eng): Subtitle: dvd_subtitle
    Metadata:
      title           : English
Output #0, image2, to '/dev/null':
  Metadata:
    encoder         : Lavf54.62.100
    Chapter #0.0: start 0.000000, end 305.316000
    Metadata:
      title           : 00:00:00.000
    Chapter #0.1: start 305.316000, end 640.985000
    Metadata:
      title           : 00:05:16.316
    Chapter #0.2: start 640.985000, end 1175.310000
    Metadata:
      title           : 00:10:51.985
    Chapter #0.3: start 1175.310000, end 1658.835000
    Metadata:
      title           : 00:19:46.310
    Chapter #0.4: start 1658.835000, end 1959.552000
    Metadata:
      title           : 00:27:49.835
    Chapter #0.5: start 1959.552000, end 2423.974000
    Metadata:
      title           : 00:32:50.552
    Chapter #0.6: start 2423.974000, end 2800.976000
    Metadata:
      title           : 00:40:34.974
    Chapter #0.7: start 2800.976000, end 3109.534000
    Metadata:
      title           : 00:46:51.976
    Chapter #0.8: start 3109.534000, end 3524.157000
    Metadata:
      title           : 00:52:00.534
    Chapter #0.9: start 3524.157000, end 3612.411000
    Metadata:
      title           : 00:58:55.157
    Chapter #0.10: start 3612.411000, end 3848.314000
    Metadata:
      title           : 01:00:23.411
    Chapter #0.11: start 3848.314000, end 4248.672000
    Metadata:
      title           : 01:04:19.314
    Chapter #0.12: start 4248.672000, end 4519.317000
    Metadata:
      title           : 01:10:59.672
    Chapter #0.13: start 4519.317000, end 4858.782000
    Metadata:
      title           : 01:15:30.317
    Chapter #0.14: start 4858.782000, end 4957.630000
    Metadata:
      title           : 01:21:09.782
    Chapter #0.15: start 4957.630000, end 5593.192000
    Metadata:
      title           : 01:22:48.630
    Stream #0:0(eng): Video: mjpeg, yuvj420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame=    1 fps=0.5 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=0 drop=262    
video:47kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.045473%
        2.20 real         6.15 user         0.13 sys

See also #2245.

Attachments (1)

seekhead-at-end.mkv (1.7 MB ) - added by Carl Eugen Hoyos 11 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by eelco, 11 years ago

Example file uploaded to ftp://upload.ffmpeg.org/incoming as 2263-slow-ss.mkv

comment:2 by Carl Eugen Hoyos, 11 years ago

Iiuc, the sample you used is not complete but was cut with "dd".
Is the same problem also reproducible with the uncut (complete) mkv file?

comment:3 by eelco, 11 years ago

Yes. I originally noticed the problem because I was trying to make a frame image at about 30 minutes, which took several minutes.

comment:4 by Carl Eugen Hoyos, 11 years ago

Can I get the original file somehow?

comment:5 by eelco, 11 years ago

I’m uploading it now as 2263-slow-ss-full.mkv but it’s 11GB, so it will take a while :)

comment:6 by eelco, 11 years ago

Done.

comment:7 by Carl Eugen Hoyos, 11 years ago

Component: undeterminedavformat
Status: newopen

I can confirm that seeking in the file takes ridiculously long, this can be fixed by remuxing (both FFmpeg and mkvmerge). I don't know enough about Matroska to explain what is "wrong" about the file but mkvalidator reports the following:

$ mkvalidator 2263-slow-ss-full.mkv
WRN103: Unnecessary secondary SeekHead was found at 11568150341
WRN861: The SegmentInfo is not referenced in the main SeekHead
WRN861: The TrackInfo is not referenced in the main SeekHead
WRN861: The Cues is not referenced in the main SeekHead
WRN861: The Chapters is not referenced in the main SeekHead
WRN0D0: There are 4618 bytes of void data................................

mkvalidator 0.4.0: the file appears to be valid
        file created with libebml v1.2.3 + libmatroska v1.3.0 / mkvmerge v5.8.0 ('No Sleep / Pillow') built on Sep  2 2012 15:37:04
$ time ffmpeg -ss 0:30:00 -i 2263-slow-ss-full.mkv -vframes 1 out.png
ffmpeg version N-49888-gafe30fe Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb 13 2013 12:23:23 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.103 / 54. 91.103
  libavformat    54. 63.100 / 54. 63.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 37.101 /  3. 37.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from '2263-slow-ss-full.mkv':
  Metadata:
    creation_time   : 2012-12-09 16:32:15
  Duration: 01:33:24.19, start: 0.000000, bitrate: 16513 kb/s
    Chapter #0.0: start 0.000000, end 316.316000
    Metadata:
      title           : 00:00:00.000
    Chapter #0.1: start 316.316000, end 651.985000
    Metadata:
      title           : 00:05:16.316
    Chapter #0.2: start 651.985000, end 1186.310000
    Metadata:
      title           : 00:10:51.985
    Chapter #0.3: start 1186.310000, end 1669.835000
    Metadata:
      title           : 00:19:46.310
    Chapter #0.4: start 1669.835000, end 1970.552000
    Metadata:
      title           : 00:27:49.835
    Chapter #0.5: start 1970.552000, end 2434.974000
    Metadata:
      title           : 00:32:50.552
    Chapter #0.6: start 2434.974000, end 2811.976000
    Metadata:
      title           : 00:40:34.974
    Chapter #0.7: start 2811.976000, end 3120.534000
    Metadata:
      title           : 00:46:51.976
    Chapter #0.8: start 3120.534000, end 3535.157000
    Metadata:
      title           : 00:52:00.534
    Chapter #0.9: start 3535.157000, end 3623.411000
    Metadata:
      title           : 00:58:55.157
    Chapter #0.10: start 3623.411000, end 3859.314000
    Metadata:
      title           : 01:00:23.411
    Chapter #0.11: start 3859.314000, end 4259.672000
    Metadata:
      title           : 01:04:19.314
    Chapter #0.12: start 4259.672000, end 4530.317000
    Metadata:
      title           : 01:10:59.672
    Chapter #0.13: start 4530.317000, end 4869.782000
    Metadata:
      title           : 01:15:30.317
    Chapter #0.14: start 4869.782000, end 4968.630000
    Metadata:
      title           : 01:21:09.782
    Chapter #0.15: start 4968.630000, end 5604.192000
    Metadata:
      title           : 01:22:48.630
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x1080, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1(eng): Audio: truehd, 48000 Hz, 7.1, s32
    Metadata:
      title           : English TRUE-HD
    Stream #0:2(swe): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Metadata:
      title           : Swedish AC3
    Stream #0:3(swe): Subtitle: dvd_subtitle (default)
    Metadata:
      title           : Swedish
    Stream #0:4(eng): Subtitle: dvd_subtitle
    Metadata:
      title           : English
Output #0, image2, to 'out.png':
  Metadata:
    encoder         : Lavf54.63.100
    Chapter #0.0: start 0.000000, end 170.552000
    Metadata:
      title           : 00:27:49.835
    Chapter #0.1: start 170.552000, end 634.974000
    Metadata:
      title           : 00:32:50.552
    Chapter #0.2: start 634.974000, end 1011.976000
    Metadata:
      title           : 00:40:34.974
    Chapter #0.3: start 1011.976000, end 1320.534000
    Metadata:
      title           : 00:46:51.976
    Chapter #0.4: start 1320.534000, end 1735.157000
    Metadata:
      title           : 00:52:00.534
    Chapter #0.5: start 1735.157000, end 1823.411000
    Metadata:
      title           : 00:58:55.157
    Chapter #0.6: start 1823.411000, end 2059.314000
    Metadata:
      title           : 01:00:23.411
    Chapter #0.7: start 2059.314000, end 2459.672000
    Metadata:
      title           : 01:04:19.314
    Chapter #0.8: start 2459.672000, end 2730.317000
    Metadata:
      title           : 01:10:59.672
    Chapter #0.9: start 2730.317000, end 3069.782000
    Metadata:
      title           : 01:15:30.317
    Chapter #0.10: start 3069.782000, end 3168.630000
    Metadata:
      title           : 01:21:09.782
    Chapter #0.11: start 3168.630000, end 3804.192000
    Metadata:
      title           : 01:22:48.630
    Stream #0:0(eng): Video: png, rgb24, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=0 drop=43155
video:4216kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.000510%

real    2m42.727s
user    15m2.405s
sys     0m6.223s
Last edited 11 years ago by Carl Eugen Hoyos (previous) (diff)

comment:8 by Carl Eugen Hoyos, 11 years ago

Priority: normalwish
Reproduced by developer: set
Summary: MKV: keyframe not used when using -ss on input?Read second SeekHead in Matroska files
Type: defectenhancement

The file has one SeekHead at the beginning and a second one at the end, FFmpeg only reads the first one (that apparently contains no reference to the second one). It is unknown how such a sample can be produced.

comment:9 by Carl Eugen Hoyos, 11 years ago

$ mkvinfo 2263-slow-ss-full.mkv
+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ EBML maximum ID length: 4
|+ EBML maximum size length: 8
|+ Doc type: matroska
|+ Doc type version: 2
|+ Doc type read version: 2
+ Segment, size 11568150356
|+ Seek head (subentries will be skipped)
|+ EbmlVoid (size: 28)
|+ Chapters
| + EditionEntry
|  + ChapterAtom
|   + ChapterUID: 4643754908665286289
|   + ChapterTimeStart: 00:00:00.000000000
|   + ChapterDisplay
|    + ChapterString: 00:00:00.000
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 776680746040114083
|   + ChapterTimeStart: 00:05:16.316000000
|   + ChapterDisplay
|    + ChapterString: 00:05:16.316
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 7936573191005558681
|   + ChapterTimeStart: 00:10:51.985000000
|   + ChapterDisplay
|    + ChapterString: 00:10:51.985
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 6360485584497157554
|   + ChapterTimeStart: 00:19:46.310000000
|   + ChapterDisplay
|    + ChapterString: 00:19:46.310
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 2145345886638826677
|   + ChapterTimeStart: 00:27:49.835000000
|   + ChapterDisplay
|    + ChapterString: 00:27:49.835
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 4051148929050008205
|   + ChapterTimeStart: 00:32:50.552000000
|   + ChapterDisplay
|    + ChapterString: 00:32:50.552
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 6076738213057105045
|   + ChapterTimeStart: 00:40:34.974000000
|   + ChapterDisplay
|    + ChapterString: 00:40:34.974
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 12712555268836147128
|   + ChapterTimeStart: 00:46:51.976000000
|   + ChapterDisplay
|    + ChapterString: 00:46:51.976
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 13765820060876751293
|   + ChapterTimeStart: 00:52:00.534000000
|   + ChapterDisplay
|    + ChapterString: 00:52:00.534
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 139259153207598227
|   + ChapterTimeStart: 00:58:55.157000000
|   + ChapterDisplay
|    + ChapterString: 00:58:55.157
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 12150923411689504900
|   + ChapterTimeStart: 01:00:23.411000000
|   + ChapterDisplay
|    + ChapterString: 01:00:23.411
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 1907332086412795570
|   + ChapterTimeStart: 01:04:19.314000000
|   + ChapterDisplay
|    + ChapterString: 01:04:19.314
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 18177291500090400424
|   + ChapterTimeStart: 01:10:59.672000000
|   + ChapterDisplay
|    + ChapterString: 01:10:59.672
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 13764324979318202552
|   + ChapterTimeStart: 01:15:30.317000000
|   + ChapterDisplay
|    + ChapterString: 01:15:30.317
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 6136948946309581968
|   + ChapterTimeStart: 01:21:09.782000000
|   + ChapterDisplay
|    + ChapterString: 01:21:09.782
|    + ChapterLanguage: und
|  + ChapterAtom
|   + ChapterUID: 6007540025134916797
|   + ChapterTimeStart: 01:22:48.630000000
|   + ChapterDisplay
|    + ChapterString: 01:22:48.630
|    + ChapterLanguage: und
|  + EditionUID: 14146429012029870465
|+ EbmlVoid (size: 3341)
|+ Segment information
| + Timecode scale: 1000000
| + Muxing application: libebml v1.2.3 + libmatroska v1.3.0
| + Writing application: mkvmerge v5.8.0 ('No Sleep / Pillow') built on Sep  2 2012 15:37:04
| + Duration: 5604.192s (01:33:24.192)
| + Date: Sun Dec  9 16:32:15 2012 UTC
| + Segment UID: 0x86 0x37 0x2f 0xf9 0xe5 0x6a 0x1e 0x85 0x88 0x3e 0x67 0xc2 0xa5 0xa6 0x1f 0xb3
|+ Segment tracks
| + A track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Track type: video
|  + Lacing flag: 0
|  + MinCache: 1
|  + Codec ID: V_MPEG4/ISO/AVC
|  + CodecPrivate, length 41 (h.264 profile: High @L4.1)
|  + Default duration: 41.708ms (23.976 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1920
|   + Pixel height: 1080
|   + Display width: 1920
|   + Display height: 1080
|  + Content encodings
|   + Content encoding
|    + Content compression
|     + Algorithm: 3 (header removal)
|     + Settings: length 1, data: 0x00
| + A track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 124107657
|  + Track type: audio
|  + Default flag: 0
|  + MinCache: 1
|  + Codec ID: A_TRUEHD
|  + Name: English TRUE-HD
|  + Audio track
|   + Sampling frequency: 48000
|   + Channels: 8
| + A track
|  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
|  + Track UID: 2618188706
|  + Track type: audio
|  + Codec ID: A_AC3
|  + Default duration: 32.000ms (31.250 frames/fields per second for a video track)
|  + Language: swe
|  + Name: Swedish AC3
|  + Audio track
|   + Sampling frequency: 48000
|   + Channels: 6
|  + Content encodings
|   + Content encoding
|    + Content compression
|     + Algorithm: 3 (header removal)
|     + Settings: length 2, data: 0x0b 0x77
| + A track
|  + Track number: 4 (track ID for mkvmerge & mkvextract: 3)
|  + Track UID: 3823762597
|  + Track type: subtitles
|  + Lacing flag: 0
|  + Codec ID: S_VOBSUB
|  + CodecPrivate, length 348
|  + Language: swe
|  + Name: Swedish
|  + Content encodings
|   + Content encoding
|    + Content compression
| + A track
|  + Track number: 5 (track ID for mkvmerge & mkvextract: 4)
|  + Track UID: 556225960
|  + Track type: subtitles
|  + Default flag: 0
|  + Lacing flag: 0
|  + Codec ID: S_VOBSUB
|  + CodecPrivate, length 348
|  + Name: English
|  + Content encodings
|   + Content encoding
|    + Content compression
|+ EbmlVoid (size: 1241)
|+ Cluster

by Carl Eugen Hoyos, 11 years ago

Attachment: seekhead-at-end.mkv added

comment:10 by Carl Eugen Hoyos, 11 years ago

mosu has kindly produced a small sample that allows to reproduce the problem:

$ mkvmerge -o out.mkv seekhead-at-end.mkv
$ ffmpeg -ss 26.4 -i seekhead-at-end.mkv -vframes 1 outslow.png
ffmpeg version N-51078-g6128d33 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 19 2013 00:53:13 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 19.101 / 52. 19.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 47.103 /  3. 47.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from 'seekhead-at-end.mkv':
  Metadata:
    creation_time   : 2013-03-18 12:09:06
  Duration: 00:00:30.24, start: 0.000000, bitrate: 469 kb/s
    Chapter #0.0: start 0.000000, end 15.000000
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 15.000000, end 30.241000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 754.567000, end 30.241000
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 1200.000000, end 30.241000
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 3723.040000, end 30.241000
    Metadata:
      title           : Chapter 05
    Stream #0:0: Video: h264 (Main), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp (default)
Output #0, image2, to 'outslow.png':
  Metadata:
    encoder         : Lavf55.0.100
    Chapter #0.0: start 0.000000, end 3.841000
    Metadata:
      title           : Chapter 02
    Chapter #0.1: start 728.167000, end 3.841000
    Metadata:
      title           : Chapter 03
    Chapter #0.2: start 1173.600000, end 3.841000
    Metadata:
      title           : Chapter 04
    Chapter #0.3: start 3696.640000, end 3.841000
    Metadata:
      title           : Chapter 05
    Stream #0:0: Video: png, rgb24, 640x352 [SAR 1:1 DAR 20:11], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A dup=0 drop=631
video:128kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.016844%

real    0m0.248s
user    0m0.827s
sys     0m0.021s
$ ffmpeg -ss 26.4 -i out.mkv -vframes 1 outfast.png
ffmpeg version N-51078-g6128d33 Copyright (c) 2000-2013 the FFmpeg developers
  built on Mar 19 2013 00:53:13 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --disable-indev=jack
  libavutil      52. 19.101 / 52. 19.101
  libavcodec     55.  1.100 / 55.  1.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 47.103 /  3. 47.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from 'out.mkv':
  Metadata:
    creation_time   : 2013-03-18 23:50:20
  Duration: 00:00:30.24, start: 0.000000, bitrate: 468 kb/s
    Chapter #0.0: start 0.000000, end 15.000000
    Metadata:
      title           : Chapter 01
    Chapter #0.1: start 15.000000, end 30.241000
    Metadata:
      title           : Chapter 02
    Chapter #0.2: start 754.567000, end 30.241000
    Metadata:
      title           : Chapter 03
    Chapter #0.3: start 1200.000000, end 30.241000
    Metadata:
      title           : Chapter 04
    Chapter #0.4: start 3723.040000, end 30.241000
    Metadata:
      title           : Chapter 05
    Stream #0:0: Video: h264 (Main), yuv420p, 640x352 [SAR 1:1 DAR 20:11], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp (default)
Output #0, image2, to 'outfast.png':
  Metadata:
    encoder         : Lavf55.0.100
    Chapter #0.0: start 0.000000, end 3.841000
    Metadata:
      title           : Chapter 02
    Chapter #0.1: start 728.167000, end 3.841000
    Metadata:
      title           : Chapter 03
    Chapter #0.2: start 1173.600000, end 3.841000
    Metadata:
      title           : Chapter 04
    Chapter #0.3: start 3696.640000, end 3.841000
    Metadata:
      title           : Chapter 05
    Stream #0:0: Video: png, rgb24, 640x352 [SAR 1:1 DAR 20:11], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> png)
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:128kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.016844%

real    0m0.040s
user    0m0.033s
sys     0m0.018s

comment:11 by eelco, 10 years ago

Is anybody working or planning to work on this by any chance?

comment:12 by eelco, 10 years ago

Keywords: bounty added

I’d like to offer a $100 bounty for implementing this.

comment:13 by Carl Eugen Hoyos, 9 years ago

Resolution: fixed
Status: openclosed

Fixed by Michael in a3920181

comment:14 by Ridley Combs, 9 years ago

Resolution: fixed
Status: closedreopened

Not quite. a3920181 is a partial fix that solves a more serious problem when -copyts or -c copy are used (wherein the seek operation previously would have no effect, and now proceeds somewhat slowly). I have a patch on the ML that fixes this slow-seeking issue caused by failure to read the second SeekHead, but it hasn't been applied yet because we need to double-check some edge cases first.
Oh, and a3920181 may speed up seeking in these files, but not by as much as reading the second SeekHead would.

comment:15 by Ridley Combs, 9 years ago

Cc: rodger.combs@gmail.com added

comment:16 by Michael Niedermayer, 9 years ago

Is there still an issue remaining after cac2295b21519d5a5320fe0787b5fd2b65eb1f8c ?

comment:17 by eelco, 9 years ago

Resolution: fixed
Status: reopenedclosed

No, this works! Thanks! I’ll contact wm4 regarding the bounty.

Note: See TracTickets for help on using tickets.