[FFmpeg-trac] #8991(ffmpeg:new): Incorrect field order indication when encoding interlace top field first using V210
FFmpeg
trac at avcodec.org
Wed Nov 18 12:15:06 EET 2020
#8991: Incorrect field order indication when encoding interlace top field first
using V210
-------------------------------------+-------------------------------------
Reporter: | Type: defect
JulietDeltaGolf |
Status: new | Priority: critical
Component: ffmpeg | Version: git-
| master
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Hello,
While transcoding MPEG2(MXF) into V210(MOV) incorrect metadata about field
order is stored in the MOV wrapper :
{{{
$ ./ffmpeg.exe -y -i /c/Temp/testfile.mxf -map 0:v -filter:v
"crop=720:576:0:32,setdar=4/3" -codec:v v210 -f mov /c/Temp/invalidmov.mxf
ffmpeg version N-99929-gbb7bb440c2 Copyright (c) 2000-2020 the FFmpeg
developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-nonfree
libavutil 56. 60.100 / 56. 60.100
libavcodec 58.112.103 / 58.112.103
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 90.100 / 7. 90.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Guessed Channel Layout for Input Stream #0.1 : 4.0
Input #0, mxf, from 'C:/Temp/testfile.mxf':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 58.45.100
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
modification_date: 2020-11-17T11:16:08.000000Z
material_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE100
timecode : 10:00:00:00
Duration: 00:00:01.00, start: 0.000000, bitrate: 54952 kb/s
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, top first),
720x608 [SAR 608:405 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
Side data:
cpb: bitrate max/min/avg: 50000000/0/0 buffer size: 2015232
vbv_delay: N/A
Stream #0:1: Audio: pcm_s24le, 48000 Hz, 4.0, s32 (24 bit), 4608 kb/s
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> v210 (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'C:/Temp/invalidmov.mxf':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 58.45.100
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
modification_date: 2020-11-17T11:16:08.000000Z
material_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE100
timecode : 10:00:00:00
encoder : Lavf58.64.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p(tv, top coded
first (swapped)), 720x576 [SAR 16:15 DAR 4:3], q=2-31, 221184 kb/s, 0.04
fps, 12800 tbn, 25 tbc
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
encoder : Lavc58.112.103 v210
frame= 25 fps=0.0 q=-0.0 Lsize= 27002kB time=00:00:00.96
bitrate=230394.3kbits/s speed=20.2x
video:27000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.005657%
}}}
The quick and dirty fix is to manually set the correct field order :
{{{
$ ./ffmpeg.exe -y -i /c/Temp/testfile.mxf -map 0:v -filter:v
"crop=720:576:0:32,setdar=4/3" -codec:v v210 -field_order tt -f mov
/c/Temp/validmov.mxf
ffmpeg version N-99929-gbb7bb440c2 Copyright (c) 2000-2020 the FFmpeg
developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-nonfree
libavutil 56. 60.100 / 56. 60.100
libavcodec 58.112.103 / 58.112.103
libavformat 58. 64.100 / 58. 64.100
libavdevice 58. 11.102 / 58. 11.102
libavfilter 7. 90.100 / 7. 90.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
libpostproc 55. 8.100 / 55. 8.100
Guessed Channel Layout for Input Stream #0.1 : 4.0
Input #0, mxf, from 'C:/Temp/testfile.mxf':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 58.45.100
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
modification_date: 2020-11-17T11:16:08.000000Z
material_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE100
timecode : 10:00:00:00
Duration: 00:00:01.00, start: 0.000000, bitrate: 54952 kb/s
Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, top first),
720x608 [SAR 608:405 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
Side data:
cpb: bitrate max/min/avg: 50000000/0/0 buffer size: 2015232
vbv_delay: N/A
Stream #0:1: Audio: pcm_s24le, 48000 Hz, 4.0, s32 (24 bit), 4608 kb/s
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
Stream mapping:
Stream #0:0 -> #0:0 (mpeg2video (native) -> v210 (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'C:/Temp/validmov.mxf':
Metadata:
operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
uid : adab4424-2f25-4dc7-92ff-29bd000c0000
generation_uid : adab4424-2f25-4dc7-92ff-29bd000c0001
company_name : FFmpeg
product_name : OP1a Muxer
product_version : 58.45.100
product_uid : adab4424-2f25-4dc7-92ff-29bd000c0002
modification_date: 2020-11-17T11:16:08.000000Z
material_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE100
timecode : 10:00:00:00
encoder : Lavf58.64.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p(tv, top first),
720x576 [SAR 16:15 DAR 4:3], q=2-31, 221184 kb/s, 0.04 fps, 12800 tbn, 25
tbc
Metadata:
file_package_umid:
0x060A2B340101010501010D0013E1FD2852947134BBE1FD280052947134BBE101
encoder : Lavc58.112.103 v210
frame= 25 fps=0.0 q=-0.0 Lsize= 27002kB time=00:00:00.96
bitrate=230394.3kbits/s speed=19.9x
video:27000kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.005657%}}}
The issue comes from this piece of code in movenc.c (line 2220)
{{{
if (track->par->codec_id != AV_CODEC_ID_H264 &&
track->par->codec_id != AV_CODEC_ID_MPEG4 &&
track->par->codec_id != AV_CODEC_ID_DNXHD) {
int field_order = track->par->field_order;
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
if (field_order != track->st->codec->field_order &&
track->st->codec->field_order != AV_FIELD_UNKNOWN)
field_order = track->st->codec->field_order;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (field_order != AV_FIELD_UNKNOWN)
mov_write_fiel_tag(pb, track, field_order);
}
}}}
"track->par->field_order" is equal to "AV_FIELD_UNKOWN" because it is
never set anywhere.
"track->st->codec->field_order" is equal to "AV_FIELD_TB" because it is
set by this piece of code in ffmpeg.c (line 1212)
{{{
if (frame) {
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT |
AV_CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
frame->top_field_first = !!ost->top_field_first;
if (frame->interlaced_frame) {
if (enc_ctx->codec->id == AV_CODEC_ID_MJPEG)
enc_ctx->field_order = frame->top_field_first ?
AV_FIELD_TT:AV_FIELD_BB;
else
enc_ctx->field_order = frame->top_field_first ?
AV_FIELD_TB:AV_FIELD_BT;
} else
enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
}
}}}
AFAIK, top_field_first frame should only represent AV_FIELD_TT... and
AV_FIELD_TB looks just wrong.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/8991>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list