[FFmpeg-devel] [RFC] ffmpeg: reverse logic for interlaced field ordering heuristic

Timo Rothenpieler timo at rothenpieler.org
Fri Sep 1 22:02:54 EEST 2017


When re-encoding for example interlaced h264 from mkv into mkv, the
field ordering type switches from TT to TB, confusing some players.
Same happens on a lot of other cases as well.

I have no idea if this is the correct fix for it, but something is
definitely going wrong.
---
 ffmpeg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index ccb6638e0a..41f9bc4fb7 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1206,7 +1206,7 @@ static void do_video_out(OutputFile *of,
            avoid any copies. We support temporarily the older
            method. */
         if (in_picture->interlaced_frame)
-            mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
+            mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
         else
             mux_par->field_order = AV_FIELD_PROGRESSIVE;
         pkt.data   = (uint8_t *)in_picture;
@@ -1226,7 +1226,7 @@ static void do_video_out(OutputFile *of,
             in_picture->top_field_first = !!ost->top_field_first;
 
         if (in_picture->interlaced_frame) {
-            if (enc->codec->id == AV_CODEC_ID_MJPEG)
+            if (enc->codec->id != AV_CODEC_ID_MJPEG)
                 mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
             else
                 mux_par->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
-- 
2.14.1



More information about the ffmpeg-devel mailing list