cmdutils: Add a stream specifier to map usable streams
It drops everything that cannot be used for re-encoding and/or streamcopy.
This commit is contained in:
parent
30e6abd1a8
commit
342fc46c69
2 changed files with 25 additions and 0 deletions
22
cmdutils.c
22
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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue