Opened 5 years ago

Closed 4 years ago

#3147 closed defect (fixed)

H264 - Wrong field order

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

Description

Summary of the bug:
This sample is top field first but ffmpeg seems to detect it as bottom field first.

How to reproduce:

% ffprobe.exe -show_frames VIDEO_Panasonic_AG_HPX_600.MXF
ffprobe version N-58134-g571a99d Copyright (c) 2007-2013 the FFmpeg developers
  built on Nov 16 2013 18:01:42 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-libass --enable-libbluray --enable-libcaca --enable-libfreetype --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-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 53.100 / 52. 53.100
  libavcodec     55. 43.100 / 55. 43.100
  libavformat    55. 21.100 / 55. 21.100
  libavdevice    55.  5.100 / 55.  5.100
  libavfilter     3. 91.100 /  3. 91.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
[mxf @ 047cc640] material track 2: no corresponding source track found
[h264 @ 047de940] Overread VUI by 5 bits
    Last message repeated 1 times
[mxf @ 047cc640] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, mxf, from 'VIDEO_Panasonic_AG_HPX_600.MXF':
  Metadata:
    uid             : 7ddd2bbf-701b-4733-b70f-1ce186dfc582
    generation_uid  : 2badcdf8-04f8-48df-a76c-52f7ea9a15fa
    company_name    : Panasonic
    product_name    : P2
    product_version : 2.0
    product_uid     : 060e2b34-0401-0109-0e0e-010101000001
    modification_date: 2012-12-12 15:03:24
    timecode        : 01:04:54:18
  Duration: 00:00:41.72, start: 0.000000, bitrate: 113670 kb/s
    Stream #0:0: Video: h264 (High 4:2:2 Intra), yuv422p10le(pc, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 50 tbc
[h264 @ 048422e0] Overread VUI by 5 bits
[FRAME]
media_type=video
key_frame=1
pkt_pts=N/A
pkt_pts_time=N/A
pkt_dts=N/A
pkt_dts_time=N/A
pkt_duration=1
pkt_duration_time=0.040000
pkt_pos=32768
pkt_size=568832
width=1920
height=1080
pix_fmt=yuv422p10le
sample_aspect_ratio=1:1
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=1
top_field_first=0
repeat_pict=0
[/FRAME]
...

Original ticket: https://trac.mpc-hc.org/ticket/3732.

Change History (4)

comment:1 Changed 5 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords h264 added

Is there an application that correctly shows top-field-first?

h->sps.pic_struct_present_flag is set, h->sei_pic_struct is set to SEI_PIC_STRUCT_FRAME, mxf does not set descriptor->field_dominance afaict.

comment:2 Changed 5 years ago by Underground78

Hmm, MediaInfo? seems to get that info right but it might be just luck.

comment:3 Changed 5 years ago by t.rapp

I also stumbled over this problem a few weeks ago. From looking at the source and some small debugging it seems that MediaInfo? derives the field order from the picture "bottom_field_flag":

Recommendation H.264 (https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.264-200305-S!!PDF-E&type=items) page 80:

"""
bottom_field_flag equal to 1 specifies that the slice is part of a coded
bottom field. bottom_field_flag equal to 0 specifies that the picture is a
coded top field. When this syntax element is not present for the current
slice, it shall be inferred to be equal to 0.
"""

FFmpeg relies only on the information in h->sei_pic_struct. When trying to use h->picture_structure I stumble over the issue that FFmpeg defaults to h->picture_structure = PICT_FRAME when the bottom_field_flag is absent instead of h->picture_structure = PICT_TOP_FIELD as mentioned in the specs. But then I am unsure how to differ between interlaced and non-interlaced data.

Last edited 5 years ago by t.rapp (previous) (diff)

comment:4 Changed 4 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in 2b6567722a48656c526ca2d6c1dcab88be3c18f7 by Thomas Mundt

Note: See TracTickets for help on using tickets.