[FFmpeg-devel] [PATCH] avformat/dashenc: set start_number of fragment from zero
Client will get from the second fragment of the playlist if the start number is 1, and the recording files will play from second fragment. So set the startNumber from 0, just make the user get fragment from the first one of playlist. Signed-off-by: Steven Liu --- libavformat/dashenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index a0919f6f2d..dd5fe02087 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -499,7 +499,7 @@ static void get_hls_playlist_name(char *playlist_name, int string_size, static void get_start_index_number(OutputStream *os, DASHContext *c, int *start_index, int *start_number) { *start_index = 0; -*start_number = 1; +*start_number = 0; if (c->window_size) { *start_index = FFMAX(os->nb_segments - c->window_size, 0); *start_number = FFMAX(os->segment_index - c->window_size, 1); -- 2.31.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".
Re: [FFmpeg-devel] [PATCH v3] avformat/hls: Add option to retry failed segments for hls
Steven Liu 于2022年10月11日周二 10:55写道: > > gnattu 于2022年10月10日周一 20:09写道: > > > > Current HLS implementation simply skip a failed segment to catch up > > the stream, but this is not optimal for some use cases like livestream > > recording. > > Add an option to retry a failed segment to ensure the output file is > > a complete stream. > > > > Signed-off-by: gnattu > > --- > > Fixed commit message wrap > > libavformat/hls.c | 15 ++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > index e622425e80..2b977f9132 100644 > > --- a/libavformat/hls.c > > +++ b/libavformat/hls.c > > @@ -225,6 +225,7 @@ typedef struct HLSContext { > > int http_persistent; > > int http_multiple; > > int http_seekable; > > +int seg_max_retry; > > AVIOContext *playlist_pb; > > HLSCryptoContext crypto_ctx; > > } HLSContext; > > @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int > > buf_size) > > int ret; > > int just_opened = 0; > > int reload_count = 0; > > +int segment_retries = 0; > > struct segment *seg; > > > > restart: > > @@ -1563,9 +1565,18 @@ reload: > > av_log(v->parent, AV_LOG_WARNING, "Failed to open segment > > %"PRId64" of playlist %d\n", > > v->cur_seq_no, > > v->index); > > -v->cur_seq_no += 1; > > +if (segment_retries >= c->seg_max_retry) { > > +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of > > playlist %d failed too many times, skipping\n", > > + v->cur_seq_no, > > + v->index); > > +v->cur_seq_no += 1; > > +segment_retries = 0; > > +} else { > > +segment_retries += 1; > > +} > > goto reload; > > } > > +segment_retries = 0; > > just_opened = 1; > > } > > > > @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { > > OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, > > FLAGS}, > > {"seg_format_options", "Set options for segment demuxer", > > OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, > > FLAGS}, > > +{"seg_max_retry", "Maximum number of times to reload a segment on > > error.", > > + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, > > FLAGS}, BTW, Document should add describe about the option. > > {NULL} > > }; > > > > -- > > 2.37.0 (Apple Git-136) > > > > ___ > > 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". > > Not sure this functions is usefull. because there have a option named > "max_reload" for playlist reload, > but this can be used for segment reload. > > Perhaps there have some sence need reload segment, so this lookd ok to me. > > > > Thanks > Steven ___ 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".
Re: [FFmpeg-devel] [PATCH] avformat/dashdec: Differentiate unassigned and zero attributes
Gregor Riepl 于2022年10月8日周六 05:31写道: > > This fixes an issue where a timestamp attribute may have a valid zero > value (the UNIX epoch 1970-01-01T00:00:00), but is misinterpreted by > dashdec as being unassigned. This changes the logic that calculates > segment numbers and makes the stream undecodable by dashdec. > > The fix originally posted to the issue tracker was incorrect and > changed other parts of the segment calculation logic. With this > patch, only the interpretation of the attributes is changed. > Some warnings are added to account for potential errors in manifests. > > Fixes: #8522 > Signed-off-by: Gregor Riepl > --- > libavformat/dashdec.c | 210 -- > 1 file changed, 162 insertions(+), 48 deletions(-) > > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c > index 29d4680c68..f25d1a2bdf 100644 > --- a/libavformat/dashdec.c > +++ b/libavformat/dashdec.c > @@ -20,6 +20,7 @@ >* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA >*/ > #include > +#include Not sure this header can be used every enveriment. Or what about use #define TRUE 1 #define FALSE 0 ? > #include "libavutil/bprint.h" > #include "libavutil/opt.h" > #include "libavutil/time.h" > @@ -129,21 +130,34 @@ typedef struct DASHContext { > struct representation **subtitles; > > /* MediaPresentationDescription Attribute */ > -uint64_t media_presentation_duration; > -uint64_t suggested_presentation_delay; > -uint64_t availability_start_time; > -uint64_t availability_end_time; > -uint64_t publish_time; > -uint64_t minimum_update_period; > -uint64_t time_shift_buffer_depth; > -uint64_t min_buffer_time; > +uint64_t media_presentation_duration_value; > +uint64_t suggested_presentation_delay_value; > +uint64_t availability_start_time_value; > +uint64_t availability_end_time_value; > +uint64_t publish_time_value; > +uint64_t minimum_update_period_value; > +uint64_t time_shift_buffer_depth_value; > +uint64_t min_buffer_time_value; > > /* Period Attribute */ > -uint64_t period_duration; > -uint64_t period_start; > +uint64_t period_duration_value; > +uint64_t period_start_value; > > /* AdaptationSet Attribute */ > -char *adaptionset_lang; > +char *adaptionset_lang_value; > + > +/* Attribute valid flags (true if the attribute exists in the XML > manifest) */ > +bool media_presentation_duration_assigned; > +bool suggested_presentation_delay_assigned; > +bool availability_start_time_assigned; > +bool availability_end_time_assigned; > +bool publish_time_assigned; > +bool minimum_update_period_assigned; > +bool time_shift_buffer_depth_assigned; > +bool min_buffer_time_assigned; > +bool period_duration_assigned; > +bool period_start_assigned; > +bool adaptionset_lang_assigned; > > int is_live; > AVIOInterruptCB *interrupt_callback; > @@ -867,8 +881,8 @@ static int parse_manifest_representation(AVFormatContext > *s, const char *url, > rep = av_mallocz(sizeof(struct representation)); > if (!rep) > return AVERROR(ENOMEM); > -if (c->adaptionset_lang) { > -rep->lang = av_strdup(c->adaptionset_lang); > +if (c->adaptionset_lang_assigned) { > +rep->lang = av_strdup(c->adaptionset_lang_value); > if (!rep->lang) { > av_log(s, AV_LOG_ERROR, "alloc language memory failure\n"); > av_freep(&rep); > @@ -1106,7 +1120,10 @@ static int > parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr adap > av_log(s, AV_LOG_WARNING, "Cannot get AdaptionSet\n"); > return AVERROR(EINVAL); > } > -c->adaptionset_lang = xmlGetProp(adaptionset_node, "lang"); > +c->adaptionset_lang_value = xmlGetProp(adaptionset_node, "lang"); > +if (c->adaptionset_lang_value) { > +c->adaptionset_lang_assigned = true; > +} > > return 0; > } > @@ -1162,8 +1179,9 @@ static int parse_manifest_adaptationset(AVFormatContext > *s, const char *url, > } > > err: > -xmlFree(c->adaptionset_lang); > -c->adaptionset_lang = NULL; > +xmlFree(c->adaptionset_lang_value); > +c->adaptionset_lang_value = NULL; > +c->adaptionset_lang_assigned = false; > return ret; > } > > @@ -1273,29 +1291,37 @@ static int parse_manifest(AVFormatContext *s, const > char *url, AVIOContext *in) > val = xmlGetProp(node, attr->name); > > if (!av_strcasecmp(attr->name, "availabilityStartTime")) { > -c->availability_start_time = get_utc_date_time_insec(s, val); > -av_log(s, AV_LOG_TRACE, "c->availability_start_time = > [%"PRId64"]\n", c->availability_start_time); > +c->availability_start_time_value = > get_utc_date_time_insec(s, val); > +c->availability_start_time_assigned = true; > +
Re: [FFmpeg-devel] [PATCH v3] avformat/hls: Add option to retry failed segments for hls
gnattu 于2022年10月10日周一 20:09写道: > > Current HLS implementation simply skip a failed segment to catch up > the stream, but this is not optimal for some use cases like livestream > recording. > Add an option to retry a failed segment to ensure the output file is > a complete stream. > > Signed-off-by: gnattu > --- > Fixed commit message wrap > libavformat/hls.c | 15 ++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index e622425e80..2b977f9132 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -225,6 +225,7 @@ typedef struct HLSContext { > int http_persistent; > int http_multiple; > int http_seekable; > +int seg_max_retry; > AVIOContext *playlist_pb; > HLSCryptoContext crypto_ctx; > } HLSContext; > @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int > buf_size) > int ret; > int just_opened = 0; > int reload_count = 0; > +int segment_retries = 0; > struct segment *seg; > > restart: > @@ -1563,9 +1565,18 @@ reload: > av_log(v->parent, AV_LOG_WARNING, "Failed to open segment > %"PRId64" of playlist %d\n", > v->cur_seq_no, > v->index); > -v->cur_seq_no += 1; > +if (segment_retries >= c->seg_max_retry) { > +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of > playlist %d failed too many times, skipping\n", > + v->cur_seq_no, > + v->index); > +v->cur_seq_no += 1; > +segment_retries = 0; > +} else { > +segment_retries += 1; > +} > goto reload; > } > +segment_retries = 0; > just_opened = 1; > } > > @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { > OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, > {"seg_format_options", "Set options for segment demuxer", > OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, > FLAGS}, > +{"seg_max_retry", "Maximum number of times to reload a segment on > error.", > + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, > {NULL} > }; > > -- > 2.37.0 (Apple Git-136) > > ___ > 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". Not sure this functions is usefull. because there have a option named "max_reload" for playlist reload, but this can be used for segment reload. Perhaps there have some sence need reload segment, so this lookd ok to me. Thanks Steven ___ 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".
Re: [FFmpeg-devel] [PATCH] aarch64: Implement stack spilling in a consistent way.
On Sun, 9 Oct 2022, reimar.doeffin...@gmx.de wrote: From: Reimar Döffinger Currently it is done in several different ways, which might cause needless dependencies or in case of tx_float_neon.S is incorrect. Signed-off-by: Reimar Döffinger --- libavcodec/aarch64/fft_neon.S | 3 +- libavcodec/aarch64/h264idct_neon.S | 6 +- libavcodec/aarch64/hevcdsp_sao_neon.S | 3 +- libavcodec/aarch64/mdct_neon.S | 18 ++ libavcodec/aarch64/me_cmp_neon.S | 6 +- libavcodec/aarch64/synth_filter_neon.S | 3 +- libavcodec/aarch64/vp9itxfm_neon.S | 28 - libavcodec/aarch64/vp9lpf_16bpp_neon.S | 32 +-- libavcodec/aarch64/vp9lpf_neon.S | 80 +- libavutil/aarch64/tx_float_neon.S | 52 - 10 files changed, 109 insertions(+), 122 deletions(-) This looks reasonable to me, assuming that it passes fate. Do you want to push it yourself, or do you want me to do it? // Martin ___ 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".
[FFmpeg-devel] [PATCH v4] avformat/segment: add -strftime_mkdir option
This enables automatically creating directories for strftime-formatted segment names. Signed-off-by: George-Cristian Jiglau --- doc/muxers.texi | 4 libavformat/segment.c | 15 +++ 2 files changed, 19 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 4edbb22b00..5695bc66ae 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2445,6 +2445,10 @@ segments to write. If this is selected, the output segment name must contain a @code{strftime} function template. Default value is @code{0}. +@item strftime_mkdir @var{1|0} +Used together with -strftime, it will create all subdirectories of the +expanded segment name. Default value is @code{0}. + @item break_non_keyframes @var{1|0} If enabled, allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is diff --git a/libavformat/segment.c b/libavformat/segment.c index c904e20708..13c18f24ca 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -94,6 +94,7 @@ typedef struct SegmentContext { AVIOContext *list_pb; ///< list file put-byte context int64_t time; ///< segment duration int use_strftime; ///< flag to expand filename with strftime +int use_strftime_mkdir; ///< flag to mkdir dirname in strftime filename int increment_tc; ///< flag to increment timecode if found char *times_str; ///< segment times specification string @@ -203,6 +204,19 @@ static int set_segment_filename(AVFormatContext *s) av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } +if (seg->use_strftime_mkdir) { +const char *dir; +char *fn_copy = av_strdup(buf); +if (!fn_copy) +return AVERROR(ENOMEM); +dir = av_dirname(fn_copy); +if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { +av_log(oc, AV_LOG_ERROR, "Could not create directory %s with strftime_mkdir\n", dir); +av_freep(&fn_copy); +return AVERROR(errno); +} +av_freep(&fn_copy); +} } else if (av_get_frame_filename(buf, sizeof(buf), s->url, seg->segment_idx) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url); @@ -1038,6 +1052,7 @@ static const AVOption options[] = { { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "strftime", "set filename expansion with strftime at segment creation", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, +{ "strftime_mkdir","create directory components in strftime-generated filename", OFFSET(use_strftime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "increment_tc", "increment timecode between each segment", OFFSET(increment_tc), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "break_non_keyframes", "allow breaking segments on non-keyframes", OFFSET(break_non_keyframes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, -- 2.36.2 ___ 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".
Re: [FFmpeg-devel] [PATCH 20/20] avcodec/snowdec: Remove debug code
On Mon, Oct 10, 2022 at 05:13:10AM +0200, Andreas Rheinhardt wrote: > The Snow decoder checks two bits of AVCodecContext.debug > via numerical constants, not defines. One of these constants > (512) used to be equivalent to FF_DEBUG_PTS which has been > removed in 302554835e39b79b977ed60c9afe81b44590dfef > (merged in 6e69525e6984d51165de0b17b796bbc29f9dd6e7). > > It is unlikely that 512 was intended to be FF_DEBUG_PTS, > as it has nothing do to with PTS; instead it makes > certain parts of the code behave like it does for keyframes > even if the current frame is not a keyframe. why not fix it instead of removing ? you can check what it did by looking at the code when it was added. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus signature.asc Description: PGP signature ___ 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".
Re: [FFmpeg-devel] [PATCH 16/20] avcodec/snow: Move allocating encoder-only buffers to snowenc.c
On Mon, Oct 10, 2022 at 05:13:06AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/snow.c| 23 +-- > libavcodec/snowenc.c | 16 +++- > 2 files changed, 24 insertions(+), 15 deletions(-) probably ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. signature.asc Description: PGP signature ___ 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".
Re: [FFmpeg-devel] [PATCH 13/20] avcodec/snow: Move freeing encoder-only buffers to snowenc.c
On Mon, Oct 10, 2022 at 05:13:03AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/snow.c| 8 > libavcodec/snowenc.c | 12 > 2 files changed, 12 insertions(+), 8 deletions(-) should be ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad signature.asc Description: PGP signature ___ 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".
Re: [FFmpeg-devel] [PATCH 11/20] avcodec/snow: Move decoder/encoder-only inline funcs to snow(dec|enc).c
On Mon, Oct 10, 2022 at 05:13:01AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/snow.h| 219 --- > libavcodec/snowdec.c | 147 + > libavcodec/snowenc.c | 64 + > 3 files changed, 211 insertions(+), 219 deletions(-) i guess if snow stays monolithically in 2 files thats ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you fake or manipulate statistics in a paper in physics you will never get a job again. If you fake or manipulate statistics in a paper in medicin you will get a job for life at the pharma industry. signature.asc Description: PGP signature ___ 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".
Re: [FFmpeg-devel] [PATCH 09/20] avcodec/snow: Move initializing MotionEstContext to snowenc.c
On Mon, Oct 10, 2022 at 05:12:59AM +0200, Andreas Rheinhardt wrote: > Only used by the encoder. > > Signed-off-by: Andreas Rheinhardt > --- > configure| 2 +- > libavcodec/snow.c| 2 -- > libavcodec/snowenc.c | 2 ++ > 3 files changed, 3 insertions(+), 3 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are too smart to engage in politics are punished by being governed by those who are dumber. -- Plato signature.asc Description: PGP signature ___ 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".
[FFmpeg-devel] [PATCH 5/8] lavfi/vf_decimate: use inverse of output framerate as timebase
This filter currently keeps the input timebase, but produces CFR output. It is thus simpler to use 1/output fps as the output timebase. Also, set output frame durations. --- libavfilter/vf_decimate.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c index 01404e6fec..f61e501c96 100644 --- a/libavfilter/vf_decimate.c +++ b/libavfilter/vf_decimate.c @@ -43,7 +43,6 @@ typedef struct DecimateContext { AVFrame *last; ///< last frame from the previous queue AVFrame **clean_src;///< frame queue for the clean source int got_frame[2]; ///< frame request flag for each input stream -AVRational ts_unit; ///< timestamp units for the output frames int64_t last_pts; ///< last output timestamp int64_t start_pts; ///< base for output timestamps uint32_t eof; ///< bitmask for end of stream @@ -213,6 +212,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) /* push all frames except the drop */ ret = 0; for (i = 0; i < dm->cycle && dm->queue[i].frame; i++) { +AVRational in_tb = ctx->inputs[INPUT_MAIN]->time_base; if (i == drop) { if (dm->ppsrc) av_frame_free(&dm->clean_src[i]); @@ -221,7 +221,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFrame *frame = dm->queue[i].frame; dm->queue[i].frame = NULL; if (frame->pts != AV_NOPTS_VALUE && dm->start_pts == AV_NOPTS_VALUE) -dm->start_pts = frame->pts; +dm->start_pts = av_rescale_q(frame->pts, in_tb, outlink->time_base); + if (dm->ppsrc) { av_frame_free(&frame); frame = dm->clean_src[i]; @@ -229,8 +230,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) continue; dm->clean_src[i] = NULL; } -frame->pts = av_rescale_q(outlink->frame_count_in, dm->ts_unit, (AVRational){1,1}) + +frame->pts = outlink->frame_count_in + (dm->start_pts == AV_NOPTS_VALUE ? 0 : dm->start_pts); +frame->duration = 1; dm->last_pts = frame->pts; ret = ff_filter_frame(outlink, frame); if (ret < 0) @@ -404,7 +406,7 @@ static int config_output(AVFilterLink *outlink) fps = av_mul_q(fps, (AVRational){dm->cycle - 1, dm->cycle}); av_log(ctx, AV_LOG_VERBOSE, "FPS: %d/%d -> %d/%d\n", inlink->frame_rate.num, inlink->frame_rate.den, fps.num, fps.den); -outlink->time_base = inlink->time_base; +outlink->time_base = av_inv_q(fps); outlink->frame_rate = fps; outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; if (dm->ppsrc) { @@ -414,7 +416,6 @@ static int config_output(AVFilterLink *outlink) outlink->w = inlink->w; outlink->h = inlink->h; } -dm->ts_unit = av_inv_q(av_mul_q(fps, outlink->time_base)); return 0; } -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 8/8] lavfi/vf_estdif: set frame durations
--- libavfilter/vf_estdif.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c index 9e826fd424..0164f4638a 100644 --- a/libavfilter/vf_estdif.c +++ b/libavfilter/vf_estdif.c @@ -432,7 +432,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, return 0; } -static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts) +static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts, int64_t duration) { ESTDIFContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -445,6 +445,7 @@ static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts) av_frame_copy_props(out, in); out->interlaced_frame = 0; out->pts = pts; +out->duration = duration; td.out = out; td.in = in; ff_filter_execute(ctx, deinterlace_slice, &td, NULL, @@ -503,19 +504,21 @@ static int config_input(AVFilterLink *inlink) if ((s->deint && !s->prev->interlaced_frame) || ctx->is_disabled) { s->prev->pts *= 2; +s->prev->duration *= 2; ret = ff_filter_frame(ctx->outputs[0], s->prev); s->prev = in; return ret; } -ret = filter(ctx, s->prev, s->prev->pts * 2); +ret = filter(ctx, s->prev, s->prev->pts * 2, + s->prev->duration * (s->mode ? 1 : 2)); if (ret < 0 || s->mode == 0) { av_frame_free(&s->prev); s->prev = in; return ret; } -ret = filter(ctx, s->prev, s->prev->pts + in->pts); +ret = filter(ctx, s->prev, s->prev->pts + in->pts, in->duration); av_frame_free(&s->prev); s->prev = in; return ret; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 7/8] lavfi/vf_estdif: drop a redundant context variable
It is only used in filter() and always set immediately before filter() is called, so it can be passed as a parameter instead. --- libavfilter/vf_estdif.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c index 9a3195fefb..9e826fd424 100644 --- a/libavfilter/vf_estdif.c +++ b/libavfilter/vf_estdif.c @@ -48,7 +48,6 @@ typedef struct ESTDIFContext { int max; int nb_planes; int nb_threads; -int64_t pts; AVFrame *prev; void (*interpolate)(struct ESTDIFContext *s, uint8_t *dst, @@ -433,7 +432,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, return 0; } -static int filter(AVFilterContext *ctx, AVFrame *in) +static int filter(AVFilterContext *ctx, AVFrame *in, int64_t pts) { ESTDIFContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -445,7 +444,7 @@ static int filter(AVFilterContext *ctx, AVFrame *in) return AVERROR(ENOMEM); av_frame_copy_props(out, in); out->interlaced_frame = 0; -out->pts = s->pts; +out->pts = pts; td.out = out; td.in = in; ff_filter_execute(ctx, deinterlace_slice, &td, NULL, @@ -509,16 +508,14 @@ static int config_input(AVFilterLink *inlink) return ret; } -s->pts = s->prev->pts * 2; -ret = filter(ctx, s->prev); +ret = filter(ctx, s->prev, s->prev->pts * 2); if (ret < 0 || s->mode == 0) { av_frame_free(&s->prev); s->prev = in; return ret; } -s->pts = s->prev->pts + in->pts; -ret = filter(ctx, s->prev); +ret = filter(ctx, s->prev, s->prev->pts + in->pts); av_frame_free(&s->prev); s->prev = in; return ret; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/8] lavfi/vf_tinterlace: set frame durations
This filter is supposed to produce CFR output. --- libavfilter/vf_tinterlace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index 399adc102d..7c54861de4 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -510,6 +510,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) } out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); +out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); ret = ff_filter_frame(outlink, out); return ret; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/8] lavfi/vf_estdif: drop an unused function parameter
--- libavfilter/vf_estdif.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c index 45089a01da..9a3195fefb 100644 --- a/libavfilter/vf_estdif.c +++ b/libavfilter/vf_estdif.c @@ -433,7 +433,7 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, return 0; } -static int filter(AVFilterContext *ctx, int is_second, AVFrame *in) +static int filter(AVFilterContext *ctx, AVFrame *in) { ESTDIFContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; @@ -510,7 +510,7 @@ static int config_input(AVFilterLink *inlink) } s->pts = s->prev->pts * 2; -ret = filter(ctx, 0, s->prev); +ret = filter(ctx, s->prev); if (ret < 0 || s->mode == 0) { av_frame_free(&s->prev); s->prev = in; @@ -518,7 +518,7 @@ static int config_input(AVFilterLink *inlink) } s->pts = s->prev->pts + in->pts; -ret = filter(ctx, 1, s->prev); +ret = filter(ctx, s->prev); av_frame_free(&s->prev); s->prev = in; return ret; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/8] lavfi/f_drawgraph: forward input frame durations
--- libavfilter/f_drawgraph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c index 000255fc52..d29a7fb60a 100644 --- a/libavfilter/f_drawgraph.c +++ b/libavfilter/f_drawgraph.c @@ -168,7 +168,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVDictionaryEntry *e; AVFrame *out = s->out; AVFrame *clone = NULL; -int64_t in_pts, out_pts; +int64_t in_pts, out_pts, in_duration; int i; if (s->slide == 4 && s->nb_values >= s->values_size[0] / sizeof(float)) { @@ -320,6 +320,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->x++; in_pts = in->pts; +in_duration = in->duration; av_frame_free(&in); @@ -336,6 +337,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return AVERROR(ENOMEM); clone->pts = s->prev_pts = out_pts; +clone->duration = av_rescale_q(in_duration, inlink->time_base, outlink->time_base); return ff_filter_frame(outlink, clone); } -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/8] lavfi/settb: rescale input frame durations
--- libavfilter/settb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/settb.c b/libavfilter/settb.c index 5f589004f8..23cb02689b 100644 --- a/libavfilter/settb.c +++ b/libavfilter/settb.c @@ -128,6 +128,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) AVFilterLink *outlink = ctx->outputs[0]; frame->pts = rescale_pts(inlink, outlink, frame->pts); +frame->duration = av_rescale_q(frame->duration, inlink->time_base, outlink->time_base); return ff_filter_frame(outlink, frame); } -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/8] lavfi/vf_coreimage: set frame durations
This filter is supposed to produce CFR output. --- libavfilter/vf_coreimage.m | 1 + 1 file changed, 1 insertion(+) diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m index 5b025c2388..874bdc8c56 100644 --- a/libavfilter/vf_coreimage.m +++ b/libavfilter/vf_coreimage.m @@ -300,6 +300,7 @@ static int request_frame(AVFilterLink *link) } frame->pts = ctx->pts; +frame->duration= 1; frame->key_frame = 1; frame->interlaced_frame= 0; frame->pict_type = AV_PICTURE_TYPE_I; -- 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-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 3/3] ffmpeg: add video heartbeat capability to fix_sub_duration
From: Jan Ekström Splits the currently handled subtitle at random access point packets that can be configured to follow a specific output stream. This way the subtitle - which is known to be shown at this time can be split and passed to muxer before its full duration is yet known. Co-authored-by: Andrzej Nadachowski Co-authored-by: Bernard Boulay Signed-off-by: Jan Ekström --- doc/ffmpeg.texi | 11 ++ fftools/ffmpeg.c | 142 ++ fftools/ffmpeg.h | 8 + fftools/ffmpeg_opt.c | 9 ++ tests/fate/ffmpeg.mak | 14 ++ .../fate/ffmpeg-fix_sub_duration_heartbeat| 48 ++ 6 files changed, 232 insertions(+) create mode 100644 tests/ref/fate/ffmpeg-fix_sub_duration_heartbeat diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index e9020b30d5..cd957fa826 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1313,6 +1313,17 @@ List all hardware acceleration components enabled in this build of ffmpeg. Actual runtime availability depends on the hardware and its suitable driver being installed. +@item -fix_sub_duration_heartbeat[:@var{stream_specifier}] +Set a specific output video stream as the heartbeat stream according to which +to split and push through currently in-progress subtitle upon receipt of a +random access packet. + +This lowers the latency of subtitles for which the end packet or the following +subtitle has not yet been received. + +Requires @option{-fix_sub_duration} to be set for the relevant input subtitle +stream for this to have any effect. + @end table @section Audio Options diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a7e6c0f6e0..56fcb994e3 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -128,6 +128,7 @@ typedef struct BenchmarkTimeStamps { int64_t sys_usec; } BenchmarkTimeStamps; +static int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt); static BenchmarkTimeStamps get_benchmark_time_stamps(void); static int64_t getmaxrss(void); static int ifilter_has_all_input_formats(FilterGraph *fg); @@ -978,6 +979,13 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &enc->time_base)); } +if ((ret = trigger_fix_sub_duration_heartbeat(ost, pkt)) < 0) { +av_log(NULL, AV_LOG_ERROR, + "Subtitle heartbeat logic failed in %s! (%s)\n", + __func__, av_err2str(ret)); +exit_program(1); +} + ost->data_size_enc += pkt->size; if (enc->codec_type == AVMEDIA_TYPE_VIDEO) @@ -1934,6 +1942,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase); +{ +int ret = trigger_fix_sub_duration_heartbeat(ost, pkt); +if (ret < 0) { +av_log(NULL, AV_LOG_ERROR, + "Subtitle heartbeat logic failed in %s! (%s)\n", + __func__, av_err2str(ret)); +exit_program(1); +} +} + output_packet(of, opkt, ost, 0); ost->streamcopy_started = 1; @@ -2365,6 +2383,130 @@ out: return ret; } +static int copy_av_subtitle(AVSubtitle *dst, AVSubtitle *src) +{ +int ret = AVERROR_BUG; +AVSubtitle tmp = { +.format = src->format, +.start_display_time = src->start_display_time, +.end_display_time = src->end_display_time, +.num_rects = 0, +.rects = NULL, +.pts = src->pts +}; + +if (!src->num_rects) +goto success; + +if (!(tmp.rects = av_calloc(src->num_rects, sizeof(*tmp.rects +return AVERROR(ENOMEM); + +for (int i = 0; i < src->num_rects; i++) { +AVSubtitleRect *src_rect = src->rects[i]; +AVSubtitleRect *dst_rect; + +if (!(dst_rect = tmp.rects[i] = av_mallocz(sizeof(*tmp.rects[0] { +ret = AVERROR(ENOMEM); +goto cleanup; +} + +tmp.num_rects++; + +dst_rect->type = src_rect->type; +dst_rect->flags = src_rect->flags; + +dst_rect->x = src_rect->x; +dst_rect->y = src_rect->y; +dst_rect->w = src_rect->w; +dst_rect->h = src_rect->h; +dst_rect->nb_colors = src_rect->nb_colors; + +if (src_rect->text) +if (!(dst_rect->text = av_strdup(src_rect->text))) { +ret = AVERROR(ENOMEM); +goto cleanup; +} + +if (src_rect->ass) +if (!(dst_rect->ass = av_strdup(src_rect->ass))) { +ret = AVERROR(ENOMEM); +goto cleanup; +} + +for (int j = 0; j < 4; j++) { +// SUBTITLE_BITMAP images are special in the sense that they +
[FFmpeg-devel] [PATCH v5 2/3] ffmpeg: move decoded frame counter from after post-processing to decode
From: Jan Ekström This way we can call process_subtitles without causing the decoded frame counter to get bumped. Additionally, this now takes into mention all of the decoded subtitle frames without fix_sub_duration latency/buffering, or filtering out decoded reset/end subtitles without any rendered rectangles, which matches the original intent in 4754345027eb85cfa51aeb88beec68d7b036c11e . Signed-off-by: Jan Ekström --- fftools/ffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index fe350fe2bb..a7e6c0f6e0 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2349,8 +2349,6 @@ static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_out if (!subtitle->num_rects) goto out; -ist->frames_decoded++; - for (int i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -2383,6 +2381,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, return ret; } +ist->frames_decoded++; + return process_subtitle(ist, &subtitle, got_output); } -- 2.37.3 ___ 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".
[FFmpeg-devel] [PATCH v5 1/3] ffmpeg: refactor post-decoding steps for subtitles into a function
From: Jan Ekström This enables us to later call this when generating additional subtitles for splitting purposes. Co-authored-by: Andrzej Nadachowski Signed-off-by: Jan Ekström --- fftools/ffmpeg.c | 51 +++- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 754172e568..fe350fe2bb 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2304,27 +2304,15 @@ fail: return err < 0 ? err : ret; } -static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, - int *decode_failed) +static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_output) { -AVSubtitle subtitle; +int ret = 0; int free_sub = 1; -int i, ret = avcodec_decode_subtitle2(ist->dec_ctx, - &subtitle, got_output, pkt); - -check_decode_result(NULL, got_output, ret); - -if (ret < 0 || !*got_output) { -*decode_failed = 1; -if (!pkt->size) -sub2video_flush(ist); -return ret; -} if (ist->fix_sub_duration) { int end = 1; if (ist->prev_sub.got_output) { -end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, +end = av_rescale(subtitle->pts - ist->prev_sub.subtitle.pts, 1000, AV_TIME_BASE); if (end < ist->prev_sub.subtitle.end_display_time) { av_log(NULL, AV_LOG_DEBUG, @@ -2336,7 +2324,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, } FFSWAP(int,*got_output, ist->prev_sub.got_output); FFSWAP(int,ret, ist->prev_sub.ret); -FFSWAP(AVSubtitle, subtitle,ist->prev_sub.subtitle); +FFSWAP(AVSubtitle, *subtitle, ist->prev_sub.subtitle); if (end <= 0) goto out; } @@ -2345,40 +2333,59 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, return ret; if (ist->sub2video.frame) { -sub2video_update(ist, INT64_MIN, &subtitle); +sub2video_update(ist, INT64_MIN, subtitle); } else if (ist->nb_filters) { if (!ist->sub2video.sub_queue) ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW); if (!ist->sub2video.sub_queue) report_and_exit(AVERROR(ENOMEM)); -ret = av_fifo_write(ist->sub2video.sub_queue, &subtitle, 1); +ret = av_fifo_write(ist->sub2video.sub_queue, subtitle, 1); if (ret < 0) exit_program(1); free_sub = 0; } -if (!subtitle.num_rects) +if (!subtitle->num_rects) goto out; ist->frames_decoded++; -for (i = 0; i < nb_output_streams; i++) { +for (int i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; if (!check_output_constraints(ist, ost) || !ost->enc_ctx || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) continue; -do_subtitle_out(output_files[ost->file_index], ost, &subtitle); +do_subtitle_out(output_files[ost->file_index], ost, subtitle); } out: if (free_sub) -avsubtitle_free(&subtitle); +avsubtitle_free(subtitle); return ret; } +static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, + int *decode_failed) +{ +AVSubtitle subtitle; +int ret = avcodec_decode_subtitle2(ist->dec_ctx, + &subtitle, got_output, pkt); + +check_decode_result(NULL, got_output, ret); + +if (ret < 0 || !*got_output) { +*decode_failed = 1; +if (!pkt->size) +sub2video_flush(ist); +return ret; +} + +return process_subtitle(ist, &subtitle, got_output); +} + static int send_filter_eof(InputStream *ist) { int i, ret; -- 2.37.3 ___ 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".
[FFmpeg-devel] [PATCH v3] avformat/hls: Add option to retry failed segments for hls
Current HLS implementation simply skip a failed segment to catch up the stream, but this is not optimal for some use cases like livestream recording. Add an option to retry a failed segment to ensure the output file is a complete stream. Signed-off-by: gnattu --- Fixed commit message wrap libavformat/hls.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index e622425e80..2b977f9132 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -225,6 +225,7 @@ typedef struct HLSContext { int http_persistent; int http_multiple; int http_seekable; +int seg_max_retry; AVIOContext *playlist_pb; HLSCryptoContext crypto_ctx; } HLSContext; @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) int ret; int just_opened = 0; int reload_count = 0; +int segment_retries = 0; struct segment *seg; restart: @@ -1563,9 +1565,18 @@ reload: av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n", v->cur_seq_no, v->index); -v->cur_seq_no += 1; +if (segment_retries >= c->seg_max_retry) { +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of playlist %d failed too many times, skipping\n", + v->cur_seq_no, + v->index); +v->cur_seq_no += 1; +segment_retries = 0; +} else { +segment_retries += 1; +} goto reload; } +segment_retries = 0; just_opened = 1; } @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, {"seg_format_options", "Set options for segment demuxer", OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, +{"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, {NULL} }; -- 2.37.0 (Apple Git-136) ___ 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".
[FFmpeg-devel] [PATCH v2] avformat/hls: Add option to retry failed segments for hls
Current HLS implementation simply skip a failed segment to catch up the stream, but this is not optimal for some use cases like livestream recording. Add an option to retry a failed segment to ensure the output file is a complete stream. Signed-off-by: gnattu --- Previous version was trashed by my email client, sorry. libavformat/hls.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index e622425e80..2b977f9132 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -225,6 +225,7 @@ typedef struct HLSContext { int http_persistent; int http_multiple; int http_seekable; +int seg_max_retry; AVIOContext *playlist_pb; HLSCryptoContext crypto_ctx; } HLSContext; @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) int ret; int just_opened = 0; int reload_count = 0; +int segment_retries = 0; struct segment *seg; restart: @@ -1563,9 +1565,18 @@ reload: av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n", v->cur_seq_no, v->index); -v->cur_seq_no += 1; +if (segment_retries >= c->seg_max_retry) { +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of playlist %d failed too many times, skipping\n", + v->cur_seq_no, + v->index); +v->cur_seq_no += 1; +segment_retries = 0; +} else { +segment_retries += 1; +} goto reload; } +segment_retries = 0; just_opened = 1; } @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, {"seg_format_options", "Set options for segment demuxer", OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, +{"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, {NULL} }; -- 2.37.0 (Apple Git-136) ___ 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".
[FFmpeg-devel] [PATCH v3] avformat/segment: add -strftime_mkdir option
This enables automatically creating directories for strftime-formatted segment names. Signed-off-by: George-Cristian Jiglau --- doc/muxers.texi | 4 libavformat/segment.c | 15 +++ 2 files changed, 19 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 4edbb22b00..5695bc66ae 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2445,6 +2445,10 @@ segments to write. If this is selected, the output segment name must contain a @code{strftime} function template. Default value is @code{0}. +@item strftime_mkdir @var{1|0} +Used together with -strftime, it will create all subdirectories of the +expanded segment name. Default value is @code{0}. + @item break_non_keyframes @var{1|0} If enabled, allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is diff --git a/libavformat/segment.c b/libavformat/segment.c index c904e20708..f75c7228f1 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -94,6 +94,7 @@ typedef struct SegmentContext { AVIOContext *list_pb; ///< list file put-byte context int64_t time; ///< segment duration int use_strftime; ///< flag to expand filename with strftime +int use_strftime_mkdir; ///< flag to mkdir dirname in strftime filename int increment_tc; ///< flag to increment timecode if found char *times_str; ///< segment times specification string @@ -203,6 +204,19 @@ static int set_segment_filename(AVFormatContext *s) av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } +if (seg->use_strftime_mkdir) { +const char *dir; +char *fn_copy = av_strdup(oc->url); +if (!fn_copy) +return AVERROR(ENOMEM); +dir = av_dirname(fn_copy); +if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { +av_log(oc, AV_LOG_ERROR, "Could not create directory %s with strftime_mkdir\n", dir); +av_freep(&fn_copy); +return AVERROR(errno); +} +av_freep(&fn_copy); +} } else if (av_get_frame_filename(buf, sizeof(buf), s->url, seg->segment_idx) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url); @@ -1038,6 +1052,7 @@ static const AVOption options[] = { { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "strftime", "set filename expansion with strftime at segment creation", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, +{ "strftime_mkdir","create directory components in strftime-generated filename", OFFSET(use_strftime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "increment_tc", "increment timecode between each segment", OFFSET(increment_tc), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "break_non_keyframes", "allow breaking segments on non-keyframes", OFFSET(break_non_keyframes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, -- 2.36.2 ___ 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".
Re: [FFmpeg-devel] [PATCH 11/11] doc/filters.texi: update overlay_vaapi documentation
> -Original Message- > From: ffmpeg-devel On Behalf Of > Gyan Doshi > Sent: Monday, October 10, 2022 1:08 PM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 11/11] doc/filters.texi: update > overlay_vaapi documentation > > > > On 2022-10-10 04:24 pm, softworkz wrote: > > From: softworkz > > > > Signed-off-by: softworkz > > --- > > doc/filters.texi | 49 +-- > - > > 1 file changed, 38 insertions(+), 11 deletions(-) > > > > diff --git a/doc/filters.texi b/doc/filters.texi > > index 2d0b5db909..5f4604a834 100644 > > --- a/doc/filters.texi > > +++ b/doc/filters.texi > > @@ -26271,30 +26271,57 @@ It takes two inputs and has one output. > The first input is the "main" video on w > > The filter accepts the following options: > > > > @table @option > > - > > @item x > > -Set the x coordinate of the overlaid video on the main video. > > -Default value is @code{0}. > > - > > @item y > > -Set the y coordinate of the overlaid video on the main video. > > -Default value is @code{0}. > > +Set expressions for the x and y coordinates of the overlaid video > > +on the main video. > > > > -@item w > > -Set the width of the overlaid video on the main video. > > -Default value is the width of input overlay video. > > +Default value is "0" for both expressions. > > > > +@item w > > @item h > > -Set the height of the overlaid video on the main video. > > -Default value is the height of input overlay video. > > +Set expressions for the width and height the overlaid video > > +on the main video. > > The default values should be mentioned here. And also what the > default > value means, if not trivial. > > Regards, > Gyan Yea, you are hitting a point that I had left out because I wasn't sure how detailed this should be explained: The expression handling is done analog to overlay_qsv and I've taken the same defaults which are: { "w", "Overlay width", OFFSET(overlay_ow), AV_OPT_TYPE_STRING, { .str="overlay_iw"}, 0, 255, .flags = FLAGS}, { "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_STRING, { .str="overlay_ih*w/overlay_iw"}, 0, 255, .flags = FLAGS}, Essentially, the values are defaulting to the frame size of the overlay input. This is because both, w and overlay_iw are initialized to the overlay size. The default expression allows to set the width only and have the height be adjusted proportionally. But it doesn't work the other way round (setting h only), so I'm not sure whether it's a good default at all - I just wanted to have it equal to overlay_qsv.. Thanks, softworkz ___ 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".
Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
> -Original Message- > From: ffmpeg-devel On Behalf Of > Anton Khirnov > Sent: Wednesday, August 31, 2022 3:40 AM > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022 > > Quoting Soft Works (2022-08-27 00:48:01) > > 2. "There's no reason why this cannot be handled using the buffer > > and data fields" > > > > I had explained the reasons and in conversation on IRC, Lynne was > > no longer insisting on this AFAIR. > > I did not see this explanation, can you restate it here? > > If you claim the other points were addressed I will look at the > patches > again. > > -- > Anton Khirnov > ___ Friendly Ping :-) ___ 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".
Re: [FFmpeg-devel] [PATCH 11/11] doc/filters.texi: update overlay_vaapi documentation
On 2022-10-10 04:24 pm, softworkz wrote: From: softworkz Signed-off-by: softworkz --- doc/filters.texi | 49 +--- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 2d0b5db909..5f4604a834 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -26271,30 +26271,57 @@ It takes two inputs and has one output. The first input is the "main" video on w The filter accepts the following options: @table @option - @item x -Set the x coordinate of the overlaid video on the main video. -Default value is @code{0}. - @item y -Set the y coordinate of the overlaid video on the main video. -Default value is @code{0}. +Set expressions for the x and y coordinates of the overlaid video +on the main video. -@item w -Set the width of the overlaid video on the main video. -Default value is the width of input overlay video. +Default value is "0" for both expressions. +@item w @item h -Set the height of the overlaid video on the main video. -Default value is the height of input overlay video. +Set expressions for the width and height the overlaid video +on the main video. The default values should be mentioned here. And also what the default value means, if not trivial. Regards, Gyan +The expressions can contain the following parameters: + +@table @option + +@item main_w, W +@item main_h, H +The main input width and height. + +@item overlay_iw +@item overlay_ih +The overlay input width and height. + +@item overlay_w, w +@item overlay_h, h +The overlay output width and height. + +@item overlay_x, x +@item overlay_y, y +Position of the overlay layer inside of main + +@end table @item alpha Set transparency of overlaid video. Allowed range is 0.0 to 1.0. Higher value means lower transparency. Default value is @code{1.0}. +@item eof_action +See @ref{framesync}. + +@item shortest +See @ref{framesync}. + +@item repeatlast +See @ref{framesync}. + @end table +This filter also supports the @ref{framesync} options. @subsection Examples @itemize ___ 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".
[FFmpeg-devel] [PATCH] avformat/hls: Add option to retry failed segments for hls
Current HLS implementation simply skip a failed segment to catch up the stream, but this is not optimal for some use cases like livestream recording. Add an option to retry a failed segment to ensure the output file is a complete stream. Signed-off-by: gnattu --- libavformat/hls.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index e622425e80..2b977f9132 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -225,6 +225,7 @@ typedef struct HLSContext { int http_persistent; int http_multiple; int http_seekable; +int seg_max_retry; AVIOContext *playlist_pb; HLSCryptoContext crypto_ctx; } HLSContext; @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) int ret; int just_opened = 0; int reload_count = 0; +int segment_retries = 0; struct segment *seg; restart: @@ -1563,9 +1565,18 @@ reload: av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n", v->cur_seq_no, v->index); -v->cur_seq_no += 1; +if (segment_retries >= c->seg_max_retry) { +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of playlist %d failed too many times, skipping\n", + v->cur_seq_no, + v->index); +v->cur_seq_no += 1; +segment_retries = 0; +} else { +segment_retries += 1; +} goto reload; } +segment_retries = 0; just_opened = 1; } @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, {"seg_format_options", "Set options for segment demuxer", OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, +{"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, {NULL} }; -- 2.37.0 (Apple Git-136) ___ 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".
[FFmpeg-devel] [PATCH 11/11] doc/filters.texi: update overlay_vaapi documentation
From: softworkz Signed-off-by: softworkz --- doc/filters.texi | 49 +--- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 2d0b5db909..5f4604a834 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -26271,30 +26271,57 @@ It takes two inputs and has one output. The first input is the "main" video on w The filter accepts the following options: @table @option - @item x -Set the x coordinate of the overlaid video on the main video. -Default value is @code{0}. - @item y -Set the y coordinate of the overlaid video on the main video. -Default value is @code{0}. +Set expressions for the x and y coordinates of the overlaid video +on the main video. -@item w -Set the width of the overlaid video on the main video. -Default value is the width of input overlay video. +Default value is "0" for both expressions. +@item w @item h -Set the height of the overlaid video on the main video. -Default value is the height of input overlay video. +Set expressions for the width and height the overlaid video +on the main video. + +The expressions can contain the following parameters: + +@table @option + +@item main_w, W +@item main_h, H +The main input width and height. + +@item overlay_iw +@item overlay_ih +The overlay input width and height. + +@item overlay_w, w +@item overlay_h, h +The overlay output width and height. + +@item overlay_x, x +@item overlay_y, y +Position of the overlay layer inside of main + +@end table @item alpha Set transparency of overlaid video. Allowed range is 0.0 to 1.0. Higher value means lower transparency. Default value is @code{1.0}. +@item eof_action +See @ref{framesync}. + +@item shortest +See @ref{framesync}. + +@item repeatlast +See @ref{framesync}. + @end table +This filter also supports the @ref{framesync} options. @subsection Examples @itemize -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 10/11] doc/filters.texi: remove incorrect statement
From: softworkz Signed-off-by: softworkz --- doc/filters.texi | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 68205147f0..2d0b5db909 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -26267,7 +26267,6 @@ To use vaapi filters, you need to setup the vaapi device correctly. For more inf Overlay one video on the top of another. It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid. -This filter requires same memory layout for all the inputs. So, format conversion may be needed. The filter accepts the following options: -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 09/11] avfilter/overlay_vaapi: enable expressions for overlay parameters
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 141 + 1 file changed, 127 insertions(+), 14 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index b2c254d9dd..7be7d52589 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -27,19 +27,106 @@ #include "formats.h" #include "internal.h" #include "vaapi_vpp.h" +#include "libavutil/eval.h" + +enum var_name { +VAR_MAIN_iW, VAR_MW, +VAR_MAIN_iH, VAR_MH, +VAR_OVERLAY_iW, +VAR_OVERLAY_iH, +VAR_OVERLAY_X, VAR_OX, +VAR_OVERLAY_Y, VAR_OY, +VAR_OVERLAY_W, VAR_OW, +VAR_OVERLAY_H, VAR_OH, +VAR_VARS_NB +}; typedef struct OverlayVAAPIContext { VAAPIVPPContext vpp_ctx; /**< must be the first field */ FFFrameSync fs; -int overlay_ox; -int overlay_oy; -int overlay_ow; -int overlay_oh; + +double var_values[VAR_VARS_NB]; +char *overlay_ox; +char *overlay_oy; +char *overlay_ow; +char *overlay_oh; +int ox; +int oy; +int ow; +int oh; floatalpha; unsigned int blend_flags; floatblend_alpha; } OverlayVAAPIContext; +static const char *const var_names[] = { +"main_w", "W", /* input width of the main layer */ +"main_h", "H", /* input height of the main layer */ +"overlay_iw",/* input width of the overlay layer */ +"overlay_ih",/* input height of the overlay layer */ +"overlay_x", "x", /* x position of the overlay layer inside of main */ +"overlay_y", "y", /* y position of the overlay layer inside of main */ +"overlay_w", "w", /* output width of overlay layer */ +"overlay_h", "h", /* output height of overlay layer */ +NULL +}; + +static int eval_expr(AVFilterContext *avctx) +{ +OverlayVAAPIContext *ctx = avctx->priv; +double *var_values = ctx->var_values; +int ret = 0; +AVExpr *ox_expr = NULL, *oy_expr = NULL; +AVExpr *ow_expr = NULL, *oh_expr = NULL; + +#define PARSE_EXPR(e, s) {\ +ret = av_expr_parse(&(e), s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \ +if (ret < 0) {\ +av_log(ctx, AV_LOG_ERROR, "Error when parsing '%s'.\n", s);\ +goto release;\ +}\ +} +PARSE_EXPR(ox_expr, ctx->overlay_ox) +PARSE_EXPR(oy_expr, ctx->overlay_oy) +PARSE_EXPR(ow_expr, ctx->overlay_ow) +PARSE_EXPR(oh_expr, ctx->overlay_oh) +#undef PASS_EXPR + +var_values[VAR_OVERLAY_W] = +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL); +var_values[VAR_OVERLAY_H] = +var_values[VAR_OH]= av_expr_eval(oh_expr, var_values, NULL); + +/* calc again in case ow is relative to oh */ +var_values[VAR_OVERLAY_W] = +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL); + +var_values[VAR_OVERLAY_X] = +var_values[VAR_OX]= av_expr_eval(ox_expr, var_values, NULL); +var_values[VAR_OVERLAY_Y] = +var_values[VAR_OY]= av_expr_eval(oy_expr, var_values, NULL); + +/* calc again in case ox is relative to oy */ +var_values[VAR_OVERLAY_X] = +var_values[VAR_OX]= av_expr_eval(ox_expr, var_values, NULL); + +/* calc overlay_w and overlay_h again incase relative to ox,oy */ +var_values[VAR_OVERLAY_W] = +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL); +var_values[VAR_OVERLAY_H] = +var_values[VAR_OH]= av_expr_eval(oh_expr, var_values, NULL); +var_values[VAR_OVERLAY_W] = +var_values[VAR_OW]= av_expr_eval(ow_expr, var_values, NULL); + +release: +av_expr_free(ox_expr); +av_expr_free(oy_expr); +av_expr_free(ow_expr); +av_expr_free(oh_expr); + +return ret; +} + static int overlay_vaapi_build_filter_params(AVFilterContext *avctx) { VAAPIVPPContext *vpp_ctx = avctx->priv; @@ -233,10 +320,10 @@ static int overlay_vaapi_blend(FFFrameSync *fs) input_overlay->width, input_overlay->height, input_overlay->pts); overlay_region = (VARectangle) { -.x = ctx->overlay_ox, -.y = ctx->overlay_oy, -.width = ctx->overlay_ow ? ctx->overlay_ow : input_overlay->width, -.height = ctx->overlay_oh ? ctx->overlay_oh : input_overlay->height, +.x = ctx->ox, +.y = ctx->oy, +.width = ctx->ow ? ctx->ow : input_overlay->width, +.height = ctx->oh ? ctx->oh : input_overlay->height, }; if (overlay_region.x + overlay_region.width > input_main->width || @@ -289,10 +376,36 @@ static int have_alpha_planar(AVFilterLink *link) return !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); } +static int overlay_
[FFmpeg-devel] [PATCH 08/11] avfilter/overlay_vaapi: precalculate blend_state, enable pixel alpha
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 44 -- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index f4f9cc58ec..b2c254d9dd 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -36,6 +36,8 @@ typedef struct OverlayVAAPIContext { int overlay_ow; int overlay_oh; floatalpha; +unsigned int blend_flags; +floatblend_alpha; } OverlayVAAPIContext; static int overlay_vaapi_build_filter_params(AVFilterContext *avctx) @@ -246,8 +248,8 @@ static int overlay_vaapi_blend(FFFrameSync *fs) memcpy(&subpic_params, ¶ms, sizeof(subpic_params)); -blend_state.flags = VA_BLEND_GLOBAL_ALPHA; -blend_state.global_alpha = ctx->alpha; +blend_state.flags = ctx->blend_flags; +blend_state.global_alpha = ctx->blend_alpha; subpic_params.blend_state = &blend_state; subpic_params.surface = (VASurfaceID)(uintptr_t)input_overlay->data[3]; @@ -269,6 +271,43 @@ fail: return err; } +static int have_alpha_planar(AVFilterLink *link) +{ +enum AVPixelFormat pix_fmt = link->format; +const AVPixFmtDescriptor *desc; +AVHWFramesContext *fctx; + +if (link->format == AV_PIX_FMT_VAAPI) { +fctx= (AVHWFramesContext *)link->hw_frames_ctx->data; +pix_fmt = fctx->sw_format; +} + +desc = av_pix_fmt_desc_get(pix_fmt); +if (!desc) +return 0; + +return !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); +} + +static int overlay_vaapi_config_input_overlay(AVFilterLink *inlink) +{ +AVFilterContext *avctx = inlink->dst; +OverlayVAAPIContext *ctx = avctx->priv; + +ctx->blend_flags = 0; +ctx->blend_alpha = 1.0f; + +if (ctx->alpha < 1.0f) { +ctx->blend_flags |= VA_BLEND_GLOBAL_ALPHA; +ctx->blend_alpha = ctx->alpha; +} + +if (have_alpha_planar(inlink)) +ctx->blend_flags |= VA_BLEND_PREMULTIPLIED_ALPHA; + +return 0; +} + static int overlay_vaapi_config_output(AVFilterLink *outlink) { AVFilterContext *avctx = outlink->src; @@ -353,6 +392,7 @@ static const AVFilterPad overlay_vaapi_inputs[] = { { .name = "overlay", .type = AVMEDIA_TYPE_VIDEO, +.config_props = overlay_vaapi_config_input_overlay, }, }; -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 07/11] avfilter/overlay_vaapi: add framesync options
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 15 --- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 71fc90a86b..f4f9cc58ec 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -292,8 +292,7 @@ static int overlay_vaapi_config_output(AVFilterLink *outlink) if (err < 0) return err; -ctx->fs.on_event = overlay_vaapi_blend; -ctx->fs.opaque= ctx; +ctx->fs.on_event = overlay_vaapi_blend; ctx->fs.time_base = outlink->time_base; return ff_framesync_configure(&ctx->fs); @@ -321,6 +320,7 @@ static av_cold void overlay_vaapi_uninit(AVFilterContext *avctx) OverlayVAAPIContext *ctx = avctx->priv; ff_framesync_uninit(&ctx->fs); +ff_vaapi_vpp_ctx_uninit(avctx); } #define OFFSET(x) offsetof(OverlayVAAPIContext, x) @@ -331,10 +331,18 @@ static const AVOption overlay_vaapi_options[] = { { "w", "Overlay width",OFFSET(overlay_ow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, { "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, { "alpha", "Overlay global alpha", OFFSET(alpha), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 1.0, .flags = FLAGS }, +{ "eof_action", "Action to take when encountering EOF from secondary input ", +OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT }, +EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" }, +{ "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" }, +{ "endall", "End both streams.",0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" }, +{ "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" }, +{ "shortest", "force termination when the shortest input terminates", OFFSET(fs.opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, +{ "repeatlast", "repeat overlay of the last overlay frame", OFFSET(fs.opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, { NULL }, }; -AVFILTER_DEFINE_CLASS(overlay_vaapi); +FRAMESYNC_DEFINE_CLASS(overlay_vaapi, OverlayVAAPIContext, fs); static const AVFilterPad overlay_vaapi_inputs[] = { { @@ -364,6 +372,7 @@ const AVFilter ff_vf_overlay_vaapi = { .init= &overlay_vaapi_init, .uninit = &overlay_vaapi_uninit, .activate= &overlay_vaapi_activate, +.preinit = overlay_vaapi_framesync_preinit, FILTER_INPUTS(overlay_vaapi_inputs), FILTER_OUTPUTS(overlay_vaapi_outputs), FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VAAPI), -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 06/11] avfilter/overlay_vaapi: remove redundant .get_buffer assignments
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index c14aacbb5d..71fc90a86b 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -340,13 +340,11 @@ static const AVFilterPad overlay_vaapi_inputs[] = { { .name = "main", .type = AVMEDIA_TYPE_VIDEO, -.get_buffer.video = ff_default_get_video_buffer, .config_props = &ff_vaapi_vpp_config_input, }, { .name = "overlay", .type = AVMEDIA_TYPE_VIDEO, -.get_buffer.video = ff_default_get_video_buffer, }, }; -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 05/11] avfilter/overlay_vaapi: reformat options
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 1281038c36..c14aacbb5d 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -326,16 +326,11 @@ static av_cold void overlay_vaapi_uninit(AVFilterContext *avctx) #define OFFSET(x) offsetof(OverlayVAAPIContext, x) #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) static const AVOption overlay_vaapi_options[] = { -{ "x", "Overlay x position", - OFFSET(overlay_ox), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, -{ "y", "Overlay y position", - OFFSET(overlay_oy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, -{ "w", "Overlay width", - OFFSET(overlay_ow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, -{ "h", "Overlay height", - OFFSET(overlay_oh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, -{ "alpha", "Overlay global alpha", - OFFSET(alpha), AV_OPT_TYPE_FLOAT, { .dbl = 1.0}, 0.0, 1.0, .flags = FLAGS}, +{ "x", "Overlay x position", OFFSET(overlay_ox), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, +{ "y", "Overlay y position", OFFSET(overlay_oy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, +{ "w", "Overlay width",OFFSET(overlay_ow), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, +{ "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, +{ "alpha", "Overlay global alpha", OFFSET(alpha), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 1.0, .flags = FLAGS }, { NULL }, }; -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 04/11] avfilter/overlay_vaapi: handle secondary null input
From: softworkz Currently segfaults in this case. Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 94 ++ 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 66e736cce4..1281038c36 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -106,18 +106,6 @@ static int overlay_vaapi_render_picture(AVFilterContext *avctx, params_id); -vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, - VAProcPipelineParameterBufferType, - sizeof(*subpic_params), 1, subpic_params, &subpic_params_id); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer: " - "%d (%s).\n", vas, vaErrorStr(vas)); -err = AVERROR(EIO); -goto fail_after_begin; -} -av_log(avctx, AV_LOG_DEBUG, "Pipeline subpic parameter buffer is %#x.\n", - subpic_params_id); - vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, ¶ms_id, 1); if (vas != VA_STATUS_SUCCESS) { @@ -127,13 +115,27 @@ static int overlay_vaapi_render_picture(AVFilterContext *avctx, goto fail_after_begin; } -vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, - &subpic_params_id, 1); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to render subpic parameter buffer: " - "%d (%s).\n", vas, vaErrorStr(vas)); -err = AVERROR(EIO); -goto fail_after_begin; +if (subpic_params) { +vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, + VAProcPipelineParameterBufferType, + sizeof(*subpic_params), 1, subpic_params, &subpic_params_id); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +err = AVERROR(EIO); +goto fail_after_begin; +} +av_log(avctx, AV_LOG_DEBUG, "Pipeline subpic parameter buffer is %#x.\n", + subpic_params_id); + +vas = vaRenderPicture(ctx->hwctx->display, ctx->va_context, + &subpic_params_id, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to render subpic parameter buffer: " + "%d (%s).\n", vas, vaErrorStr(vas)); +err = AVERROR(EIO); +goto fail_after_begin; +} } vas = vaEndPicture(ctx->hwctx->display, ctx->va_context); @@ -177,7 +179,7 @@ static int overlay_vaapi_blend(FFFrameSync *fs) AVFrame *input_main, *input_overlay; AVFrame *output; VAProcPipelineParameterBuffer params, subpic_params; -VABlendState blend_state; /**< Blend State */ +VABlendState blend_state = { 0 }; /**< Blend State */ VARectangle overlay_region, output_region; int err; @@ -192,10 +194,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs) av_get_pix_fmt_name(input_main->format), input_main->width, input_main->height, input_main->pts); -av_log(avctx, AV_LOG_DEBUG, "Filter overlay: %s, %ux%u (%"PRId64").\n", - av_get_pix_fmt_name(input_overlay->format), - input_overlay->width, input_overlay->height, input_overlay->pts); - if (vpp_ctx->va_context == VA_INVALID_ID) return AVERROR(EINVAL); @@ -214,13 +212,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs) if (err < 0) goto fail; -overlay_region = (VARectangle) { -.x = ctx->overlay_ox, -.y = ctx->overlay_oy, -.width = ctx->overlay_ow ? ctx->overlay_ow : input_overlay->width, -.height = ctx->overlay_oh ? ctx->overlay_oh : input_overlay->height, -}; - output_region = (VARectangle) { .x = 0, .y = 0, @@ -228,29 +219,42 @@ static int overlay_vaapi_blend(FFFrameSync *fs) .height = output->height, }; -if (overlay_region.x + overlay_region.width > input_main->width || -overlay_region.y + overlay_region.height > input_main->height) { -av_log(ctx, AV_LOG_WARNING, - "The overlay image exceeds the scope of the main image, " - "will crop the overlay image according based on the main image.\n"); -} - params.filters = &vpp_ctx->filter_buffers[0]; params.num_filters = vpp_ctx->nb_filter_buffers; params.output_region = &output_region; params.output_background_color = VAAPI_VPP_BACKGROUND_BLACK; -memcpy(&subpic_params, ¶ms, sizeof(subpic_params)); +if (input_overlay) { +av_log(avctx, AV_LOG_DEBUG, "Filter overlay: %s, %ux%u (%"PRId64").\n", + av_get_pix_fmt_name(input_overlay->fo
[FFmpeg-devel] [PATCH 03/11] avfilter/overlay_vaapi: remove double framesync init
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 31 +-- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index cf17426b5d..66e736cce4 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -265,28 +265,6 @@ fail: return err; } -static int overlay_vaapi_init_framesync(AVFilterContext *avctx) -{ -OverlayVAAPIContext *ctx = avctx->priv; -int ret, i; - -ctx->fs.on_event = overlay_vaapi_blend; -ctx->fs.opaque = ctx; -ret = ff_framesync_init(&ctx->fs, avctx, avctx->nb_inputs); -if (ret < 0) -return ret; - -for (i = 0; i < avctx->nb_inputs; i++) { -FFFrameSyncIn *in = &ctx->fs.in[i]; -in->before= EXT_STOP; -in->after = EXT_INFINITY; -in->sync = i ? 1 : 2; -in->time_base = avctx->inputs[i]->time_base; -} - -return ff_framesync_configure(&ctx->fs); -} - static int overlay_vaapi_config_output(AVFilterLink *outlink) { AVFilterContext *avctx = outlink->src; @@ -294,10 +272,7 @@ static int overlay_vaapi_config_output(AVFilterLink *outlink) VAAPIVPPContext *vpp_ctx = avctx->priv; int err; -err = overlay_vaapi_init_framesync(avctx); -if (err < 0) -return err; - +outlink->time_base = avctx->inputs[0]->time_base; vpp_ctx->output_width = avctx->inputs[0]->w; vpp_ctx->output_height = avctx->inputs[0]->h; @@ -313,6 +288,10 @@ static int overlay_vaapi_config_output(AVFilterLink *outlink) if (err < 0) return err; +ctx->fs.on_event = overlay_vaapi_blend; +ctx->fs.opaque= ctx; +ctx->fs.time_base = outlink->time_base; + return ff_framesync_configure(&ctx->fs); } -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 02/11] avfilter/overlay_vaapi: build filter params just once
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 218daf571f..cf17426b5d 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -181,10 +181,6 @@ static int overlay_vaapi_blend(FFFrameSync *fs) VARectangle overlay_region, output_region; int err; -err = overlay_vaapi_build_filter_params(avctx); -if (err < 0) -return err; - err = ff_framesync_get_frame(fs, 0, &input_main, 0); if (err < 0) return err; @@ -309,6 +305,10 @@ static int overlay_vaapi_config_output(AVFilterLink *outlink) if (err < 0) return err; +err = overlay_vaapi_build_filter_params(avctx); +if (err < 0) +return err; + err = ff_framesync_init_dualinput(&ctx->fs, avctx); if (err < 0) return err; -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 01/11] avfilter/overlay_vaapi: use FILTER_SINGLE_PIXFMT
From: softworkz Signed-off-by: softworkz --- libavfilter/vf_overlay_vaapi.c | 30 +- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index 3e6a0de13f..218daf571f 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -38,34 +38,6 @@ typedef struct OverlayVAAPIContext { floatalpha; } OverlayVAAPIContext; -static int overlay_vaapi_query_formats(AVFilterContext *ctx) -{ -int ret; -enum { -MAIN= 0, -OVERLAY = 1, -}; - -static const enum AVPixelFormat pix_fmts[] = { -AV_PIX_FMT_VAAPI, -AV_PIX_FMT_NONE -}; - -ret = ff_formats_ref(ff_make_format_list(pix_fmts), &ctx->inputs[MAIN]->outcfg.formats); -if (ret < 0) -return ret; - -ret = ff_formats_ref(ff_make_format_list(pix_fmts), &ctx->inputs[OVERLAY]->outcfg.formats); -if (ret < 0) -return ret; - -ret = ff_formats_ref(ff_make_format_list(pix_fmts), &ctx->outputs[0]->incfg.formats); -if (ret < 0) -return ret; - -return 0; -} - static int overlay_vaapi_build_filter_params(AVFilterContext *avctx) { VAAPIVPPContext *vpp_ctx = avctx->priv; @@ -418,6 +390,6 @@ const AVFilter ff_vf_overlay_vaapi = { .activate= &overlay_vaapi_activate, FILTER_INPUTS(overlay_vaapi_inputs), FILTER_OUTPUTS(overlay_vaapi_outputs), -FILTER_QUERY_FUNC(overlay_vaapi_query_formats), +FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VAAPI), .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH 00/11] Fixes and Enhancements for VAAPI Overlay
This patchset resolves a number of issues in the current code: * Bogus doubles framesync initialization * Executing build_parameters on each input frame * Segfault when there's no secondary input (yet) and adds a number of enhancements to bring this on-par with the other overlay filters: * Enable pixel alpha blending * Expose framesync parameters * Add support for expressions in overlay parameters (x, y, w, h) softworkz (11): avfilter/overlay_vaapi: use FILTER_SINGLE_PIXFMT avfilter/overlay_vaapi: build filter params just once avfilter/overlay_vaapi: remove double framesync init avfilter/overlay_vaapi: handle secondary null input avfilter/overlay_vaapi: reformat options avfilter/overlay_vaapi: remove redundant .get_buffer assignments avfilter/overlay_vaapi: add framesync options avfilter/overlay_vaapi: precalculate blend_state, enable pixel alpha avfilter/overlay_vaapi: enable expressions for overlay parameters doc/filters.texi: remove incorrect statement doc/filters.texi: update overlay_vaapi documentation doc/filters.texi | 50 +++-- libavfilter/vf_overlay_vaapi.c | 328 ++--- 2 files changed, 257 insertions(+), 121 deletions(-) base-commit: f3b5277057ad84071721f01419fe4badeceaff08 Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-42%2Fsoftworkz%2Fsubmit_vaapi_overlay-v1 Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-42/softworkz/submit_vaapi_overlay-v1 Pull-Request: https://github.com/ffstaging/FFmpeg/pull/42 -- ffmpeg-codebot ___ 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".
[FFmpeg-devel] [PATCH] avformat/hls: Add option to retry failed segments for hls
Current HLS implementation simply skip a failed segment to catch up the stream, but this is not optimal for some use cases like livestream recording. Add an option to retry a failed segment to ensure the output file is a complete stream. Signed-off-by: gnattu --- libavformat/hls.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index e622425e80..2b977f9132 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -225,6 +225,7 @@ typedef struct HLSContext { int http_persistent; int http_multiple; int http_seekable; +int seg_max_retry; AVIOContext *playlist_pb; HLSCryptoContext crypto_ctx; } HLSContext; @@ -1472,6 +1473,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size) int ret; int just_opened = 0; int reload_count = 0; +int segment_retries = 0; struct segment *seg; restart: @@ -1563,9 +1565,18 @@ reload: av_log(v->parent, AV_LOG_WARNING, "Failed to open segment %"PRId64" of playlist %d\n", v->cur_seq_no, v->index); -v->cur_seq_no += 1; +if (segment_retries >= c->seg_max_retry) { +av_log(v->parent, AV_LOG_WARNING, "Segment %"PRId64" of playlist %d failed too many times, skipping\n", + v->cur_seq_no, + v->index); +v->cur_seq_no += 1; +segment_retries = 0; +} else { +segment_retries += 1; +} goto reload; } +segment_retries = 0; just_opened = 1; } @@ -2549,6 +2560,8 @@ static const AVOption hls_options[] = { OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, {"seg_format_options", "Set options for segment demuxer", OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, +{"seg_max_retry", "Maximum number of times to reload a segment on error.", + OFFSET(seg_max_retry), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS}, {NULL} }; -- 2.37.0 (Apple Git-136) ___ 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".
[FFmpeg-devel] [PATCH v2] avformat/segment: add -strftime_mkdir option
This enables automatically creating directories for strftime-formatted segment names. Signed-off-by: George-Cristian Jiglau --- doc/muxers.texi | 4 libavformat/segment.c | 15 +++ 2 files changed, 19 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 4edbb22b00..96b63f4b9e 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2445,6 +2445,10 @@ segments to write. If this is selected, the output segment name must contain a @code{strftime} function template. Default value is @code{0}. +@item strftime_mkdir @var{1|0| +Used together with -strftime, it will create all subdirectories of the +expanded segment name. Default value is @code{0}. + @item break_non_keyframes @var{1|0} If enabled, allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is diff --git a/libavformat/segment.c b/libavformat/segment.c index c904e20708..f75c7228f1 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -94,6 +94,7 @@ typedef struct SegmentContext { AVIOContext *list_pb; ///< list file put-byte context int64_t time; ///< segment duration int use_strftime; ///< flag to expand filename with strftime +int use_strftime_mkdir; ///< flag to mkdir dirname in strftime filename int increment_tc; ///< flag to increment timecode if found char *times_str; ///< segment times specification string @@ -203,6 +204,19 @@ static int set_segment_filename(AVFormatContext *s) av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } +if (seg->use_strftime_mkdir) { +const char *dir; +char *fn_copy = av_strdup(oc->url); +if (!fn_copy) +return AVERROR(ENOMEM); +dir = av_dirname(fn_copy); +if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { +av_log(oc, AV_LOG_ERROR, "Could not create directory %s with strftime_mkdir\n", dir); +av_freep(&fn_copy); +return AVERROR(errno); +} +av_freep(&fn_copy); +} } else if (av_get_frame_filename(buf, sizeof(buf), s->url, seg->segment_idx) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url); @@ -1038,6 +1052,7 @@ static const AVOption options[] = { { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "strftime", "set filename expansion with strftime at segment creation", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, +{ "strftime_mkdir","create directory components in strftime-generated filename", OFFSET(use_strftime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "increment_tc", "increment timecode between each segment", OFFSET(increment_tc), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "break_non_keyframes", "allow breaking segments on non-keyframes", OFFSET(break_non_keyframes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, -- 2.36.2 ___ 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".
[FFmpeg-devel] [PATCH] avformat/segment: add -strftime_mkdir option
This enabled automatically creating directories for strftime-formatted segment names. Signed-off-by: George-Cristian Jiglau --- doc/muxers.texi | 11 +++ libavformat/segment.c | 18 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 4edbb22b00..77792379d9 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2445,6 +2445,17 @@ segments to write. If this is selected, the output segment name must contain a @code{strftime} function template. Default value is @code{0}. +@item strftime_mkdir @var{1|0| +Used together with -strftime, it will create all subdirectories of the +expanded segment name. Default value is @code{0}. + +@example +ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8 +@end example +This example will create a directory hierarchy 2016/02/15 (if any of them do not exist), and then +produce the playlist, @file{out.m3u8}, and segment files: +@file{2016/02/15/file-20160215-1455569023.ts}, @file{2016/02/15/file-20160215-1455569024.ts}, etc. + @item break_non_keyframes @var{1|0} If enabled, allow segments to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is diff --git a/libavformat/segment.c b/libavformat/segment.c index c904e20708..ef95b34beb 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -93,9 +93,11 @@ typedef struct SegmentContext { int list_type; ///< set the list type AVIOContext *list_pb; ///< list file put-byte context int64_t time; ///< segment duration -int use_strftime; ///< flag to expand filename with strftime int increment_tc; ///< flag to increment timecode if found +int use_strftime; ///< flag to expand filename with strftime +int use_strftime_mkdir; ///< flag to mkdir dirname in strftime filename + char *times_str; ///< segment times specification string int64_t *times;///< list of segment interval specification int nb_times; ///< number of elments in the times array @@ -203,6 +205,19 @@ static int set_segment_filename(AVFormatContext *s) av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } +if (seg->use_strftime_mkdir) { +const char *dir; +char *fn_copy = av_strdup(oc->url); +if (!fn_copy) +return AVERROR(ENOMEM); +dir = av_dirname(fn_copy); +if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { +av_log(oc, AV_LOG_ERROR, "Could not create directory %s with strftime_mkdir\n", dir); +av_freep(&fn_copy); +return AVERROR(errno); +} +av_freep(&fn_copy); +} } else if (av_get_frame_filename(buf, sizeof(buf), s->url, seg->segment_idx) < 0) { av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url); @@ -1038,6 +1053,7 @@ static const AVOption options[] = { { "segment_start_number", "set the sequence number of the first segment", OFFSET(segment_idx), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "segment_wrap_number", "set the number of wrap before the first segment", OFFSET(segment_idx_wrap_nb), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E }, { "strftime", "set filename expansion with strftime at segment creation", OFFSET(use_strftime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, +{ "strftime_mkdir","create directory components in strftime-generated filename", OFFSET(use_strftime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "increment_tc", "increment timecode between each segment", OFFSET(increment_tc), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, { "break_non_keyframes", "allow breaking segments on non-keyframes", OFFSET(break_non_keyframes), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E }, -- 2.36.2 ___ 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".
[FFmpeg-devel] [PATCH] lavc/qsvenc: fill the padding area
From: Haihao Xiang qsvenc makes a copy when the input in system memory is not padded as the SDK requires, however the padding area is not filled with right data Signed-off-by: Haihao Xiang --- libavcodec/qsvenc.c | 69 +++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index dc5479d0f3..15e6936a65 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1514,6 +1514,64 @@ static int get_free_frame(QSVEncContext *q, QSVFrame **f) return 0; } +static int qsvenc_fill_padding_area(AVFrame *frame, int new_w, int new_h) +{ +const AVPixFmtDescriptor *desc; +int max_step[4], filled[4] = { 0 }; + +desc = av_pix_fmt_desc_get(frame->format); +av_assert0(desc); +av_image_fill_max_pixsteps(max_step, NULL, desc); + +for (int i = 0; i < desc->nb_components; i++) { +const AVComponentDescriptor *comp = &desc->comp[i]; +int sheight, dheight, plane = comp->plane; +ptrdiff_t swidth = av_image_get_linesize(frame->format, + frame->width, + plane); +ptrdiff_t dwidth = av_image_get_linesize(frame->format, + new_w, + plane); + +if (swidth < 0 || dwidth < 0) { +av_log(NULL, AV_LOG_ERROR, "av_image_get_linesize failed\n"); +return AVERROR(EINVAL); +} + +if (filled[plane]) +continue; + +sheight = frame->height; +dheight = new_h; + +if (plane) { +sheight = AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h); +dheight = AV_CEIL_RSHIFT(new_h, desc->log2_chroma_h); +} + +// Fill right padding +if (new_w > frame->width) { +for (int j = 0; j < sheight; j++) { +void *line_ptr = frame->data[plane] + j * frame->linesize[plane] + swidth; + +av_memcpy_backptr(line_ptr, + max_step[plane], + new_w - frame->width); +} +} + +// Fill bottom padding +for (int j = sheight; j < dheight; j++) +memcpy(frame->data[plane] + j * frame->linesize[plane], + frame->data[plane] + (sheight - 1) * frame->linesize[plane], + dwidth); + +filled[plane] = 1; +} + +return 0; +} + static int submit_frame(QSVEncContext *q, const AVFrame *frame, QSVFrame **new_frame) { @@ -1543,8 +1601,9 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, /* and to make allocation continious for data[0]/data[1] */ if ((frame->height & 31 || frame->linesize[0] & (q->width_align - 1)) || (frame->data[1] - frame->data[0] != frame->linesize[0] * FFALIGN(qf->frame->height, q->height_align))) { -qf->frame->height = FFALIGN(frame->height, q->height_align); -qf->frame->width = FFALIGN(frame->width, q->width_align); +int tmp_w, tmp_h; +qf->frame->height = tmp_h = FFALIGN(frame->height, q->height_align); +qf->frame->width = tmp_w = FFALIGN(frame->width, q->width_align); qf->frame->format = frame->format; @@ -1562,6 +1621,12 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, av_frame_unref(qf->frame); return ret; } + +ret = qsvenc_fill_padding_area(qf->frame, tmp_w, tmp_h); +if (ret < 0) { +av_frame_unref(qf->frame); +return ret; +} } else { av_frame_unref(qf->frame); ret = av_frame_ref(qf->frame, frame); -- 2.17.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".
Re: [FFmpeg-devel] [PATCH 1/1] Enable building with WSL and MSVC
On Sat, Oct 8, 2022 at 4:37 PM Carl Eugen Hoyos wrote: > Am Sa., 8. Okt. 2022 um 10:39 Uhr schrieb Julio C. Rocha : > > > > On Sun, Oct 2, 2022 at 4:48 PM Julio C. Rocha wrote: > > > > > --- > > > configure | 7 ++- > > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > > > diff --git a/configure b/configure > > > index 6712d045d9..f5f5eb29dd 100755 > > > --- a/configure > > > +++ b/configure > > > @@ -4847,7 +4847,12 @@ probe_cc(){ > > > else > > > _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d > '\r') > > > fi > > > -_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | > > > awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if > > > (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' > > > +if [ "$(grep -i Microsoft /proc/version)" ]; then > > > +# Windows Subsystem for Linux > > > +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< > 2>&1 > > > | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if > > > (!match($$0, / /)) { cmd="/usr/bin/wslpath \x27" $$0 "\x27"; cmd |& > getline > > > pth; print "$@:", pth } }'\'' > $(@:.o=.d)' > > > +else > > > +_DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< > 2>&1 > > > | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if > > > (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' > > > +fi > > > _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' > > > _cflags_speed="-O2" > > > _cflags_size="-O1" > > > -- > > > 2.37.0 (Apple Git-136) > > > > > > > > Hi! I'd like to re-request feedback for this patch. > > > > To clarify, it allows building FFmpeg using MSVC over WSL, without any > > dependency on MinGW or MSYS. > > Hi Carl. I'm new to building FFmpeg, so need to make some follow-up questions. > You write in your own explanations "Succeeds" - this and what the patch > is meant to fix are missing from your commit message. > Should I resubmit the patch from scratch with an improved commit message? > Your patch would not work here - sadly, cl.exe does not print "including" > for all installations. > Can you please elaborate? If I understand correctly, you are saying older versions of CL.EXE would not print "including". Wouldn't that also be an issue for the non-WSL case currently existing in the configure script?: else _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)' To finish this point, what sort of installations would fail with the proposed patch? > I build FFmpeg regularly with wsl and msvc and others do as well. > Dependency files are simply empty here (because cl.exe prints > "Einlesen der Datei" here). Do you still rely on msys/mingw packages? This patch tries to address this by removing such dependency. How can I configure FFmpeg to ignore/leave empty the dependency files? > Dependency generation works for me with --dep-cc=clang-cl.exe but > I normally just build without it. > > Using clang-cl may not be an option when the software to be integrated with a specific FFmpeg build expects binary compatibility with plain MSVC. Looking forward to applying the suggestions once clarified. ___ 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".
[FFmpeg-devel] [PATCH] avcodec/mediacodec: fix incorrect crop info
From: Zhao Zhili The crop info is optional, but used unconditionally. Signed-off-by: Zhao Zhili --- libavcodec/mediacodecdec_common.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index 2a605e7f5b..c1cbb28488 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -487,6 +487,11 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte AMEDIAFORMAT_GET_INT32(s->crop_left, "crop-left", 0); AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0); +if (s->crop_bottom == 0 || s->crop_right == 0) { +s->crop_top = s->crop_left = 0; +s->crop_right = s->width - 1; +s->crop_bottom = s->height - 1; +} width = s->crop_right + 1 - s->crop_left; height = s->crop_bottom + 1 - s->crop_top; -- 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".