Opened 10 years ago

Last modified 4 months ago

#3705 open defect

Seeking fails for H264 file

Reported by: Aleksoid1978 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: h264
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
Sample: ​http://aleksoid.voserver.net/Sample/H264/no_recovery_ffmpeg.m2ts

Ticket #3652 fixed(decoding is good), but seek is not working
How to reproduce:

% ffplay.exe no_recovery_ffmpeg.m2ts
ffplay version N-63843-g6d40849 Copyright (c) 2003-2014 the FFmpeg developers
  built on Jun  8 2014 22:02:04 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-li
bass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --
enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --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      52. 89.100 / 52. 89.100
  libavcodec     55. 66.100 / 55. 66.100
  libavformat    55. 42.101 / 55. 42.101
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  6.100 /  4.  6.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mpegts, from 'no_recovery_ffmpeg.m2ts': sq=    0B f=0/0
  Duration: 00:01:58.20, start: 4328.545078, bitrate: 13543 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
[h264 @ 0464ce20] mmco: unref short failure  49KB sq=    0B f=0/0
    Last message repeated 1 times
[h264 @ 0464c600] mmco: unref short failure   0KB sq=    0B f=0/0
[h264 @ 0464c600] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0464dc60] reference picture missing during reorder
[h264 @ 0464dc60] Missing reference picture, default is 65512
[h264 @ 045677c0] mmco: unref short failure
[h264 @ 045677c0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0464dc60] reference picture missing during reorder
[h264 @ 0464dc60] Missing reference picture, default is 65512
[h264 @ 0464dc60] reference picture missing during reorderB f=0/0
[h264 @ 0464dc60] Missing reference picture, default is 65512
[h264 @ 0464dc60] reference picture missing during reorder
[h264 @ 0464dc60] Missing reference picture, default is 65512
[h264 @ 0464ce20] mmco: unref short failure 433KB sq=    0B f=0/0
[h264 @ 0464ce20] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 04566700] mmco: unref short failure
[h264 @ 04566700] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 05540a80] Missing reference picture, default is 00B f=0/0
[h264 @ 0464c600] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0464c600] Missing reference picture, default is 0
    Last message repeated 1 times
[h264 @ 05540a80] Missing reference picture, default is 0
[h264 @ 0464dc60] mmco: unref short failure
[h264 @ 0464c600] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0464c600] Missing reference picture, default is 0
    Last message repeated 1 times
[h264 @ 04566d00] reference picture missing during reorder
[h264 @ 04566d00] Missing reference picture, default is 65540
[h264 @ 05540a80] Missing reference picture, default is 0
[h264 @ 0464c600] reference picture missing during reorderB f=0/0
    Last message repeated 1 times
[h264 @ 0464c600] Missing reference picture, default is 0
    Last message repeated 1 times
[h264 @ 04566d00] reference picture missing during reorder
[h264 @ 04566d00] Missing reference picture, default is 65540
[h264 @ 05540a80] Missing reference picture, default is 00B f=0/0
[h264 @ 0464c600] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0464c600] Missing reference picture, default is 0
    Last message repeated 1 times
[h264 @ 04566d00] reference picture missing during reorder
[h264 @ 04566d00] Missing reference picture, default is 65540
[h264 @ 04566d00] reference picture missing during reorder
[h264 @ 04566d00] Missing reference picture, default is 65540
[h264 @ 0464c600] mmco: unref short failure   0KB sq=    0B f=0/0
[h264 @ 0464c600] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0464dc60] mmco: unref short failure
[h264 @ 0464dc60] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 0464c600] mmco: unref short failure 424KB sq=    0B f=0/0
[h264 @ 0464ce20] mmco: unref short failure  29KB sq=    0B f=0/0
[h264 @ 045677c0] reference picture missing during reorder
[h264 @ 045677c0] Missing reference picture, default is 65542
[h264 @ 04567fe0] mmco: unref short failure
[h264 @ 045677c0] reference picture missing during reorder
[h264 @ 045677c0] Missing reference picture, default is 65542
[h264 @ 045677c0] reference picture missing during reorder
[h264 @ 045677c0] Missing reference picture, default is 65542
[h264 @ 045677c0] reference picture missing during reorderB f=0/0
[h264 @ 045677c0] Missing reference picture, default is 65542

After pressing RIGHT/LEFT key - picture freezes.

Attachments (1)

no_recovery_ffmpeg_cut.h264 (2.4 MB ) - added by Carl Eugen Hoyos 9 years ago.

Change History (17)

comment:1 by Carl Eugen Hoyos, 10 years ago

Component: ffplayundetermined
Reproduced by developer: set
Status: newopen
Summary: FFPlay cannot seek H264 fileSeeking fails for H264 file
Version: unspecifiedgit-master
$ ffmpeg -ss 0.1 -i no_recovery_ffmpeg_cut.h264 out.avi
ffmpeg version N-63852-gf341340 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun  9 2014 16:59:00 with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl
  libavutil      52. 89.100 / 52. 89.100
  libavcodec     55. 66.100 / 55. 66.100
  libavformat    55. 42.101 / 55. 42.101
  libavdevice    55. 13.101 / 55. 13.101
  libavfilter     4.  7.100 /  4.  7.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
no_recovery_ffmpeg_cut.h264: could not seek to position 0.100
Input #0, h264, from 'no_recovery_ffmpeg_cut.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1200k tbn, 47.95 tbc
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf55.42.101
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc55.66.100 mpeg4
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> mpeg4 (mpeg4))
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=0.0 Lsize=       6kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

comment:2 by Aleksoid1978, 10 years ago

There is progress on this issue ??

comment:3 by Aleksoid1978, 10 years ago

There is progress on this issue ??

comment:4 by Aleksoid1978, 10 years ago

There is progress on this issue ??

comment:5 by Aleksoid1978, 9 years ago

Old link is dead.
New link - https://yadi.sk/i/jteUfal9hY7QR

comment:6 by Aleksoid1978, 9 years ago

There is progress on this issue ??

by Carl Eugen Hoyos, 9 years ago

Attachment: no_recovery_ffmpeg_cut.h264 added

comment:7 by Carl Eugen Hoyos, 9 years ago

Workaround is to use -flags2 +showall

comment:8 by Aleksoid1978, 9 years ago

It's can give an artifact after seeking, but PotPlayer & Microsoft DTV-DVD Video decoder seeking normal.

comment:10 by v0lt, 6 years ago

After searching, I get this log

Reinit context to 1920x1088, pix_fmt: dxva2_vld
[h264 @ 000000000f00e0c0] co located POCs unavailable
[h264 @ 000000000f00e0c0] co located POCs unavailable
[h264 @ 000000000f00e0c0] co located POCs unavailable
[h264 @ 000000000f00e0c0] co located POCs unavailable
[h264 @ 000000000f00e0c0] mmco: unref short failure
[h264 @ 000000000f00e0c0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 000000000f00e0c0] reference picture missing during reorder
[h264 @ 000000000f00e0c0] Missing reference picture, default is 65534
[h264 @ 000000000f00e0c0] reference picture missing during reorder
[h264 @ 000000000f00e0c0] Missing reference picture, default is 65534
[h264 @ 000000000f00e0c0] reference picture missing during reorder
[h264 @ 000000000f00e0c0] Missing reference picture, default is 65534
[h264 @ 000000000f00e0c0] reference picture missing during reorder
[h264 @ 000000000f00e0c0] Missing reference picture, default is 65534
[h264 @ 000000000f00e0c0] mmco: unref short failure
[h264 @ 000000000f00e0c0] number of reference frames (0+4) exceeds max (3; probably corrupt input), discarding one
[h264 @ 000000000f00e0c0] mmco: unref short failure

On line h->cur_pic_ptr->recovered |= 1; I get the following data.

err == 0
h->short_ref_count == 3
pps_ref_count[0] == 4
pps_ref_count[1] == 1
h->avctx->has_b_frames == 2
h->picture_structure == PICT_FRAME
h->has_recovery_point == 0

I see two ways to change the check.
Replace 2 with 3

h->short_ref_count<=3

or 2 with 4.

pps_ref_count[0] <= 4 && pps_ref_count[1] <= 1 && h->avctx->has_b_frames

But I do not know which one is more correct.

Last edited 6 years ago by v0lt (previous) (diff)

comment:11 by Carl Eugen Hoyos, 6 years ago

Component: undeterminedavcodec
Keywords: h264 added

comment:12 by v0lt, 6 years ago

Another more radical patch - https://sourceforge.net/p/mpcbe/code/4315/
We haven't found any problems with it yet. If anyone has information, why not do this, please write here.

comment:13 by Carl Eugen Hoyos, 6 years ago

Not every H.264 I-frame is a recovery point.
Please understand that patches - made with git format-patch - can only be discussed on the development mailing list.

comment:14 by v0lt, 5 years ago

Yes. You are right all three patches do not work on NVIDIA GeForce 9500 GS (PureVideo Feature Set A (VP2)).
But on new cards (like the NVIDIA GTX 950), all three patches work well.

comment:15 by Aleksoid1978, 5 years ago

Moment - not working with DXVA2 decoder on NVIDIA GeForce? 9500 GS, after seeking artefact on screen.

comment:16 by Balling, 4 months ago

There are no IDR frames in this file, and only recovery on some non-IDR frames. First of all this is not valid bistream: per the ITU-T H.264 specs
7.4.1.2.2
"A bitstream conforming to this Recommendation | International Standard consists of one or more coded video sequences. The first access unit of each coded video sequence is an IDR access unit."
To clarify that the above applies to decoding order, not display order:
3.64
"The first picture of each coded video sequence in decoding order is an IDR picture"

mmco: unref short failure

is evidense of that.

If you need to decode this file you must actually at least insert recovery points SEIs anywhere they are needed. Yet the file has no recovery points.

Note: See TracTickets for help on using tickets.