Re: [FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
On Thu, Dec 13, 2018 at 01:20:22AM +0530, Gyan wrote: > > On 13-12-2018 12:50 AM, Michael Niedermayer wrote: > >On Wed, Dec 12, 2018 at 10:25:46AM +0530, Gyan wrote: > >>On 12-12-2018 03:40 AM, Michael Niedermayer wrote: > >>>On Mon, Dec 10, 2018 at 08:57:44PM +0530, Gyan wrote: > At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input > files. Individual streams can still be let through e.g. > > ffmpeg -an -discard:a:1 none -i file ... > > will let (only) the 2nd audio stream be seen during stream selection and > filtergraph construction. > > Thanks, > Gyan > ffmpeg_filter.c |7 +++ > ffmpeg_opt.c| 17 + > 2 files changed, 24 insertions(+) > 212c7bcecbd62329f3f18893c71f464ebeee3b67 > 0001-ffmpeg-implement-input-file-stream-disabling.patch > From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 > From: Gyan Doshi > Date: Mon, 10 Dec 2018 20:38:20 +0530 > Subject: [PATCH] ffmpeg: implement input file stream disabling > > -vn/-an/-sn/-dn can be set to stop processing of streams > of said type from an input file. > >>>isnt this 2 seperate changes ? > >>>one is adding -vn/-an/-sn/-dn input support and the other is fixing some > >>>input > >>>discard issues related to existing -discard functionality > >> > >>Only one change. I provided an example command syntax to show how to > >>selectively enable streams while leaving others of the same type disabled. > >You misunderstand me i think > >patches should be split in self contained changes. > >part of this patch adds support for -vn/-an/-sn/-dn > >and other parts are fixing bugs > > > >the patch for example adds a error check for disabled filter inputs > >using this example: > >ffmpeg -discard all -i tests/data/asynth-44100-1.wav -i > >tests/data/asynth-44100-1.wav -filter_complex > >'[0:a][1:a]amerge=inputs=2[aout]' -map '[aout]' -f framecrc - > > > >This newly added code triggers and prints > >"Stream specifier ':a' in filtergraph description > >[0:a][1:a]amerge=inputs=2[aout] matches a disabled input stream." > > > >before the patch the code did not error out. > > Actually, I meant to catch and error out for scenarios like, > > ffmpeg -vn -i input -lavfi [0:v]filter output > > Since there's only one variable to set discard state, it happens to error > out your command as well. I didn't consider it a bug fix but as due > diligence for this new 'feature'. > > I can split this in two, if you like. > > Anything else? more spliting is better, yes you know your changes better than i do, any self contained bugfix could be split out. Or maybe all related bugfixes together if you dont want too many one line patches thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you drop bombs on a foreign country and kill a hundred thousand innocent people, expect your government to call the consequence "unprovoked inhuman terrorist attacks" and use it to justify dropping more bombs and killing more people. The technology changed, the idea is old. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
On 13-12-2018 12:50 AM, Michael Niedermayer wrote: On Wed, Dec 12, 2018 at 10:25:46AM +0530, Gyan wrote: On 12-12-2018 03:40 AM, Michael Niedermayer wrote: On Mon, Dec 10, 2018 at 08:57:44PM +0530, Gyan wrote: At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input files. Individual streams can still be let through e.g. ffmpeg -an -discard:a:1 none -i file ... will let (only) the 2nd audio stream be seen during stream selection and filtergraph construction. Thanks, Gyan ffmpeg_filter.c |7 +++ ffmpeg_opt.c| 17 + 2 files changed, 24 insertions(+) 212c7bcecbd62329f3f18893c71f464ebeee3b67 0001-ffmpeg-implement-input-file-stream-disabling.patch From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Mon, 10 Dec 2018 20:38:20 +0530 Subject: [PATCH] ffmpeg: implement input file stream disabling -vn/-an/-sn/-dn can be set to stop processing of streams of said type from an input file. isnt this 2 seperate changes ? one is adding -vn/-an/-sn/-dn input support and the other is fixing some input discard issues related to existing -discard functionality Only one change. I provided an example command syntax to show how to selectively enable streams while leaving others of the same type disabled. You misunderstand me i think patches should be split in self contained changes. part of this patch adds support for -vn/-an/-sn/-dn and other parts are fixing bugs the patch for example adds a error check for disabled filter inputs using this example: ffmpeg -discard all -i tests/data/asynth-44100-1.wav -i tests/data/asynth-44100-1.wav -filter_complex '[0:a][1:a]amerge=inputs=2[aout]' -map '[aout]' -f framecrc - This newly added code triggers and prints "Stream specifier ':a' in filtergraph description [0:a][1:a]amerge=inputs=2[aout] matches a disabled input stream." before the patch the code did not error out. Actually, I meant to catch and error out for scenarios like, ffmpeg -vn -i input -lavfi [0:v]filter output Since there's only one variable to set discard state, it happens to error out your command as well. I didn't consider it a bug fix but as due diligence for this new 'feature'. I can split this in two, if you like. Anything else? Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
On Wed, Dec 12, 2018 at 10:25:46AM +0530, Gyan wrote: > > On 12-12-2018 03:40 AM, Michael Niedermayer wrote: > >On Mon, Dec 10, 2018 at 08:57:44PM +0530, Gyan wrote: > >>At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input > >>files. Individual streams can still be let through e.g. > >> > >> ffmpeg -an -discard:a:1 none -i file ... > >> > >>will let (only) the 2nd audio stream be seen during stream selection and > >>filtergraph construction. > >> > >>Thanks, > >>Gyan > >> ffmpeg_filter.c |7 +++ > >> ffmpeg_opt.c| 17 + > >> 2 files changed, 24 insertions(+) > >>212c7bcecbd62329f3f18893c71f464ebeee3b67 > >>0001-ffmpeg-implement-input-file-stream-disabling.patch > >> From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 > >>From: Gyan Doshi > >>Date: Mon, 10 Dec 2018 20:38:20 +0530 > >>Subject: [PATCH] ffmpeg: implement input file stream disabling > >> > >>-vn/-an/-sn/-dn can be set to stop processing of streams > >>of said type from an input file. > >isnt this 2 seperate changes ? > >one is adding -vn/-an/-sn/-dn input support and the other is fixing some > >input > >discard issues related to existing -discard functionality > > > Only one change. I provided an example command syntax to show how to > selectively enable streams while leaving others of the same type disabled. You misunderstand me i think patches should be split in self contained changes. part of this patch adds support for -vn/-an/-sn/-dn and other parts are fixing bugs the patch for example adds a error check for disabled filter inputs using this example: ffmpeg -discard all -i tests/data/asynth-44100-1.wav -i tests/data/asynth-44100-1.wav -filter_complex '[0:a][1:a]amerge=inputs=2[aout]' -map '[aout]' -f framecrc - This newly added code triggers and prints "Stream specifier ':a' in filtergraph description [0:a][1:a]amerge=inputs=2[aout] matches a disabled input stream." before the patch the code did not error out. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
On 12-12-2018 03:40 AM, Michael Niedermayer wrote: On Mon, Dec 10, 2018 at 08:57:44PM +0530, Gyan wrote: At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input files. Individual streams can still be let through e.g. ffmpeg -an -discard:a:1 none -i file ... will let (only) the 2nd audio stream be seen during stream selection and filtergraph construction. Thanks, Gyan ffmpeg_filter.c |7 +++ ffmpeg_opt.c| 17 + 2 files changed, 24 insertions(+) 212c7bcecbd62329f3f18893c71f464ebeee3b67 0001-ffmpeg-implement-input-file-stream-disabling.patch From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Mon, 10 Dec 2018 20:38:20 +0530 Subject: [PATCH] ffmpeg: implement input file stream disabling -vn/-an/-sn/-dn can be set to stop processing of streams of said type from an input file. isnt this 2 seperate changes ? one is adding -vn/-an/-sn/-dn input support and the other is fixing some input discard issues related to existing -discard functionality Only one change. I provided an example command syntax to show how to selectively enable streams while leaving others of the same type disabled. Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
On Mon, Dec 10, 2018 at 08:57:44PM +0530, Gyan wrote: > At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input > files. Individual streams can still be let through e.g. > > ffmpeg -an -discard:a:1 none -i file ... > > will let (only) the 2nd audio stream be seen during stream selection and > filtergraph construction. > > Thanks, > Gyan > ffmpeg_filter.c |7 +++ > ffmpeg_opt.c| 17 + > 2 files changed, 24 insertions(+) > 212c7bcecbd62329f3f18893c71f464ebeee3b67 > 0001-ffmpeg-implement-input-file-stream-disabling.patch > From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 > From: Gyan Doshi > Date: Mon, 10 Dec 2018 20:38:20 +0530 > Subject: [PATCH] ffmpeg: implement input file stream disabling > > -vn/-an/-sn/-dn can be set to stop processing of streams > of said type from an input file. isnt this 2 seperate changes ? one is adding -vn/-an/-sn/-dn input support and the other is fixing some input discard issues related to existing -discard functionality if thats the case it should be 2 seperate patches thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "Nothing to hide" only works if the folks in power share the values of you and everyone you know entirely and always will -- Tom Scott signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] ffmpeg: implement input file stream disabling
At Michael's suggestion, this patch lets -vn/-an/-sn/-dn work for input files. Individual streams can still be let through e.g. ffmpeg -an -discard:a:1 none -i file ... will let (only) the 2nd audio stream be seen during stream selection and filtergraph construction. Thanks, Gyan From 9823a71f2055f2c4c4484536291bbd2afee36a81 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Mon, 10 Dec 2018 20:38:20 +0530 Subject: [PATCH] ffmpeg: implement input file stream disabling -vn/-an/-sn/-dn can be set to stop processing of streams of said type from an input file. --- fftools/ffmpeg_filter.c | 7 +++ fftools/ffmpeg_opt.c| 17 + 2 files changed, 24 insertions(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 6518d50870..8c0ff99dd9 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -293,10 +293,17 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) exit_program(1); } ist = input_streams[input_files[file_idx]->ist_index + st->index]; +if (ist->user_set_discard == AVDISCARD_ALL) { +av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s " + "matches a disabled input stream.\n", p, fg->graph_desc); +exit_program(1); +} } else { /* find the first unused stream of corresponding type */ for (i = 0; i < nb_input_streams; i++) { ist = input_streams[i]; +if (ist->user_set_discard == AVDISCARD_ALL) +continue; if (ist->dec_ctx->codec_type == type && ist->discard) break; } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index d4851a2cd8..59f4236127 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -746,6 +746,13 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st); ist->user_set_discard = AVDISCARD_NONE; + +if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) || +(o->audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) || +(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) || +(o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)) +ist->user_set_discard = AVDISCARD_ALL; + if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str); @@ -2174,6 +2181,8 @@ static int open_output_file(OptionsContext *o, const char *filename) int new_area; ist = input_streams[i]; new_area = ist->st->codecpar->width * ist->st->codecpar->height + 1*!!ist->st->codec_info_nb_frames; +if (ist->user_set_discard == AVDISCARD_ALL) +continue; if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) new_area = 1; if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && @@ -2195,6 +2204,8 @@ static int open_output_file(OptionsContext *o, const char *filename) int score; ist = input_streams[i]; score = ist->st->codecpar->channels + 1*!!ist->st->codec_info_nb_frames; +if (ist->user_set_discard == AVDISCARD_ALL) +continue; if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && score > best_score) { best_score = score; @@ -2216,6 +2227,8 @@ static int open_output_file(OptionsContext *o, const char *filename) AVCodec const *output_codec = avcodec_find_encoder(oc->oformat->subtitle_codec); int input_props = 0, output_props = 0; +if (input_streams[i]->user_set_discard == AVDISCARD_ALL) +continue; if (output_codec) output_descriptor = avcodec_descriptor_get(output_codec->id); if (input_descriptor) @@ -2237,6 +2250,8 @@ static int open_output_file(OptionsContext *o, const char *filename) if (!o->data_disable ) { enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA); for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) { +if (input_streams[i]->user_set_discard == AVDISCARD_ALL) +continue; if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA && input_streams[i]->st->codecpar->codec_id == codec_id ) new_data_stream(o, oc, i