summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <[email protected]>2021-07-19 23:25:28 +0300
committerJan Ekström <[email protected]>2021-08-28 20:58:58 +0300
commit926d8b844fee222cb68dfd393273d7876a84e088 (patch)
tree0fb79f5b9b85000685b2496233437e9536a245b9
parentbf87bdd3f65569e562341843965f0e810f7a2d1f (diff)
ffmpeg: fix order between field order autodetection and override
Having the override before autodetection meant that the overridden value got overwritten by the autodetected result each time, effectively disabling the ability to utilize the `-top` option for override purposes. Somehow I missed this in fbb44bc51a647862eb05ae3f9d7d49a0be9bed57 , even though the lines were within the context. Probably the code originally being after this logic had something to do with it, but previously it only touched the avformat context's codecpar, which did not affect the encoder codec context whatsoever. Fixes #9320 Fixes #9339 (cherry picked from commit 4c694093be68d401c60819e5171817c62afef8b2)
-rw-r--r--fftools/ffmpeg.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 7d533c3806..9a34d1f13e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3463,12 +3463,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample;
}
- if (ost->top_field_first == 0) {
- enc_ctx->field_order = AV_FIELD_BB;
- } else if (ost->top_field_first == 1) {
- enc_ctx->field_order = AV_FIELD_TT;
- }
-
+ // Field order: autodetection
if (frame) {
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
@@ -3483,6 +3478,13 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
}
+ // Field order: override
+ if (ost->top_field_first == 0) {
+ enc_ctx->field_order = AV_FIELD_BB;
+ } else if (ost->top_field_first == 1) {
+ enc_ctx->field_order = AV_FIELD_TT;
+ }
+
if (ost->forced_keyframes) {
if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5,