[Libav-user] Getting field_order in dv demuxer early?
Andrew Randrianasulu
randrianasulu at gmail.com
Sat Nov 14 21:25:00 EET 2020
Hello, all!
I was trying to get field order autodetection working in CinelerraGG (our developer sadly died, so I can't ask him anymore ...)
I get field_order like this:
int FFMPEG::ff_interlace(int stream)
{
/* reads from demuxer because codec frame not ready */
int interlace = ffvideo[stream]->st->codecpar->field_order;
printf("interlace: %i\n", interlace);
switch (interlace)
{
case AV_FIELD_TT:
return ILACE_MODE_TOP_FIRST;
case AV_FIELD_BB:
return ILACE_MODE_BOTTOM_FIRST;
case AV_FIELD_PROGRESSIVE:
return ILACE_MODE_NOTINTERLACED;
default:
return ILACE_MODE_UNDETECTED;
}
}
Unfortunately, this only work for mpegts streams and not for, say, dv.
I tried to add some code in libavformat/dv.c, and while it sort-of working, it apparently doesn't work early enough (at stream probe time?)
in cinelerra/cinelerra-5.1/thirdparty/ffmpeg-4.3/libavformat/dv.c
in function dv_extract_video_info() I added those lines (logic might be wrong, but I can fix it later, I used libavcodec/dvdec.c as example):
if (c->sys->height == 720) {
par->field_order = AV_FIELD_PROGRESSIVE;}
else if (c->sys->height == 1080) {
int ilaced = 1;
int tff = (vsc_pack[3] & 0x40) == 0x40;
par->field_order = tff ? AV_FIELD_TT : 0; }
else {
int ilaced = (vsc_pack[3] & 0x10) == 0x10;
int tff = !(vsc_pack[3] & 0x40) == 0x40;
par->field_order = tff ? 0 : AV_FIELD_BB;
}
//printf("Field order: %i \n", par->field_order);
It prints 'field order: 3" for usual pal DV example, but ffprobe (from where I get my logic for extracting field_order) still says:
/dev/shm/cinelerra/cinelerra-5.1/thirdparty/ffmpeg-4.3/ffprobe -show_streams /dev/shm/qt_dv_pal_test.mov
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Field order: 3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/dev/shm/qt_dv_pal_test.mov':
Metadata:
creation_time : 2002-10-04T18:46:28.000000Z
Duration: 00:00:04.45, start: 0.000000, bitrate: 57948 kb/s
Stream #0:0(eng): Video: dvvideo (dvcp / 0x70637664), yuv420p, 720x576 [SAR 16:15 DAR 4:3], 28800 kb/s, 25 fps, 25 tbr, 600 tbn, 25 tbc (default)
Metadata:
creation_time : 2002-10-04T18:46:28.000000Z
handler_name : Apple Video Media Handler
encoder : DV - PAL
Stream #0:1(eng): Audio: pcm_s16le (dvca / 0x61637664), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
Metadata:
creation_time : 2002-10-04T18:46:28.000000Z
handler_name : Apple Sound Media Handler
[STREAM]
index=0
codec_name=dvvideo
codec_long_name=DV (Digital Video)
profile=unknown
codec_type=video
codec_time_base=1/25
codec_tag_string=dvcp
codec_tag=0x70637664
width=720
height=576
coded_width=720
coded_height=576
closed_captions=0
has_b_frames=0
sample_aspect_ratio=16:15
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=-99
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=topleft
field_order=unknown
timecode=N/A
[a lot more skiped]
I tried to add same logic into dv_read_header(), but dv_extract_pack(frame, dv_video_control); wants 'frame' and I have no idea from where to plug it.
Idea about putting this in header reading code come from libavformat/yuv4mpegdec.c
Any ideas?
More information about the Libav-user
mailing list