The purpose of this is to tell ffmpeg which field order the returned clip of the avisynth .avs script decided to finally deliver, which is handy in an automated environment. Interlacing is generally a very hard topic in avisynth, the huge comment is neccessary to explain my reasons. Additionally to the comment in the patch, i can tell that i set unknown instead of progressive for backward compatibility. (i was struggeling with this, maybe i should have even left it unset in case it is not clearly tff or bff interlaced.

/* Set interlacing type. http://avisynth.nl/index.php/Interlaced_fieldbased * The following typically only works when assumetff (-bff) and assumefieldbased is used in the avs. * This is because most avisynth source plugins do not set the parity info in the clip properties. * We could use GetParity() to be more accurate but it decodes a frame which is * expensive and can potentially lead to unforeseen behaviour when seeking later.
    *   In case Parity is not known, we still cannot guarantee that
    */

Tests with different avisynth source plugins, e.g. directshowsource, ffms2, mpeg2source delivered the expected result.
Make FATE passed.
From 31a37518afa5f9b635e6c52a8f29513bc756c715 Mon Sep 17 00:00:00 2001
From: emcodem <emco...@ffastrans.com>
Date: Sun, 17 Jan 2021 01:02:08 +0100
Subject: [PATCH] Populate field order returned by avs script, Trac Ticket 8757

---
 libavformat/avisynth.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index 2c08ace8db..67348a61d7 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -241,6 +241,26 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
     st->nb_frames         = avs->vi->num_frames;
     avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator);
 
+    av_log(s, AV_LOG_TRACE, "avs_is_field_based: %d\n", avs_is_field_based(avs->vi));
+    av_log(s, AV_LOG_TRACE, "avs_is_parity_known: %d\n", avs_is_parity_known(avs->vi));
+    
+    st->codecpar->field_order = AV_FIELD_UNKNOWN;
+    if (avs_is_field_based(avs->vi)) {
+    /*  Set interlacing type. http://avisynth.nl/index.php/Interlaced_fieldbased
+    *   The following typically only works when assumetff (-bff) and assumefieldbased is used in the avs.
+    *   This is because most avisynth source plugins do not set the parity info in the clip properties.
+    *   We could use GetParity() to be more accurate but it decodes a frame which is 
+    *   expensive and can potentially lead to unforeseen behaviour when seeking later.
+    *   In case Parity is not known, we still cannot guarantee that 
+    */
+        if (avs_is_tff(avs->vi)) {
+            st->codecpar->field_order = AV_FIELD_TT;
+        }
+        else if (avs_is_bff(avs->vi)) {
+            st->codecpar->field_order = AV_FIELD_BB;
+        }
+    }
+    
     switch (avs->vi->pixel_type) {
     /* 10~16-bit YUV pix_fmts (AviSynth+) */
     case AVS_CS_YUV444P10:
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to