Re: [FFmpeg-devel] [PATCH] avformat/utils: Stream specifier enhancement 2.
On Fri, Apr 13, 2018 at 10:03:18PM +0200, Bodecs Bela wrote: > > > 2018.04.13. 20:54 keltezéssel, Michael Niedermayer írta: > >On Fri, Apr 13, 2018 at 12:16:52PM +0200, Bodecs Bela wrote: > >>Dear All, > >> > >>In some cases, mainly working with multiprogram mpeg-ts containers as > >>input, it would be handy to select sub stream of a specific program by > >>their metadata. > >>This patch makes it possible to narrow the stream selection among > >>streams of the specified program by stream metadata. > >> > >>Examples: > >>p:601:m:language:hun will select all sub streams of program with id 601 > >>where sub streams have metadata key named 'language' with value 'hun'. > >>p:602:m:guide will select all sub streams of program with id 602 where > >>sub streams have metadata key named 'guide'. > >> > >>This syntax enhancement does not interfere in any way with > >>current/existing syntax or working command lines. > >> > >>please review this patch. > >> > >>thank you in advance, > >> > >>best, > >> > >>Bela > >> > >> doc/fftools-common-opts.texi | 10 -- > >> libavformat/utils.c | 28 > >> 2 files changed, 36 insertions(+), 2 deletions(-) > >>03f0760a24e25b89f4515e3fd860f3af1061ae23 > >>0001-avformat-utils-Stream-specifier-enhancement-2.patch > >> From fbec3c0c9b8189b1517f33394548c58c112a48ed Mon Sep 17 00:00:00 2001 > >>From: Bela Bodecs> >>Date: Fri, 13 Apr 2018 12:11:32 +0200 > >>Subject: [PATCH] avformat/utils: Stream specifier enhancement 2. > >will apply > > > >can you also add a fate test ? > > > >thanks > > > >[...] > I have searched but there is no mpeg-ts with metadata among test files. > which is the preferred solution: > a.) send a files into the fate-suite or b.) create on-the-fly for test? if it can be created on the fly that is better as it would then also test the codepathes for creating such files thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/utils: Stream specifier enhancement 2.
2018.04.13. 20:54 keltezéssel, Michael Niedermayer írta: On Fri, Apr 13, 2018 at 12:16:52PM +0200, Bodecs Bela wrote: Dear All, In some cases, mainly working with multiprogram mpeg-ts containers as input, it would be handy to select sub stream of a specific program by their metadata. This patch makes it possible to narrow the stream selection among streams of the specified program by stream metadata. Examples: p:601:m:language:hun will select all sub streams of program with id 601 where sub streams have metadata key named 'language' with value 'hun'. p:602:m:guide will select all sub streams of program with id 602 where sub streams have metadata key named 'guide'. This syntax enhancement does not interfere in any way with current/existing syntax or working command lines. please review this patch. thank you in advance, best, Bela doc/fftools-common-opts.texi | 10 -- libavformat/utils.c | 28 2 files changed, 36 insertions(+), 2 deletions(-) 03f0760a24e25b89f4515e3fd860f3af1061ae23 0001-avformat-utils-Stream-specifier-enhancement-2.patch From fbec3c0c9b8189b1517f33394548c58c112a48ed Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Fri, 13 Apr 2018 12:11:32 +0200 Subject: [PATCH] avformat/utils: Stream specifier enhancement 2. will apply can you also add a fate test ? thanks [...] I have searched but there is no mpeg-ts with metadata among test files. which is the preferred solution: a.) send a files into the fate-suite or b.) create on-the-fly for test? bb ___ 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] avformat/utils: Stream specifier enhancement 2.
On Fri, Apr 13, 2018 at 12:16:52PM +0200, Bodecs Bela wrote: > Dear All, > > In some cases, mainly working with multiprogram mpeg-ts containers as > input, it would be handy to select sub stream of a specific program by > their metadata. > This patch makes it possible to narrow the stream selection among > streams of the specified program by stream metadata. > > Examples: > p:601:m:language:hun will select all sub streams of program with id 601 > where sub streams have metadata key named 'language' with value 'hun'. > p:602:m:guide will select all sub streams of program with id 602 where > sub streams have metadata key named 'guide'. > > This syntax enhancement does not interfere in any way with > current/existing syntax or working command lines. > > please review this patch. > > thank you in advance, > > best, > > Bela > > doc/fftools-common-opts.texi | 10 -- > libavformat/utils.c | 28 > 2 files changed, 36 insertions(+), 2 deletions(-) > 03f0760a24e25b89f4515e3fd860f3af1061ae23 > 0001-avformat-utils-Stream-specifier-enhancement-2.patch > From fbec3c0c9b8189b1517f33394548c58c112a48ed Mon Sep 17 00:00:00 2001 > From: Bela Bodecs> Date: Fri, 13 Apr 2018 12:11:32 +0200 > Subject: [PATCH] avformat/utils: Stream specifier enhancement 2. will apply can you also add a fate test ? thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/utils: Stream specifier enhancement 2.
Dear All, In some cases, mainly working with multiprogram mpeg-ts containers as input, it would be handy to select sub stream of a specific program by their metadata. This patch makes it possible to narrow the stream selection among streams of the specified program by stream metadata. Examples: p:601:m:language:hun will select all sub streams of program with id 601 where sub streams have metadata key named 'language' with value 'hun'. p:602:m:guide will select all sub streams of program with id 602 where sub streams have metadata key named 'guide'. This syntax enhancement does not interfere in any way with current/existing syntax or working command lines. please review this patch. thank you in advance, best, Bela >From fbec3c0c9b8189b1517f33394548c58c112a48ed Mon Sep 17 00:00:00 2001 From: Bela BodecsDate: Fri, 13 Apr 2018 12:11:32 +0200 Subject: [PATCH] avformat/utils: Stream specifier enhancement 2. In some cases, mainly working with multiprogram mpeg-ts containers as input, it would be handy to select sub stream of a specific program by their metadata. This patch makes it possible to narrow the stream selection among streams of the specified program by stream metadata. Examples: p:601:m:language:hun will select all sub streams of program with id 601 where sub streams have metadata key named 'language' with value 'hun'. p:602:m:guide will select all sub streams of program with id 602 where sub streams have metadata key named 'guide'. Signed-off-by: Bela Bodecs --- doc/fftools-common-opts.texi | 10 -- libavformat/utils.c | 28 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 79feb39..84705c0 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -42,14 +42,20 @@ streams, 'V' only matches video streams which are not attached pictures, video thumbnails or cover arts. If @var{stream_index} is given, then it matches stream number @var{stream_index} of this type. Otherwise, it matches all streams of this type. -@item p:@var{program_id}[:@var{stream_index}] or p:@var{program_id}[:@var{stream_type}[:@var{stream_index}]] +@item p:@var{program_id}[:@var{stream_index}] or p:@var{program_id}[:@var{stream_type}[:@var{stream_index}]] or +p:@var{program_id}:m:@var{key}[:@var{value}] In first version, if @var{stream_index} is given, then it matches the stream with number @var{stream_index} in the program with the id @var{program_id}. Otherwise, it matches all streams in the -program. In the latter version, @var{stream_type} is one of following: 'v' for video, 'a' for audio, 's' +program. In the second version, @var{stream_type} is one of following: 'v' for video, 'a' for audio, 's' for subtitle, 'd' for data. If @var{stream_index} is also given, then it matches stream number @var{stream_index} of this type in the program with the id @var{program_id}. Otherwise, if only @var{stream_type} is given, it matches all streams of this type in the program with the id @var{program_id}. +In the third version matches streams in the program with the id @var{program_id} with the metadata +tag @var{key} having the specified value. If +@var{value} is not given, matches streams that contain the given tag with any +value. + @item #@var{stream_id} or i:@var{stream_id} Match the stream by stream id (e.g. PID in MPEG-TS container). @item m:@var{key}[:@var{value}] diff --git a/libavformat/utils.c b/libavformat/utils.c index cc35998..84b926d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5124,6 +5124,34 @@ FF_ENABLE_DEPRECATION_WARNINGS } return 0; } + +} else if ( *endptr == 'm') { // p::m: +AVDictionaryEntry *tag; +char *key, *val; +int ret = 0; + +if (*(++endptr) != ':') { +av_log(s, AV_LOG_ERROR, "Invalid stream specifier syntax, missing ':' sign after :m.\n"); +return AVERROR(EINVAL); +} + +val = strchr(++endptr, ':'); +key = val ? av_strndup(endptr, val - endptr) : av_strdup(endptr); +if (!key) +return AVERROR(ENOMEM); + +for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) +if (st->index == s->programs[i]->stream_index[j]) { +tag = av_dict_get(st->metadata, key, NULL, 0); +if (tag && (!val || !strcmp(tag->value, val + 1))) +ret = 1; + +break; +} + +av_freep(); +return ret; + } else { // p:: int stream_idx =