diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2015-03-18 13:40:12 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2015-03-20 16:10:20 +0100 |
commit | 342fc46c69199b076b7c210f42208ce39a2bde1c (patch) | |
tree | 5ea3a7db00a6f4e8f6e7125d1129bda141eebc06 | |
parent | 30e6abd1a8cc4fd5daf2e23ad2e768862c39e975 (diff) | |
download | ffmpeg-342fc46c69199b076b7c210f42208ce39a2bde1c.tar.gz |
cmdutils: Add a stream specifier to map usable streams
It drops everything that cannot be used for re-encoding and/or
streamcopy.
-rw-r--r-- | cmdutils.c | 22 | ||||
-rw-r--r-- | doc/avtools-common-opts.texi | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/cmdutils.c b/cmdutils.c index e01ad24906..af8354aa19 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -1587,6 +1587,28 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) av_freep(&key); return ret; + } else if (*spec == 'u') { + AVCodecContext *avctx = st->codec; + int val; + switch (avctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + val = avctx->sample_rate && avctx->channels; + if (avctx->sample_fmt == AV_SAMPLE_FMT_NONE) + return 0; + break; + case AVMEDIA_TYPE_VIDEO: + val = avctx->width && avctx->height; + if (avctx->pix_fmt == AV_PIX_FMT_NONE) + return 0; + break; + case AVMEDIA_TYPE_UNKNOWN: + val = 0; + break; + default: + val = 1; + break; + } + return avctx->codec_id != AV_CODEC_ID_NONE && val != 0; } else if (!*spec) /* empty specifier, matches everything */ return 1; diff --git a/doc/avtools-common-opts.texi b/doc/avtools-common-opts.texi index 8468ecaad1..852d3f8236 100644 --- a/doc/avtools-common-opts.texi +++ b/doc/avtools-common-opts.texi @@ -48,6 +48,9 @@ Match the stream by stream id (e.g. PID in MPEG-TS container). Matches streams 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 u +Matches streams with usable configuration, the codec must be defined and the +essential information such as video dimension or audio sample rate must be present. Note that in @command{avconv}, matching by metadata will only work properly for input files. |