Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios
@ 2022-02-23 15:03 James Almer
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: James Almer @ 2022-02-23 15:03 UTC (permalink / raw)
  To: ffmpeg-devel

Bitstream filters inserted between the input and output were
never drained, resulting packets being lost if the bsf had any
buffered.

Signed-off-by: James Almer <jamrial@gmail.com>
---
Now also flushing packets when forcing a record duration.

 fftools/ffmpeg.c        | 13 ++++++++-----
 fftools/ffmpeg.h        |  1 +
 fftools/ffmpeg_filter.c |  1 +
 fftools/ffmpeg_opt.c    |  4 ++++
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e5de099d14..44043ef203 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2010,7 +2010,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost)
     if (ost->source_index != ist_index)
         return 0;
 
-    if (ost->finished)
+    if (ost->finished & MUXER_FINISHED)
         return 0;
 
     if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
@@ -2743,7 +2743,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
         }
         ist->pts = ist->dts;
         ist->next_pts = ist->next_dts;
-    }
+    } else if (!ist->decoding_needed)
+        eof_reached = 1;
+
     for (i = 0; i < nb_output_streams; i++) {
         OutputStream *ost = output_streams[i];
 
@@ -4224,11 +4226,12 @@ static int process_input(int file_index)
         for (i = 0; i < ifile->nb_streams; i++) {
             ist = input_streams[ifile->ist_index + i];
             avctx = ist->dec_ctx;
-            if (ist->decoding_needed) {
+            if (ist->processing_needed) {
                 ret = process_input_packet(ist, NULL, 1);
                 if (ret>0)
                     return 0;
-                avcodec_flush_buffers(avctx);
+                if (ist->decoding_needed)
+                    avcodec_flush_buffers(avctx);
             }
         }
 #if HAVE_THREADS
@@ -4258,7 +4261,7 @@ static int process_input(int file_index)
 
         for (i = 0; i < ifile->nb_streams; i++) {
             ist = input_streams[ifile->ist_index + i];
-            if (ist->decoding_needed) {
+            if (ist->processing_needed) {
                 ret = process_input_packet(ist, NULL, 0);
                 if (ret>0)
                     return 0;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 649f6ee047..82f3db6b6d 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -306,6 +306,7 @@ typedef struct InputStream {
     int decoding_needed;     /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
 #define DECODING_FOR_OST    1
 #define DECODING_FOR_FILTER 2
+    int processing_needed;   /* non zero if the packets must be processed */
 
     AVCodecContext *dec_ctx;
     const AVCodec *dec;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 31d9a8076e..0845c631a5 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -294,6 +294,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
 
     ist->discard         = 0;
     ist->decoding_needed |= DECODING_FOR_FILTER;
+    ist->processing_needed = 1;
     ist->st->discard = AVDISCARD_NONE;
 
     ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 76b9020e83..7ff3936dcf 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -2615,6 +2615,7 @@ loop_end:
         if (ost->encoding_needed && ost->source_index >= 0) {
             InputStream *ist = input_streams[ost->source_index];
             ist->decoding_needed |= DECODING_FOR_OST;
+            ist->processing_needed = 1;
 
             if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
                 ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -2627,6 +2628,9 @@ loop_end:
                     exit_program(1);
                 }
             }
+        } else if (ost->stream_copy && ost->source_index >= 0) {
+            InputStream *ist = input_streams[ost->source_index];
+            ist->processing_needed = 1;
         }
 
         /* set the filter output constraints */
-- 
2.35.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets
  2022-02-23 15:03 [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
@ 2022-02-23 15:03 ` James Almer
  2022-03-31 11:47   ` Anton Khirnov
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 3/4] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants James Almer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: James Almer @ 2022-02-23 15:03 UTC (permalink / raw)
  To: ffmpeg-devel

A keyframe could be buffered in the bsf and not be output until more packets
had been fed to it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
Changed the check from pkt to !eof, since a packet is always provided.

 fftools/ffmpeg.c | 4 +++-
 fftools/ffmpeg.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 44043ef203..2b61c0d5aa 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -890,6 +890,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
 
     /* apply the output bitstream filters */
     if (ost->bsf_ctx) {
+        if (!eof && pkt->flags & AV_PKT_FLAG_KEY)
+            ost->seen_kf = 1;
         ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
         if (ret < 0)
             goto finish;
@@ -2035,7 +2037,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
     }
 
     if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
-        !ost->copy_initial_nonkeyframes)
+        !ost->copy_initial_nonkeyframes && !ost->seen_kf)
         return;
 
     if (!ost->frame_number && !ost->copy_prior_start) {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 82f3db6b6d..6a19dc9c7c 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -534,6 +534,7 @@ typedef struct OutputStream {
     int inputs_done;
 
     const char *attachment_filename;
+    int seen_kf;
     int copy_initial_nonkeyframes;
     int copy_prior_start;
     char *disposition;
-- 
2.35.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 3/4] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants
  2022-02-23 15:03 [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer
@ 2022-02-23 15:03 ` James Almer
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 4/4 v2] avcodec/setts_bsf: add constants to modify packet duration James Almer
  2022-02-28 12:30 ` [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
  3 siblings, 0 replies; 7+ messages in thread
From: James Almer @ 2022-02-23 15:03 UTC (permalink / raw)
  To: ffmpeg-devel

They correspond to the relevant fields from the packet that follows the
one where the expressions are being applied.

Signed-off-by: James Almer <jamrial@gmail.com>
---
No changes since last version. Already LGTM'd by Paul.

 libavcodec/setts_bsf.c | 75 ++++++++++++++++++++++++++++--------------
 1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
index d604f91f71..f0243a1114 100644
--- a/libavcodec/setts_bsf.c
+++ b/libavcodec/setts_bsf.c
@@ -37,6 +37,8 @@ static const char *const var_names[] = {
     "PREV_INDTS",  ///< previous  input DTS
     "PREV_OUTPTS", ///< previous output PTS
     "PREV_OUTDTS", ///< previous output DTS
+    "NEXT_PTS",    ///< next input PTS
+    "NEXT_DTS",    ///< next input DTS
     "PTS",         ///< original PTS in the file of the frame
     "DTS",         ///< original DTS in the file of the frame
     "STARTPTS",    ///< PTS at start of movie
@@ -55,6 +57,8 @@ enum var_name {
     VAR_PREV_INDTS,
     VAR_PREV_OUTPTS,
     VAR_PREV_OUTDTS,
+    VAR_NEXT_PTS,
+    VAR_NEXT_DTS,
     VAR_PTS,
     VAR_DTS,
     VAR_STARTPTS,
@@ -76,16 +80,16 @@ typedef struct SetTSContext {
 
     int64_t start_pts;
     int64_t start_dts;
-    int64_t prev_inpts;
-    int64_t prev_indts;
-    int64_t prev_outpts;
-    int64_t prev_outdts;
 
     double var_values[VAR_VARS_NB];
 
     AVExpr *ts_expr;
     AVExpr *pts_expr;
     AVExpr *dts_expr;
+
+    AVPacket *prev_inpkt;
+    AVPacket *prev_outpkt;
+    AVPacket *cur_pkt;
 } SetTSContext;
 
 static int setts_init(AVBSFContext *ctx)
@@ -93,6 +97,12 @@ static int setts_init(AVBSFContext *ctx)
     SetTSContext *s = ctx->priv_data;
     int ret;
 
+    s->prev_inpkt = av_packet_alloc();
+    s->prev_outpkt = av_packet_alloc();
+    s->cur_pkt = av_packet_alloc();
+    if (!s->prev_inpkt || !s->prev_outpkt || !s->cur_pkt)
+        return AVERROR(ENOMEM);
+
     if ((ret = av_expr_parse(&s->ts_expr, s->ts_str,
                              var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
         av_log(ctx, AV_LOG_ERROR, "Error while parsing ts expression '%s'\n", s->ts_str);
@@ -118,10 +128,6 @@ static int setts_init(AVBSFContext *ctx)
     s->frame_number= 0;
     s->start_pts   = AV_NOPTS_VALUE;
     s->start_dts   = AV_NOPTS_VALUE;
-    s->prev_inpts  = AV_NOPTS_VALUE;
-    s->prev_indts  = AV_NOPTS_VALUE;
-    s->prev_outpts = AV_NOPTS_VALUE;
-    s->prev_outdts = AV_NOPTS_VALUE;
     s->var_values[VAR_NOPTS] = AV_NOPTS_VALUE;
 
     return 0;
@@ -134,24 +140,31 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
     int ret;
 
     ret = ff_bsf_get_packet_ref(ctx, pkt);
-    if (ret < 0)
+    if (ret < 0 && (ret != AVERROR_EOF || !s->cur_pkt->data))
         return ret;
 
+    if (!s->cur_pkt->data) {
+         av_packet_move_ref(s->cur_pkt, pkt);
+         return AVERROR(EAGAIN);
+    }
+
     if (s->start_pts == AV_NOPTS_VALUE)
-        s->start_pts = pkt->pts;
+        s->start_pts = s->cur_pkt->pts;
 
     if (s->start_dts == AV_NOPTS_VALUE)
-        s->start_dts = pkt->dts;
+        s->start_dts = s->cur_pkt->dts;
 
     s->var_values[VAR_N]           = s->frame_number++;
-    s->var_values[VAR_TS]          = pkt->dts;
-    s->var_values[VAR_POS]         = pkt->pos;
-    s->var_values[VAR_PTS]         = pkt->pts;
-    s->var_values[VAR_DTS]         = pkt->dts;
-    s->var_values[VAR_PREV_INPTS]  = s->prev_inpts;
-    s->var_values[VAR_PREV_INDTS]  = s->prev_indts;
-    s->var_values[VAR_PREV_OUTPTS] = s->prev_outpts;
-    s->var_values[VAR_PREV_OUTDTS] = s->prev_outdts;
+    s->var_values[VAR_TS]          = s->cur_pkt->dts;
+    s->var_values[VAR_POS]         = s->cur_pkt->pos;
+    s->var_values[VAR_PTS]         = s->cur_pkt->pts;
+    s->var_values[VAR_DTS]         = s->cur_pkt->dts;
+    s->var_values[VAR_PREV_INPTS]  = s->prev_inpkt->pts;
+    s->var_values[VAR_PREV_INDTS]  = s->prev_inpkt->dts;
+    s->var_values[VAR_PREV_OUTPTS] = s->prev_outpkt->pts;
+    s->var_values[VAR_PREV_OUTDTS] = s->prev_outpkt->dts;
+    s->var_values[VAR_NEXT_PTS]    = pkt->pts;
+    s->var_values[VAR_NEXT_DTS]    = pkt->dts;
     s->var_values[VAR_STARTPTS]    = s->start_pts;
     s->var_values[VAR_STARTDTS]    = s->start_dts;
     s->var_values[VAR_TB]          = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0;
@@ -160,27 +173,35 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
     new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL));
 
     if (s->pts_str) {
-        s->var_values[VAR_TS] = pkt->pts;
+        s->var_values[VAR_TS] = s->cur_pkt->pts;
         new_pts = llrint(av_expr_eval(s->pts_expr, s->var_values, NULL));
     } else {
         new_pts = new_ts;
     }
 
     if (s->dts_str) {
-        s->var_values[VAR_TS] = pkt->dts;
+        s->var_values[VAR_TS] = s->cur_pkt->dts;
         new_dts = llrint(av_expr_eval(s->dts_expr, s->var_values, NULL));
     } else {
         new_dts = new_ts;
     }
 
-    s->prev_inpts  = pkt->pts;
-    s->prev_indts  = pkt->dts;
-    s->prev_outpts = new_pts;
-    s->prev_outdts = new_dts;
+    av_packet_unref(s->prev_inpkt);
+    av_packet_unref(s->prev_outpkt);
+    av_packet_move_ref(s->prev_inpkt, s->cur_pkt);
+    av_packet_move_ref(s->cur_pkt, pkt);
+
+    ret = av_packet_ref(pkt, s->prev_inpkt);
+    if (ret < 0)
+        return ret;
 
     pkt->pts = new_pts;
     pkt->dts = new_dts;
 
+    ret = av_packet_ref(s->prev_outpkt, pkt);
+    if (ret < 0)
+        av_packet_unref(pkt);
+
     return ret;
 }
 
@@ -188,6 +209,10 @@ static void setts_close(AVBSFContext *bsf)
 {
     SetTSContext *s = bsf->priv_data;
 
+    av_packet_free(&s->prev_inpkt);
+    av_packet_free(&s->prev_outpkt);
+    av_packet_free(&s->cur_pkt);
+
     av_expr_free(s->ts_expr);
     s->ts_expr = NULL;
     av_expr_free(s->pts_expr);
-- 
2.35.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH 4/4 v2] avcodec/setts_bsf: add constants to modify packet duration
  2022-02-23 15:03 [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 3/4] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants James Almer
@ 2022-02-23 15:03 ` James Almer
  2022-02-28 12:30 ` [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
  3 siblings, 0 replies; 7+ messages in thread
From: James Almer @ 2022-02-23 15:03 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: James Almer <jamrial@gmail.com>
---
No changes since last version. Already LGTM'd by Paul.

 libavcodec/setts_bsf.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavcodec/setts_bsf.c b/libavcodec/setts_bsf.c
index f0243a1114..eadc4e4d34 100644
--- a/libavcodec/setts_bsf.c
+++ b/libavcodec/setts_bsf.c
@@ -35,12 +35,16 @@ static const char *const var_names[] = {
     "POS",         ///< original position in the file of the frame
     "PREV_INPTS",  ///< previous  input PTS
     "PREV_INDTS",  ///< previous  input DTS
+    "PREV_INDURATION", ///< previous input duration
     "PREV_OUTPTS", ///< previous output PTS
     "PREV_OUTDTS", ///< previous output DTS
+    "PREV_OUTDURATION", ///< previous output duration
     "NEXT_PTS",    ///< next input PTS
     "NEXT_DTS",    ///< next input DTS
+    "NEXT_DURATION", ///< next input duration
     "PTS",         ///< original PTS in the file of the frame
     "DTS",         ///< original DTS in the file of the frame
+    "DURATION",    ///< original duration in the file of the frame
     "STARTPTS",    ///< PTS at start of movie
     "STARTDTS",    ///< DTS at start of movie
     "TB",          ///< timebase of the stream
@@ -55,12 +59,16 @@ enum var_name {
     VAR_POS,
     VAR_PREV_INPTS,
     VAR_PREV_INDTS,
+    VAR_PREV_INDUR,
     VAR_PREV_OUTPTS,
     VAR_PREV_OUTDTS,
+    VAR_PREV_OUTDUR,
     VAR_NEXT_PTS,
     VAR_NEXT_DTS,
+    VAR_NEXT_DUR,
     VAR_PTS,
     VAR_DTS,
+    VAR_DURATION,
     VAR_STARTPTS,
     VAR_STARTDTS,
     VAR_TB,
@@ -75,6 +83,7 @@ typedef struct SetTSContext {
     char *ts_str;
     char *pts_str;
     char *dts_str;
+    char *duration_str;
 
     int64_t frame_number;
 
@@ -86,6 +95,7 @@ typedef struct SetTSContext {
     AVExpr *ts_expr;
     AVExpr *pts_expr;
     AVExpr *dts_expr;
+    AVExpr *duration_expr;
 
     AVPacket *prev_inpkt;
     AVPacket *prev_outpkt;
@@ -109,6 +119,12 @@ static int setts_init(AVBSFContext *ctx)
         return ret;
     }
 
+    if ((ret = av_expr_parse(&s->duration_expr, s->duration_str,
+                             var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
+        av_log(ctx, AV_LOG_ERROR, "Error while parsing duration expression '%s'\n", s->duration_str);
+        return ret;
+    }
+
     if (s->pts_str) {
         if ((ret = av_expr_parse(&s->pts_expr, s->pts_str,
                                  var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) {
@@ -136,7 +152,7 @@ static int setts_init(AVBSFContext *ctx)
 static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
 {
     SetTSContext *s = ctx->priv_data;
-    int64_t new_ts, new_pts, new_dts;
+    int64_t new_ts, new_pts, new_dts, new_duration;
     int ret;
 
     ret = ff_bsf_get_packet_ref(ctx, pkt);
@@ -159,18 +175,23 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
     s->var_values[VAR_POS]         = s->cur_pkt->pos;
     s->var_values[VAR_PTS]         = s->cur_pkt->pts;
     s->var_values[VAR_DTS]         = s->cur_pkt->dts;
+    s->var_values[VAR_DURATION]    = s->cur_pkt->duration;
     s->var_values[VAR_PREV_INPTS]  = s->prev_inpkt->pts;
     s->var_values[VAR_PREV_INDTS]  = s->prev_inpkt->dts;
+    s->var_values[VAR_PREV_INDUR]  = s->prev_inpkt->duration;
     s->var_values[VAR_PREV_OUTPTS] = s->prev_outpkt->pts;
     s->var_values[VAR_PREV_OUTDTS] = s->prev_outpkt->dts;
+    s->var_values[VAR_PREV_OUTDUR] = s->prev_outpkt->duration;
     s->var_values[VAR_NEXT_PTS]    = pkt->pts;
     s->var_values[VAR_NEXT_DTS]    = pkt->dts;
+    s->var_values[VAR_NEXT_DUR]    = pkt->duration;
     s->var_values[VAR_STARTPTS]    = s->start_pts;
     s->var_values[VAR_STARTDTS]    = s->start_dts;
     s->var_values[VAR_TB]          = ctx->time_base_out.den ? av_q2d(ctx->time_base_out) : 0;
     s->var_values[VAR_SR]          = ctx->par_in->sample_rate;
 
     new_ts = llrint(av_expr_eval(s->ts_expr, s->var_values, NULL));
+    new_duration = llrint(av_expr_eval(s->duration_expr, s->var_values, NULL));
 
     if (s->pts_str) {
         s->var_values[VAR_TS] = s->cur_pkt->pts;
@@ -197,6 +218,7 @@ static int setts_filter(AVBSFContext *ctx, AVPacket *pkt)
 
     pkt->pts = new_pts;
     pkt->dts = new_dts;
+    pkt->duration = new_duration;
 
     ret = av_packet_ref(s->prev_outpkt, pkt);
     if (ret < 0)
@@ -228,6 +250,7 @@ static const AVOption options[] = {
     { "ts",  "set expression for packet PTS and DTS", OFFSET(ts_str),  AV_OPT_TYPE_STRING, {.str="TS"}, 0, 0, FLAGS },
     { "pts", "set expression for packet PTS", OFFSET(pts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
     { "dts", "set expression for packet DTS", OFFSET(dts_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
+    { "duration", "set expression for packet duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str="DURATION"}, 0, 0, FLAGS },
     { NULL },
 };
 
-- 
2.35.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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios
  2022-02-23 15:03 [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
                   ` (2 preceding siblings ...)
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 4/4 v2] avcodec/setts_bsf: add constants to modify packet duration James Almer
@ 2022-02-28 12:30 ` James Almer
  3 siblings, 0 replies; 7+ messages in thread
From: James Almer @ 2022-02-28 12:30 UTC (permalink / raw)
  To: ffmpeg-devel

On 2/23/2022 12:03 PM, James Almer wrote:
> Bitstream filters inserted between the input and output were
> never drained, resulting packets being lost if the bsf had any
> buffered.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Now also flushing packets when forcing a record duration.
> 
>   fftools/ffmpeg.c        | 13 ++++++++-----
>   fftools/ffmpeg.h        |  1 +
>   fftools/ffmpeg_filter.c |  1 +
>   fftools/ffmpeg_opt.c    |  4 ++++
>   4 files changed, 14 insertions(+), 5 deletions(-)

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

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets
  2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer
@ 2022-03-31 11:47   ` Anton Khirnov
  2022-03-31 11:51     ` James Almer
  0 siblings, 1 reply; 7+ messages in thread
From: Anton Khirnov @ 2022-03-31 11:47 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting James Almer (2022-02-23 16:03:53)
> A keyframe could be buffered in the bsf and not be output until more packets
> had been fed to it.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Changed the check from pkt to !eof, since a packet is always provided.
> 
>  fftools/ffmpeg.c | 4 +++-
>  fftools/ffmpeg.h | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 44043ef203..2b61c0d5aa 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -890,6 +890,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
>  
>      /* apply the output bitstream filters */
>      if (ost->bsf_ctx) {
> +        if (!eof && pkt->flags & AV_PKT_FLAG_KEY)
> +            ost->seen_kf = 1;

Shouldn't this also be set when no bsfs are used?

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

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets
  2022-03-31 11:47   ` Anton Khirnov
@ 2022-03-31 11:51     ` James Almer
  0 siblings, 0 replies; 7+ messages in thread
From: James Almer @ 2022-03-31 11:51 UTC (permalink / raw)
  To: ffmpeg-devel



On 3/31/2022 8:47 AM, Anton Khirnov wrote:
> Quoting James Almer (2022-02-23 16:03:53)
>> A keyframe could be buffered in the bsf and not be output until more packets
>> had been fed to it.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>> Changed the check from pkt to !eof, since a packet is always provided.
>>
>>   fftools/ffmpeg.c | 4 +++-
>>   fftools/ffmpeg.h | 1 +
>>   2 files changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>> index 44043ef203..2b61c0d5aa 100644
>> --- a/fftools/ffmpeg.c
>> +++ b/fftools/ffmpeg.c
>> @@ -890,6 +890,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
>>   
>>       /* apply the output bitstream filters */
>>       if (ost->bsf_ctx) {
>> +        if (!eof && pkt->flags & AV_PKT_FLAG_KEY)
>> +            ost->seen_kf = 1;
> 
> Shouldn't this also be set when no bsfs are used?

Afaict only in streamcopy with bsfs scenarios can packets be temporarily 
withheld, so it's not necessary.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-31 11:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 15:03 [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer
2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 2/4 v2] ffmpeg: ensure a keyframe was not seen before skipping packets James Almer
2022-03-31 11:47   ` Anton Khirnov
2022-03-31 11:51     ` James Almer
2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 3/4] avcodec/setts_bsf: add NEXT_PTS/DTS expression constants James Almer
2022-02-23 15:03 ` [FFmpeg-devel] [PATCH 4/4 v2] avcodec/setts_bsf: add constants to modify packet duration James Almer
2022-02-28 12:30 ` [FFmpeg-devel] [PATCH 1/4 v2] ffmpeg: flush delayed frames in codec copy scenarios James Almer

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git