@@ -158,6 +158,7 @@ static int ndi_write_video_packet(AVFormatContext *avctx, AVStream *st, AVPacket
{
struct NDIContext *ctx = avctx->priv_data;
AVFrame *avframe, *tmp = (AVFrame *)pkt->data;
+ AVCodecParameters *c = st->codecpar;
if (tmp->format != AV_PIX_FMT_UYVY422 && tmp->format != AV_PIX_FMT_BGRA &&
tmp->format != AV_PIX_FMT_BGR0 && tmp->format != AV_PIX_FMT_RGBA &&
@@ -188,6 +189,15 @@ static int ndi_write_video_packet(AVFormatContext *avctx, AVStream *st, AVPacket
ctx->video->line_stride_in_bytes = avframe->linesize[0];
ctx->video->p_data = (void *)(avframe->data[0]);
+ if (c->field_order == AV_FIELD_UNKNOWN)
+ ctx->video->frame_format_type = tmp->interlaced_frame
+ ? NDIlib_frame_format_type_interleaved
+ : NDIlib_frame_format_type_progressive;
+ else
+ ctx->video->frame_format_type = c->field_order == AV_FIELD_PROGRESSIVE
+ ? NDIlib_frame_format_type_progressive
+ : NDIlib_frame_format_type_interleaved;
+
av_log(avctx, AV_LOG_DEBUG, "%s: pkt->pts=%"PRId64", timecode=%"PRId64", st->time_base=%d/%d\n",
__func__, pkt->pts, ctx->video->timecode, st->time_base.num, st->time_base.den);
@@ -358,9 +368,6 @@ static int ndi_setup_video(AVFormatContext *avctx, AVStream *st)
ctx->video->yres = c->height;
ctx->video->frame_rate_N = st->avg_frame_rate.num;
ctx->video->frame_rate_D = st->avg_frame_rate.den;
- ctx->video->frame_format_type = c->field_order == AV_FIELD_PROGRESSIVE
- ? NDIlib_frame_format_type_progressive
- : NDIlib_frame_format_type_interleaved;
if (st->sample_aspect_ratio.num) {
AVRational display_aspect_ratio;