Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 07.01.2019 15:31, Dmitry Humeniuk wrote: Signed-off-by: Dmitry Humeniuk --- Changelog|1 + doc/filters.texi | 23 + libavfilter/Makefile |1 + libavfilter/af_dumpwave.c| 234 libavfilter/allfilters.c |1 + libavfilter/version.h|4 +- tests/fate-run.sh|9 + tests/fate/filter-audio.mak | 12 + tests/ref/fate/filter-dumpwave | 1800 ++ tests/ref/fate/filter-dumpwave-24bit | 1800 ++ tests/ref/fate/filter-dumpwave-fltp | 1800 ++ 11 files changed, 5683 insertions(+), 2 deletions(-) create mode 100644 libavfilter/af_dumpwave.c create mode 100644 tests/ref/fate/filter-dumpwave create mode 100644 tests/ref/fate/filter-dumpwave-24bit create mode 100644 tests/ref/fate/filter-dumpwave-fltp diff --git a/Changelog b/Changelog index f135fa56b6..1eb337796b 100644 --- a/Changelog +++ b/Changelog @@ -13,6 +13,7 @@ version : - GIF parser - vividas demuxer - hymt decoder +- dumpwave filter version 4.1: diff --git a/doc/filters.texi b/doc/filters.texi index 98858c5356..66c2961fd8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2912,6 +2912,29 @@ Set window length in seconds used to split audio into segments of equal length. Default is 3 seconds. @end table +@section dumpwave +Dump RMS envelope to a file. +Convert samples to decibels and calculates RMS (Root-Mean-Square) audio power in 0 to 1.0 floats. + +@table @option +@item w, width +Number of data values. +The default value is @var{1800} + +@item n, nb_samples +Samples count per value per channel, default 128 + +@item f, file +Path to a file ``-'' is a shorthand +for standard output. +@end table + +For example, to generate RMS envelope for 44.1 kHz 6 seconds length audio +with dimensions @var{1800x140}, samples count @code{44100*6/1800=147} and store it to @var{/tmp/out.csv}, you might use: +@example +dumpwave=w=1800:n=147:f=/tmp/out.csv +@end example + @section dynaudnorm Dynamic Audio Normalizer. [...] I appreciate the completeness of the proposed patch (documentation, tests, version bump) but it seems that the functionality overlaps with existing filters. Besides the different output format I think the same can be achieved by using a command like: ffmpeg -i input.wav -f null -filter:a "asetnsamples=147,astats=metadata=on,ametadata=print:key=lavfi.astats.Overall.RMS_peak:file=/tmp/out.dat" /dev/null So if it is only about the output format, it would be better to add CSV support to the ametadata filter, IMHO. That way other filters with frame metadata output will also gain CSV support. Best regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
Hi > On 14 Jan 2018, at 04:04, Michael Niedermayerwrote: > > On Sat, Jan 13, 2018 at 11:59:59PM +0100, Dmytro Humeniuk wrote: >> Hi, >>> On 12 Jan 2018, at 00:20, Dmitry Gumenyuk wrote: >>> -- >>> Best regards, >>> Dmytro >>> On 11 Jan 2018, at 23:57, Paul B Mahol wrote: > On 1/11/18, Dmitry Gumenyuk wrote: > >>> On 11 Jan 2018, at 23:02, Paul B Mahol wrote: >>> >>> On 1/11/18, Dmitry Gumenyuk wrote: >>> > On 11 Jan 2018, at 22:41, Paul B Mahol wrote: > > On 1/11/18, Dmitry Gumenyuk wrote: > Hello > > 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : >>> On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com >>> wrote: >>> >>> +@table @option >>> +@item d >>> +Dimensions @code{WxH}. >>> +@code{W} - number of data values in json, values will be scaled >>> according to @code{H}. >>> +The default value is @var{640x480} >>> + >>> +@item s >>> +Samples count per value per channel >> >> In most other filters/filtersources, s+size is used for dimensions, >> d+duration for time, and n for an amount/number of frames/samples or >> so. Might be a good idea to align with this. And use aliases (i.e. >> implement both "s" and "size"). >> >>> +static const AVOption dumpwave_options[] = { >>> +{ "d", "set width and height", OFFSET(w), >>> AV_OPT_TYPE_IMAGE_SIZE, >>> {.str = "640x480"}, 0, 0, FLAGS }, >>> +{ "s", "set number of samples per value per channel", >>> OFFSET(s), >>> AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >>> +{ "json", "set json dump file", OFFSET(json), >>> AV_OPT_TYPE_STRING, >>> { >>> .str = NULL }, 0, 0, FLAGS }, >>> +{ NULL } >> [...] >>> +static av_cold int init(AVFilterContext *ctx) >>> +{ >>> +DumpWaveContext *dumpwave = ctx->priv; >>> +if(!dumpwave->s) { >>> +dumpwave->is_disabled = 1; >>> +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value >>> config\n"); >>> +} >>> +return 0; >> >> I don't like the idea of having to provide the "s" parameter. Is >> there >> really no useful default? >> >> And now, if s=0, what does the filter do? Just sit around? Couldn't >> it >> fail instead? >> >> Apart from that: >> "if (" is the bracket style ffmpeg uses. >> >>> +if (dumpwave->json && !(dump_fp = >>> av_fopen_utf8(dumpwave->json, >>> "w"))) >>> +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); >> >> I would appreciate evaluation of errno and printing the appropriate >> string (using av_strerror(), I believe). >> >>> +switch (inlink->format) { >>> +case AV_SAMPLE_FMT_DBLP: >> >> As Kyle hinted: Can this not force a conversion (implicit insertion >> of >> aformat filter) to e.g. double by only supporting this format, and >> reducing this switch to one or two cases? (The filter's output isn't >> really meant for transparent reuse anyway? af_volumedetect e.g. also >> supports only one, meaning its output can be a different format than >> its input.) It's also really hard to go through and later to >> maintain. >> It the big switch/case remains, one or two code macros would be >> appropriate. > > I checked solution used in volumedetect and couldn't find a way to > read across formats. I do not understand what you are trying to do. >>> Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample >>> formats > How would you implement such macros? Since version 3.2 astats filter > uses same approach for reading different formats and as far as I know > macros harder to debug astats is using all formats because of numerous reasons. astats uses raw values, your filter just convert each raw value to float representation. >>> Is this wrong, as I'd like to have high precision? >> >> For rendering to small size image? > Data can be used for analysis as well. Any size I would say as user may > define size Than use floats. >>> Ok, will give it a try >> Here is updated patch ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On Sat, Jan 13, 2018 at 11:59:59PM +0100, Dmytro Humeniuk wrote: > Hi, > > On 12 Jan 2018, at 00:20, Dmitry Gumenyukwrote: > > -- > > Best regards, > > Dmytro > > > >> On 11 Jan 2018, at 23:57, Paul B Mahol wrote: > >> > >>> On 1/11/18, Dmitry Gumenyuk wrote: > >>> > > On 11 Jan 2018, at 23:02, Paul B Mahol wrote: > > > > On 1/11/18, Dmitry Gumenyuk wrote: > > > >>> On 11 Jan 2018, at 22:41, Paul B Mahol wrote: > >>> > >>> On 1/11/18, Dmitry Gumenyuk wrote: > >>> Hello > >>> > >>> 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : > > On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com > > wrote: > > > > +@table @option > > +@item d > > +Dimensions @code{WxH}. > > +@code{W} - number of data values in json, values will be scaled > > according to @code{H}. > > +The default value is @var{640x480} > > + > > +@item s > > +Samples count per value per channel > > In most other filters/filtersources, s+size is used for dimensions, > d+duration for time, and n for an amount/number of frames/samples or > so. Might be a good idea to align with this. And use aliases (i.e. > implement both "s" and "size"). > > > +static const AVOption dumpwave_options[] = { > > +{ "d", "set width and height", OFFSET(w), > > AV_OPT_TYPE_IMAGE_SIZE, > > {.str = "640x480"}, 0, 0, FLAGS }, > > +{ "s", "set number of samples per value per channel", > > OFFSET(s), > > AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > > +{ "json", "set json dump file", OFFSET(json), > > AV_OPT_TYPE_STRING, > > { > > .str = NULL }, 0, 0, FLAGS }, > > +{ NULL } > [...] > > +static av_cold int init(AVFilterContext *ctx) > > +{ > > +DumpWaveContext *dumpwave = ctx->priv; > > +if(!dumpwave->s) { > > +dumpwave->is_disabled = 1; > > +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value > > config\n"); > > +} > > +return 0; > > I don't like the idea of having to provide the "s" parameter. Is > there > really no useful default? > > And now, if s=0, what does the filter do? Just sit around? Couldn't > it > fail instead? > > Apart from that: > "if (" is the bracket style ffmpeg uses. > > > +if (dumpwave->json && !(dump_fp = > > av_fopen_utf8(dumpwave->json, > > "w"))) > > +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); > > I would appreciate evaluation of errno and printing the appropriate > string (using av_strerror(), I believe). > > > +switch (inlink->format) { > > +case AV_SAMPLE_FMT_DBLP: > > As Kyle hinted: Can this not force a conversion (implicit insertion > of > aformat filter) to e.g. double by only supporting this format, and > reducing this switch to one or two cases? (The filter's output isn't > really meant for transparent reuse anyway? af_volumedetect e.g. also > supports only one, meaning its output can be a different format than > its input.) It's also really hard to go through and later to > maintain. > It the big switch/case remains, one or two code macros would be > appropriate. > >>> > >>> I checked solution used in volumedetect and couldn't find a way to > >>> read across formats. > >> > >> I do not understand what you are trying to do. > > Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample > > formats > >>> How would you implement such macros? Since version 3.2 astats filter > >>> uses same approach for reading different formats and as far as I know > >>> macros harder to debug > >> > >> astats is using all formats because of numerous reasons. astats uses > >> raw > >> values, > >> your filter just convert each raw value to float representation. > > Is this wrong, as I'd like to have high precision? > > For rendering to small size image? > >>> Data can be used for analysis as well. Any size I would say as user may > >>> define size > >> > >> Than use floats. > > Ok, will give it a try > Here is updated patch > >> ___ > >> ffmpeg-devel mailing list > >> ffmpeg-devel@ffmpeg.org > >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > Changelog
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
Hi, > On 12 Jan 2018, at 00:20, Dmitry Gumenyukwrote: > -- > Best regards, > Dmytro > >> On 11 Jan 2018, at 23:57, Paul B Mahol wrote: >> >>> On 1/11/18, Dmitry Gumenyuk wrote: >>> > On 11 Jan 2018, at 23:02, Paul B Mahol wrote: > > On 1/11/18, Dmitry Gumenyuk wrote: > >>> On 11 Jan 2018, at 22:41, Paul B Mahol wrote: >>> >>> On 1/11/18, Dmitry Gumenyuk wrote: >>> Hello >>> >>> 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : > On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com > wrote: > > +@table @option > +@item d > +Dimensions @code{WxH}. > +@code{W} - number of data values in json, values will be scaled > according to @code{H}. > +The default value is @var{640x480} > + > +@item s > +Samples count per value per channel In most other filters/filtersources, s+size is used for dimensions, d+duration for time, and n for an amount/number of frames/samples or so. Might be a good idea to align with this. And use aliases (i.e. implement both "s" and "size"). > +static const AVOption dumpwave_options[] = { > +{ "d", "set width and height", OFFSET(w), > AV_OPT_TYPE_IMAGE_SIZE, > {.str = "640x480"}, 0, 0, FLAGS }, > +{ "s", "set number of samples per value per channel", > OFFSET(s), > AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > +{ "json", "set json dump file", OFFSET(json), > AV_OPT_TYPE_STRING, > { > .str = NULL }, 0, 0, FLAGS }, > +{ NULL } [...] > +static av_cold int init(AVFilterContext *ctx) > +{ > +DumpWaveContext *dumpwave = ctx->priv; > +if(!dumpwave->s) { > +dumpwave->is_disabled = 1; > +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value > config\n"); > +} > +return 0; I don't like the idea of having to provide the "s" parameter. Is there really no useful default? And now, if s=0, what does the filter do? Just sit around? Couldn't it fail instead? Apart from that: "if (" is the bracket style ffmpeg uses. > +if (dumpwave->json && !(dump_fp = > av_fopen_utf8(dumpwave->json, > "w"))) > +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); I would appreciate evaluation of errno and printing the appropriate string (using av_strerror(), I believe). > +switch (inlink->format) { > +case AV_SAMPLE_FMT_DBLP: As Kyle hinted: Can this not force a conversion (implicit insertion of aformat filter) to e.g. double by only supporting this format, and reducing this switch to one or two cases? (The filter's output isn't really meant for transparent reuse anyway? af_volumedetect e.g. also supports only one, meaning its output can be a different format than its input.) It's also really hard to go through and later to maintain. It the big switch/case remains, one or two code macros would be appropriate. >>> >>> I checked solution used in volumedetect and couldn't find a way to >>> read across formats. >> >> I do not understand what you are trying to do. > Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample > formats >>> How would you implement such macros? Since version 3.2 astats filter >>> uses same approach for reading different formats and as far as I know >>> macros harder to debug >> >> astats is using all formats because of numerous reasons. astats uses >> raw >> values, >> your filter just convert each raw value to float representation. > Is this wrong, as I'd like to have high precision? For rendering to small size image? >>> Data can be used for analysis as well. Any size I would say as user may >>> define size >> >> Than use floats. > Ok, will give it a try Here is updated patch >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel FFmpeg-devel-v2-avfilter-add-dumpwave-filter.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
-- Best regards, Dmytro > On 11 Jan 2018, at 23:57, Paul B Maholwrote: > >> On 1/11/18, Dmitry Gumenyuk wrote: >> On 11 Jan 2018, at 23:02, Paul B Mahol wrote: On 1/11/18, Dmitry Gumenyuk wrote: >> On 11 Jan 2018, at 22:41, Paul B Mahol wrote: >> >> On 1/11/18, Dmitry Gumenyuk wrote: >> Hello >> >> 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com wrote: +@table @option +@item d +Dimensions @code{WxH}. +@code{W} - number of data values in json, values will be scaled according to @code{H}. +The default value is @var{640x480} + +@item s +Samples count per value per channel >>> >>> In most other filters/filtersources, s+size is used for dimensions, >>> d+duration for time, and n for an amount/number of frames/samples or >>> so. Might be a good idea to align with this. And use aliases (i.e. >>> implement both "s" and "size"). >>> +static const AVOption dumpwave_options[] = { +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS }, +{ "s", "set number of samples per value per channel", OFFSET(s), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, +{ NULL } >>> [...] +static av_cold int init(AVFilterContext *ctx) +{ +DumpWaveContext *dumpwave = ctx->priv; +if(!dumpwave->s) { +dumpwave->is_disabled = 1; +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value config\n"); +} +return 0; >>> >>> I don't like the idea of having to provide the "s" parameter. Is >>> there >>> really no useful default? >>> >>> And now, if s=0, what does the filter do? Just sit around? Couldn't >>> it >>> fail instead? >>> >>> Apart from that: >>> "if (" is the bracket style ffmpeg uses. >>> +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, "w"))) +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); >>> >>> I would appreciate evaluation of errno and printing the appropriate >>> string (using av_strerror(), I believe). >>> +switch (inlink->format) { +case AV_SAMPLE_FMT_DBLP: >>> >>> As Kyle hinted: Can this not force a conversion (implicit insertion >>> of >>> aformat filter) to e.g. double by only supporting this format, and >>> reducing this switch to one or two cases? (The filter's output isn't >>> really meant for transparent reuse anyway? af_volumedetect e.g. also >>> supports only one, meaning its output can be a different format than >>> its input.) It's also really hard to go through and later to >>> maintain. >>> It the big switch/case remains, one or two code macros would be >>> appropriate. >> >> I checked solution used in volumedetect and couldn't find a way to >> read across formats. > > I do not understand what you are trying to do. Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample formats >> How would you implement such macros? Since version 3.2 astats filter >> uses same approach for reading different formats and as far as I know >> macros harder to debug > > astats is using all formats because of numerous reasons. astats uses > raw > values, > your filter just convert each raw value to float representation. Is this wrong, as I'd like to have high precision? >>> >>> For rendering to small size image? >> Data can be used for analysis as well. Any size I would say as user may >> define size > > Than use floats. Ok, will give it a try > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel smime.p7s Description: S/MIME cryptographic signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 1/11/18, Dmitry Gumenyukwrote: > >> On 11 Jan 2018, at 23:02, Paul B Mahol wrote: >> >>> On 1/11/18, Dmitry Gumenyuk wrote: >>> > On 11 Jan 2018, at 22:41, Paul B Mahol wrote: > > On 1/11/18, Dmitry Gumenyuk wrote: > Hello > > 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : >>> On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com >>> wrote: >>> >>> +@table @option >>> +@item d >>> +Dimensions @code{WxH}. >>> +@code{W} - number of data values in json, values will be scaled >>> according to @code{H}. >>> +The default value is @var{640x480} >>> + >>> +@item s >>> +Samples count per value per channel >> >> In most other filters/filtersources, s+size is used for dimensions, >> d+duration for time, and n for an amount/number of frames/samples or >> so. Might be a good idea to align with this. And use aliases (i.e. >> implement both "s" and "size"). >> >>> +static const AVOption dumpwave_options[] = { >>> +{ "d", "set width and height", OFFSET(w), >>> AV_OPT_TYPE_IMAGE_SIZE, >>> {.str = "640x480"}, 0, 0, FLAGS }, >>> +{ "s", "set number of samples per value per channel", >>> OFFSET(s), >>> AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >>> +{ "json", "set json dump file", OFFSET(json), >>> AV_OPT_TYPE_STRING, >>> { >>> .str = NULL }, 0, 0, FLAGS }, >>> +{ NULL } >> [...] >>> +static av_cold int init(AVFilterContext *ctx) >>> +{ >>> +DumpWaveContext *dumpwave = ctx->priv; >>> +if(!dumpwave->s) { >>> +dumpwave->is_disabled = 1; >>> +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value >>> config\n"); >>> +} >>> +return 0; >> >> I don't like the idea of having to provide the "s" parameter. Is >> there >> really no useful default? >> >> And now, if s=0, what does the filter do? Just sit around? Couldn't >> it >> fail instead? >> >> Apart from that: >> "if (" is the bracket style ffmpeg uses. >> >>> +if (dumpwave->json && !(dump_fp = >>> av_fopen_utf8(dumpwave->json, >>> "w"))) >>> +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); >> >> I would appreciate evaluation of errno and printing the appropriate >> string (using av_strerror(), I believe). >> >>> +switch (inlink->format) { >>> +case AV_SAMPLE_FMT_DBLP: >> >> As Kyle hinted: Can this not force a conversion (implicit insertion >> of >> aformat filter) to e.g. double by only supporting this format, and >> reducing this switch to one or two cases? (The filter's output isn't >> really meant for transparent reuse anyway? af_volumedetect e.g. also >> supports only one, meaning its output can be a different format than >> its input.) It's also really hard to go through and later to >> maintain. >> It the big switch/case remains, one or two code macros would be >> appropriate. > > I checked solution used in volumedetect and couldn't find a way to > read across formats. I do not understand what you are trying to do. >>> Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample >>> formats > How would you implement such macros? Since version 3.2 astats filter > uses same approach for reading different formats and as far as I know > macros harder to debug astats is using all formats because of numerous reasons. astats uses raw values, your filter just convert each raw value to float representation. >>> Is this wrong, as I'd like to have high precision? >> >> For rendering to small size image? > Data can be used for analysis as well. Any size I would say as user may > define size Than use floats. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
> On 11 Jan 2018, at 23:02, Paul B Maholwrote: > >> On 1/11/18, Dmitry Gumenyuk wrote: >> On 11 Jan 2018, at 22:41, Paul B Mahol wrote: On 1/11/18, Dmitry Gumenyuk wrote: Hello 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : >> On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com >> wrote: >> >> +@table @option >> +@item d >> +Dimensions @code{WxH}. >> +@code{W} - number of data values in json, values will be scaled >> according to @code{H}. >> +The default value is @var{640x480} >> + >> +@item s >> +Samples count per value per channel > > In most other filters/filtersources, s+size is used for dimensions, > d+duration for time, and n for an amount/number of frames/samples or > so. Might be a good idea to align with this. And use aliases (i.e. > implement both "s" and "size"). > >> +static const AVOption dumpwave_options[] = { >> +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, >> {.str = "640x480"}, 0, 0, FLAGS }, >> +{ "s", "set number of samples per value per channel", OFFSET(s), >> AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >> +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, >> { >> .str = NULL }, 0, 0, FLAGS }, >> +{ NULL } > [...] >> +static av_cold int init(AVFilterContext *ctx) >> +{ >> +DumpWaveContext *dumpwave = ctx->priv; >> +if(!dumpwave->s) { >> +dumpwave->is_disabled = 1; >> +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value >> config\n"); >> +} >> +return 0; > > I don't like the idea of having to provide the "s" parameter. Is there > really no useful default? > > And now, if s=0, what does the filter do? Just sit around? Couldn't it > fail instead? > > Apart from that: > "if (" is the bracket style ffmpeg uses. > >> +if (dumpwave->json && !(dump_fp = >> av_fopen_utf8(dumpwave->json, >> "w"))) >> +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); > > I would appreciate evaluation of errno and printing the appropriate > string (using av_strerror(), I believe). > >> +switch (inlink->format) { >> +case AV_SAMPLE_FMT_DBLP: > > As Kyle hinted: Can this not force a conversion (implicit insertion of > aformat filter) to e.g. double by only supporting this format, and > reducing this switch to one or two cases? (The filter's output isn't > really meant for transparent reuse anyway? af_volumedetect e.g. also > supports only one, meaning its output can be a different format than > its input.) It's also really hard to go through and later to maintain. > It the big switch/case remains, one or two code macros would be > appropriate. I checked solution used in volumedetect and couldn't find a way to read across formats. >>> >>> I do not understand what you are trying to do. >> Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample formats How would you implement such macros? Since version 3.2 astats filter uses same approach for reading different formats and as far as I know macros harder to debug >>> >>> astats is using all formats because of numerous reasons. astats uses raw >>> values, >>> your filter just convert each raw value to float representation. >> Is this wrong, as I'd like to have high precision? > > For rendering to small size image? Data can be used for analysis as well. Any size I would say as user may define size > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel smime.p7s Description: S/MIME cryptographic signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
> On 11 Jan 2018, at 22:41, Paul B Maholwrote: > >> On 1/11/18, Dmitry Gumenyuk wrote: >> Hello >> >> 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com wrote: +@table @option +@item d +Dimensions @code{WxH}. +@code{W} - number of data values in json, values will be scaled according to @code{H}. +The default value is @var{640x480} + +@item s +Samples count per value per channel >>> >>> In most other filters/filtersources, s+size is used for dimensions, >>> d+duration for time, and n for an amount/number of frames/samples or >>> so. Might be a good idea to align with this. And use aliases (i.e. >>> implement both "s" and "size"). >>> +static const AVOption dumpwave_options[] = { +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS }, +{ "s", "set number of samples per value per channel", OFFSET(s), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS }, +{ NULL } >>> [...] +static av_cold int init(AVFilterContext *ctx) +{ +DumpWaveContext *dumpwave = ctx->priv; +if(!dumpwave->s) { +dumpwave->is_disabled = 1; +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value config\n"); +} +return 0; >>> >>> I don't like the idea of having to provide the "s" parameter. Is there >>> really no useful default? >>> >>> And now, if s=0, what does the filter do? Just sit around? Couldn't it >>> fail instead? >>> >>> Apart from that: >>> "if (" is the bracket style ffmpeg uses. >>> +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, "w"))) +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); >>> >>> I would appreciate evaluation of errno and printing the appropriate >>> string (using av_strerror(), I believe). >>> +switch (inlink->format) { +case AV_SAMPLE_FMT_DBLP: >>> >>> As Kyle hinted: Can this not force a conversion (implicit insertion of >>> aformat filter) to e.g. double by only supporting this format, and >>> reducing this switch to one or two cases? (The filter's output isn't >>> really meant for transparent reuse anyway? af_volumedetect e.g. also >>> supports only one, meaning its output can be a different format than >>> its input.) It's also really hard to go through and later to maintain. >>> It the big switch/case remains, one or two code macros would be >>> appropriate. >> >> I checked solution used in volumedetect and couldn't find a way to >> read across formats. > > I do not understand what you are trying to do. Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample formats >> How would you implement such macros? Since version 3.2 astats filter >> uses same approach for reading different formats and as far as I know >> macros harder to debug > > astats is using all formats because of numerous reasons. astats uses raw > values, > your filter just convert each raw value to float representation. Is this wrong, as I'd like to have high precision? > This filter does not need support for so many formats, it could > support just s16. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel smime.p7s Description: S/MIME cryptographic signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 1/11/18, Dmitry Gumenyukwrote: > >> On 11 Jan 2018, at 22:41, Paul B Mahol wrote: >> >>> On 1/11/18, Dmitry Gumenyuk wrote: >>> Hello >>> >>> 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : > On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com > wrote: > > +@table @option > +@item d > +Dimensions @code{WxH}. > +@code{W} - number of data values in json, values will be scaled > according to @code{H}. > +The default value is @var{640x480} > + > +@item s > +Samples count per value per channel In most other filters/filtersources, s+size is used for dimensions, d+duration for time, and n for an amount/number of frames/samples or so. Might be a good idea to align with this. And use aliases (i.e. implement both "s" and "size"). > +static const AVOption dumpwave_options[] = { > +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, > {.str = "640x480"}, 0, 0, FLAGS }, > +{ "s", "set number of samples per value per channel", OFFSET(s), > AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, > { > .str = NULL }, 0, 0, FLAGS }, > +{ NULL } [...] > +static av_cold int init(AVFilterContext *ctx) > +{ > +DumpWaveContext *dumpwave = ctx->priv; > +if(!dumpwave->s) { > +dumpwave->is_disabled = 1; > +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value > config\n"); > +} > +return 0; I don't like the idea of having to provide the "s" parameter. Is there really no useful default? And now, if s=0, what does the filter do? Just sit around? Couldn't it fail instead? Apart from that: "if (" is the bracket style ffmpeg uses. > +if (dumpwave->json && !(dump_fp = > av_fopen_utf8(dumpwave->json, > "w"))) > +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); I would appreciate evaluation of errno and printing the appropriate string (using av_strerror(), I believe). > +switch (inlink->format) { > +case AV_SAMPLE_FMT_DBLP: As Kyle hinted: Can this not force a conversion (implicit insertion of aformat filter) to e.g. double by only supporting this format, and reducing this switch to one or two cases? (The filter's output isn't really meant for transparent reuse anyway? af_volumedetect e.g. also supports only one, meaning its output can be a different format than its input.) It's also really hard to go through and later to maintain. It the big switch/case remains, one or two code macros would be appropriate. >>> >>> I checked solution used in volumedetect and couldn't find a way to >>> read across formats. >> >> I do not understand what you are trying to do. > Sorry, I'm trying to add support for 8, 16, 24, 32, 64 bit sample formats >>> How would you implement such macros? Since version 3.2 astats filter >>> uses same approach for reading different formats and as far as I know >>> macros harder to debug >> >> astats is using all formats because of numerous reasons. astats uses raw >> values, >> your filter just convert each raw value to float representation. > Is this wrong, as I'd like to have high precision? For rendering to small size image? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 1/11/18, Dmitry Gumenyukwrote: > Hello > > 2018-01-10 11:33 GMT+01:00 Moritz Barsnick : >> On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com wrote: >> >>> +@table @option >>> +@item d >>> +Dimensions @code{WxH}. >>> +@code{W} - number of data values in json, values will be scaled >>> according to @code{H}. >>> +The default value is @var{640x480} >>> + >>> +@item s >>> +Samples count per value per channel >> >> In most other filters/filtersources, s+size is used for dimensions, >> d+duration for time, and n for an amount/number of frames/samples or >> so. Might be a good idea to align with this. And use aliases (i.e. >> implement both "s" and "size"). >> >>> +static const AVOption dumpwave_options[] = { >>> +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, >>> {.str = "640x480"}, 0, 0, FLAGS }, >>> +{ "s", "set number of samples per value per channel", OFFSET(s), >>> AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >>> +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, { >>> .str = NULL }, 0, 0, FLAGS }, >>> +{ NULL } >> [...] >>> +static av_cold int init(AVFilterContext *ctx) >>> +{ >>> +DumpWaveContext *dumpwave = ctx->priv; >>> +if(!dumpwave->s) { >>> +dumpwave->is_disabled = 1; >>> +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value config\n"); >>> +} >>> +return 0; >> >> I don't like the idea of having to provide the "s" parameter. Is there >> really no useful default? >> >> And now, if s=0, what does the filter do? Just sit around? Couldn't it >> fail instead? >> >> Apart from that: >> "if (" is the bracket style ffmpeg uses. >> >>> +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, >>> "w"))) >>> +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); >> >> I would appreciate evaluation of errno and printing the appropriate >> string (using av_strerror(), I believe). >> >>> +switch (inlink->format) { >>> +case AV_SAMPLE_FMT_DBLP: >> >> As Kyle hinted: Can this not force a conversion (implicit insertion of >> aformat filter) to e.g. double by only supporting this format, and >> reducing this switch to one or two cases? (The filter's output isn't >> really meant for transparent reuse anyway? af_volumedetect e.g. also >> supports only one, meaning its output can be a different format than >> its input.) It's also really hard to go through and later to maintain. >> It the big switch/case remains, one or two code macros would be >> appropriate. > > I checked solution used in volumedetect and couldn't find a way to > read across formats. I do not understand what you are trying to do. > How would you implement such macros? Since version 3.2 astats filter > uses same approach for reading different formats and as far as I know > macros harder to debug astats is using all formats because of numerous reasons. astats uses raw values, your filter just convert each raw value to float representation. This filter does not need support for so many formats, it could support just s16. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
Hello 2018-01-10 11:33 GMT+01:00 Moritz Barsnick: > On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com wrote: > >> +@table @option >> +@item d >> +Dimensions @code{WxH}. >> +@code{W} - number of data values in json, values will be scaled according >> to @code{H}. >> +The default value is @var{640x480} >> + >> +@item s >> +Samples count per value per channel > > In most other filters/filtersources, s+size is used for dimensions, > d+duration for time, and n for an amount/number of frames/samples or > so. Might be a good idea to align with this. And use aliases (i.e. > implement both "s" and "size"). > >> +static const AVOption dumpwave_options[] = { >> +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str >> = "640x480"}, 0, 0, FLAGS }, >> +{ "s", "set number of samples per value per channel", OFFSET(s), >> AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, >> +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, { >> .str = NULL }, 0, 0, FLAGS }, >> +{ NULL } > [...] >> +static av_cold int init(AVFilterContext *ctx) >> +{ >> +DumpWaveContext *dumpwave = ctx->priv; >> +if(!dumpwave->s) { >> +dumpwave->is_disabled = 1; >> +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value config\n"); >> +} >> +return 0; > > I don't like the idea of having to provide the "s" parameter. Is there > really no useful default? > > And now, if s=0, what does the filter do? Just sit around? Couldn't it > fail instead? > > Apart from that: > "if (" is the bracket style ffmpeg uses. > >> +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, >> "w"))) >> +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); > > I would appreciate evaluation of errno and printing the appropriate > string (using av_strerror(), I believe). > >> +switch (inlink->format) { >> +case AV_SAMPLE_FMT_DBLP: > > As Kyle hinted: Can this not force a conversion (implicit insertion of > aformat filter) to e.g. double by only supporting this format, and > reducing this switch to one or two cases? (The filter's output isn't > really meant for transparent reuse anyway? af_volumedetect e.g. also > supports only one, meaning its output can be a different format than > its input.) It's also really hard to go through and later to maintain. > It the big switch/case remains, one or two code macros would be > appropriate. I checked solution used in volumedetect and couldn't find a way to read across formats. How would you implement such macros? Since version 3.2 astats filter uses same approach for reading different formats and as far as I know macros harder to debug >> +for (i = 0; i < buf->nb_samples; i++) { >> +for (c = 0; c < channels; c++, src++) >> +calc_db_rms(dumpwave, *src); >> +}} > > I believe the curly brackets need to be placed differently. > >> +.description = NULL_IF_CONFIG_SMALL("Dumps RMS amplitude to JSON >> file"), > > Imperative, i.e. "Dump RMS ...". > >> +FATE_AFILTER-$(call FILTERDEMDEC, DUMPWAVE, WAV, PCM_S16LE) += >> fate-filter-dumpwave >> +fate-filter-dumpwave: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav >> +fate-filter-dumpwave: CMD = ffmpeg -i $(SRC) -af >> dumpwave=d=1800x140:s=147:json=$(TARGET_PATH)/tests/data/fate/filter-dumpwave.out >> -f null - && cat $(TARGET_PATH)/tests/data/fate/filter-dumpwave.out >> + > > If you need to implement all formats, you might want to test them all. > Just a thought. > > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On Wed, Jan 10, 2018 at 08:58:05 +0100, dmitry.gumen...@gmail.com wrote: > +@table @option > +@item d > +Dimensions @code{WxH}. > +@code{W} - number of data values in json, values will be scaled according to > @code{H}. > +The default value is @var{640x480} > + > +@item s > +Samples count per value per channel In most other filters/filtersources, s+size is used for dimensions, d+duration for time, and n for an amount/number of frames/samples or so. Might be a good idea to align with this. And use aliases (i.e. implement both "s" and "size"). > +static const AVOption dumpwave_options[] = { > +{ "d", "set width and height", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str > = "640x480"}, 0, 0, FLAGS }, > +{ "s", "set number of samples per value per channel", OFFSET(s), > AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, FLAGS }, > +{ "json", "set json dump file", OFFSET(json), AV_OPT_TYPE_STRING, { .str > = NULL }, 0, 0, FLAGS }, > +{ NULL } [...] > +static av_cold int init(AVFilterContext *ctx) > +{ > +DumpWaveContext *dumpwave = ctx->priv; > +if(!dumpwave->s) { > +dumpwave->is_disabled = 1; > +av_log(ctx, AV_LOG_ERROR, "Invalid samples per value config\n"); > +} > +return 0; I don't like the idea of having to provide the "s" parameter. Is there really no useful default? And now, if s=0, what does the filter do? Just sit around? Couldn't it fail instead? Apart from that: "if (" is the bracket style ffmpeg uses. > +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, > "w"))) > +av_log(ctx, AV_LOG_WARNING, "Flushing dump failed\n"); I would appreciate evaluation of errno and printing the appropriate string (using av_strerror(), I believe). > +switch (inlink->format) { > +case AV_SAMPLE_FMT_DBLP: As Kyle hinted: Can this not force a conversion (implicit insertion of aformat filter) to e.g. double by only supporting this format, and reducing this switch to one or two cases? (The filter's output isn't really meant for transparent reuse anyway? af_volumedetect e.g. also supports only one, meaning its output can be a different format than its input.) It's also really hard to go through and later to maintain. It the big switch/case remains, one or two code macros would be appropriate. > +for (i = 0; i < buf->nb_samples; i++) { > +for (c = 0; c < channels; c++, src++) > +calc_db_rms(dumpwave, *src); > +}} I believe the curly brackets need to be placed differently. > +.description = NULL_IF_CONFIG_SMALL("Dumps RMS amplitude to JSON > file"), Imperative, i.e. "Dump RMS ...". > +FATE_AFILTER-$(call FILTERDEMDEC, DUMPWAVE, WAV, PCM_S16LE) += > fate-filter-dumpwave > +fate-filter-dumpwave: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav > +fate-filter-dumpwave: CMD = ffmpeg -i $(SRC) -af > dumpwave=d=1800x140:s=147:json=$(TARGET_PATH)/tests/data/fate/filter-dumpwave.out > -f null - && cat $(TARGET_PATH)/tests/data/fate/filter-dumpwave.out > + If you need to implement all formats, you might want to test them all. Just a thought. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 10.01.2018 09:34, Дмитрий Гуменюк wrote: There is no existing dumping format for RMS. How to make it generic? Some of my applications use the following pattern to dump audio envelope data during transcoding: ffmpeg -i input-file -f [...] output-file \ -f wav -write_peak only peak-file The data format of "peak-file" follows EBU Tech 3285 Supplement 3 (BWF Peak Envelope Chunk). Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 10.01.2018 09:11, Дмитрий Гуменюк wrote: Hi, In my opinion JSON is more flexible, so envelope can be rendered in web app or mobile app This filter is useful when you’d like to generate visual representation of audio while doing transcode I see, but my point is: If you do the image rendering external anyway, why not use an existing envelope dumping format? Or alternatively connect the rendering application via the av* library interface in C? Filters into the codebase should be as generic as possible to allow re-usage by other filters. On 10 Jan 2018, at 09:00, Tobias Rappwrote: On 08.01.2018 01:36, dmitry.gumen...@gmail.com wrote: From: Dmytro Humeniuk Signed-off-by: Dmytro Humeniuk --- Changelog | 1 + libavfilter/Makefile | 1 + libavfilter/af_dumpwave.c | 273 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- tests/fate/filter-audio.mak| 5 + tests/ref/fate/filter-dumpwave | 1 + 7 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 libavfilter/af_dumpwave.c create mode 100644 tests/ref/fate/filter-dumpwave [...] As far as I can see the filter reads audio and writes an envelope curve using JSON data format. The JSON data is then rendered into an image outside of FFmpeg. In my opinion it would be better to allow connecting the filter with other filters by directly rendering the image within FFmpeg. So the filter should have a generic video output instead of the JSON output. This would be similar to the existing "showvolume" filter. If you just want to get the raw envelope data from FFmpeg I suggest to take a look at the "write_peak" option of the WAV muxer. Regards, Tobias BTW: Top-posting is unpopular on this list. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
On 08.01.2018 01:36, dmitry.gumen...@gmail.com wrote: From: Dmytro HumeniukSigned-off-by: Dmytro Humeniuk --- Changelog | 1 + libavfilter/Makefile | 1 + libavfilter/af_dumpwave.c | 273 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- tests/fate/filter-audio.mak| 5 + tests/ref/fate/filter-dumpwave | 1 + 7 files changed, 284 insertions(+), 2 deletions(-) create mode 100644 libavfilter/af_dumpwave.c create mode 100644 tests/ref/fate/filter-dumpwave [...] As far as I can see the filter reads audio and writes an envelope curve using JSON data format. The JSON data is then rendered into an image outside of FFmpeg. In my opinion it would be better to allow connecting the filter with other filters by directly rendering the image within FFmpeg. So the filter should have a generic video output instead of the JSON output. This would be similar to the existing "showvolume" filter. If you just want to get the raw envelope data from FFmpeg I suggest to take a look at the "write_peak" option of the WAV muxer. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
Hi, >Can you provide some context for this? Please add docs as well. filter converts samples to decibels and calculates RMS (Root-Mean-Square) audio power scaled to desired values, it supposed to generate something like SoundCloud does http://plnkr.co/edit/WeppGcEPQiOyKDsA0C4Y I added docs. >Can't really test this because it segfaults for me: ./ffmpeg -f lavfi >-i anoisesrc -af dumpwave -f null - it expected some config - fixed >Just set the sample format to something like AV_SAMPLE_FMT_DBL in >query_format. There's no need for this big switch statement. it handles samples in different way, you may look at the astats filter 2018-01-08 23:58 GMT+01:00 Kyle Swanson: > Hi, > > Can you provide some context for this? Please add docs as well. > Can't really test this because it segfaults for me: ./ffmpeg -f lavfi > -i anoisesrc -af dumpwave -f null - > > On Sun, Jan 7, 2018 at 4:36 PM, wrote: >> >> From: Dmytro Humeniuk >> >> Signed-off-by: Dmytro Humeniuk >> --- >> Changelog | 1 + >> libavfilter/Makefile | 1 + >> libavfilter/af_dumpwave.c | 273 >> + >> libavfilter/allfilters.c | 1 + >> libavfilter/version.h | 4 +- >> tests/fate/filter-audio.mak| 5 + >> tests/ref/fate/filter-dumpwave | 1 + >> 7 files changed, 284 insertions(+), 2 deletions(-) >> create mode 100644 libavfilter/af_dumpwave.c >> create mode 100644 tests/ref/fate/filter-dumpwave >> >> diff --git a/Changelog b/Changelog >> index 61075b3392..40fd624449 100644 >> --- a/Changelog >> +++ b/Changelog >> @@ -38,6 +38,7 @@ version : >> - Removed the ffserver program >> - Removed the ffmenc and ffmdec muxer and demuxer >> - VideoToolbox HEVC encoder and hwaccel >> +- dumpwave audio filter >> >> >> version 3.4: >> diff --git a/libavfilter/Makefile b/libavfilter/Makefile >> index 256dfabd66..020d90ee01 100644 >> --- a/libavfilter/Makefile >> +++ b/libavfilter/Makefile >> @@ -122,6 +122,7 @@ OBJS-$(CONFIG_TREMOLO_FILTER)+= >> af_tremolo.o >> OBJS-$(CONFIG_VIBRATO_FILTER)+= af_vibrato.o >> generate_wave_table.o >> OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o >> OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o >> +OBJS-$(CONFIG_DUMPWAVE_FILTER) += af_dumpwave.o >> >> OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o >> OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o >> diff --git a/libavfilter/af_dumpwave.c b/libavfilter/af_dumpwave.c >> new file mode 100644 >> index 00..493b5b7ff2 >> --- /dev/null >> +++ b/libavfilter/af_dumpwave.c >> @@ -0,0 +1,273 @@ >> +/* >> + * Copyright (c) 2017 Dmytro Humeniuk >> + * >> + * This file is part of FFmpeg. >> + * >> + * FFmpeg is free software; you can redistribute it and/or >> + * modify it under the terms of the GNU Lesser General Public >> + * License as published by the Free Software Foundation; either >> + * version 2.1 of the License, or (at your option) any later version. >> + * >> + * FFmpeg is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + * Lesser General Public License for more details. >> + * >> + * You should have received a copy of the GNU Lesser General Public >> + * License along with FFmpeg; if not, write to the Free Software >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 >> USA >> + */ >> + >> +/** >> + * @file >> + * waveform audio filter – dumps RMS amplitude to JSON file like SoundCloud >> does >> + */ >> + >> +#include "libavutil/avassert.h" >> +#include "libavutil/avstring.h" >> +#include "libavutil/channel_layout.h" >> +#include "libavutil/opt.h" >> +#include "libavutil/parseutils.h" >> +#include "avfilter.h" >> +#include "formats.h" >> +#include "audio.h" >> +#include "internal.h" >> + >> +typedef struct DumpWaveContext { >> +const AVClass *class; >> +int w, h; >> +AVRational rate; >> +int col; >> +char *json; >> +char *str; >> +double *values; >> +int64_t c, n, max_samples; >> +double sum; /* sum of the squared samples per segment */ >> +} DumpWaveContext; >> + >> +#define OFFSET(x) offsetof(DumpWaveContext, x) >> +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM >> + >> +static const AVOption dumpwave_options[] = { >> +{ "s","set dump size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = >> "600x240"}, 0, 0, FLAGS }, >> +{ "c", "set number of samples per item", OFFSET(c), AV_OPT_TYPE_INT64, >> {.i64 = 0}, 0, INT64_MAX, FLAGS }, > > Use more descriptive parameter names. Also, per item? What is an item? > >> +{ "json", "set dump file", OFFSET(json), AV_OPT_TYPE_STRING, { .str = >> NULL }, 0, 0, FLAGS }, >> +{ NULL
Re: [FFmpeg-devel] [PATCH] avfilter: add dumpwave filter.
Hi, Can you provide some context for this? Please add docs as well. Can't really test this because it segfaults for me: ./ffmpeg -f lavfi -i anoisesrc -af dumpwave -f null - On Sun, Jan 7, 2018 at 4:36 PM,wrote: > > From: Dmytro Humeniuk > > Signed-off-by: Dmytro Humeniuk > --- > Changelog | 1 + > libavfilter/Makefile | 1 + > libavfilter/af_dumpwave.c | 273 > + > libavfilter/allfilters.c | 1 + > libavfilter/version.h | 4 +- > tests/fate/filter-audio.mak| 5 + > tests/ref/fate/filter-dumpwave | 1 + > 7 files changed, 284 insertions(+), 2 deletions(-) > create mode 100644 libavfilter/af_dumpwave.c > create mode 100644 tests/ref/fate/filter-dumpwave > > diff --git a/Changelog b/Changelog > index 61075b3392..40fd624449 100644 > --- a/Changelog > +++ b/Changelog > @@ -38,6 +38,7 @@ version : > - Removed the ffserver program > - Removed the ffmenc and ffmdec muxer and demuxer > - VideoToolbox HEVC encoder and hwaccel > +- dumpwave audio filter > > > version 3.4: > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 256dfabd66..020d90ee01 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -122,6 +122,7 @@ OBJS-$(CONFIG_TREMOLO_FILTER)+= > af_tremolo.o > OBJS-$(CONFIG_VIBRATO_FILTER)+= af_vibrato.o > generate_wave_table.o > OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o > OBJS-$(CONFIG_VOLUMEDETECT_FILTER) += af_volumedetect.o > +OBJS-$(CONFIG_DUMPWAVE_FILTER) += af_dumpwave.o > > OBJS-$(CONFIG_AEVALSRC_FILTER) += aeval.o > OBJS-$(CONFIG_ANOISESRC_FILTER) += asrc_anoisesrc.o > diff --git a/libavfilter/af_dumpwave.c b/libavfilter/af_dumpwave.c > new file mode 100644 > index 00..493b5b7ff2 > --- /dev/null > +++ b/libavfilter/af_dumpwave.c > @@ -0,0 +1,273 @@ > +/* > + * Copyright (c) 2017 Dmytro Humeniuk > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +/** > + * @file > + * waveform audio filter – dumps RMS amplitude to JSON file like SoundCloud > does > + */ > + > +#include "libavutil/avassert.h" > +#include "libavutil/avstring.h" > +#include "libavutil/channel_layout.h" > +#include "libavutil/opt.h" > +#include "libavutil/parseutils.h" > +#include "avfilter.h" > +#include "formats.h" > +#include "audio.h" > +#include "internal.h" > + > +typedef struct DumpWaveContext { > +const AVClass *class; > +int w, h; > +AVRational rate; > +int col; > +char *json; > +char *str; > +double *values; > +int64_t c, n, max_samples; > +double sum; /* sum of the squared samples per segment */ > +} DumpWaveContext; > + > +#define OFFSET(x) offsetof(DumpWaveContext, x) > +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > + > +static const AVOption dumpwave_options[] = { > +{ "s","set dump size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = > "600x240"}, 0, 0, FLAGS }, > +{ "c", "set number of samples per item", OFFSET(c), AV_OPT_TYPE_INT64, > {.i64 = 0}, 0, INT64_MAX, FLAGS }, Use more descriptive parameter names. Also, per item? What is an item? > +{ "json", "set dump file", OFFSET(json), AV_OPT_TYPE_STRING, { .str = > NULL }, 0, 0, FLAGS }, > +{ NULL } > +}; > + > +AVFILTER_DEFINE_CLASS(dumpwave); > + > +static int config_output(AVFilterLink *outlink) > +{ > +DumpWaveContext *dumpwave = outlink->src->priv; > +const int ch_width = dumpwave->w; > +dumpwave->values = av_malloc(ch_width * sizeof(double)); > +dumpwave->str = av_malloc(ch_width*sizeof(int)); > +dumpwave->max_samples = dumpwave->c * outlink->channels; > + > +return 0; > +} > + > +static av_cold void uninit(AVFilterContext *ctx) > +{ > +DumpWaveContext *dumpwave = ctx->priv; > +const int ch_height = dumpwave->h; > +const int ch_width = dumpwave->w; > +char *result = dumpwave->str; > +FILE *dump_fp = NULL; > + > +if (dumpwave->json && !(dump_fp = av_fopen_utf8(dumpwave->json, "w"))) > +av_log(ctx, AV_LOG_WARNING, "dump failed.\n"); > +