You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
ffmpeg: add option recast_media
Allows forcing decoders of different media type. Needed to decode media data muxed as data streams.
This commit is contained in:
@@ -449,6 +449,11 @@ output file already exists.
|
|||||||
Set number of times input stream shall be looped. Loop 0 means no loop,
|
Set number of times input stream shall be looped. Loop 0 means no loop,
|
||||||
loop -1 means infinite loop.
|
loop -1 means infinite loop.
|
||||||
|
|
||||||
|
@item -recast_media (@emph{global})
|
||||||
|
Allow forcing a decoder of a different media type than the one
|
||||||
|
detected or designated by the demuxer. Useful for decoding media
|
||||||
|
data muxed as data streams.
|
||||||
|
|
||||||
@item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
|
@item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
|
||||||
@itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
|
@itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
|
||||||
Select an encoder (when used before an output file) or a decoder (when used
|
Select an encoder (when used before an output file) or a decoder (when used
|
||||||
|
@@ -186,6 +186,7 @@ static int input_sync;
|
|||||||
static int input_stream_potentially_available = 0;
|
static int input_stream_potentially_available = 0;
|
||||||
static int ignore_unknown_streams = 0;
|
static int ignore_unknown_streams = 0;
|
||||||
static int copy_unknown_streams = 0;
|
static int copy_unknown_streams = 0;
|
||||||
|
static int recast_media = 0;
|
||||||
static int find_stream_info = 1;
|
static int find_stream_info = 1;
|
||||||
|
|
||||||
static void uninit_options(OptionsContext *o)
|
static void uninit_options(OptionsContext *o)
|
||||||
@@ -759,7 +760,7 @@ static const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type,
|
|||||||
av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
|
av_log(NULL, AV_LOG_FATAL, "Unknown %s '%s'\n", codec_string, name);
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
if (codec->type != type) {
|
if (codec->type != type && !recast_media) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
|
av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name);
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
}
|
}
|
||||||
@@ -774,6 +775,8 @@ static const AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVSt
|
|||||||
if (codec_name) {
|
if (codec_name) {
|
||||||
const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
|
const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
|
||||||
st->codecpar->codec_id = codec->id;
|
st->codecpar->codec_id = codec->id;
|
||||||
|
if (recast_media && st->codecpar->codec_type != codec->type)
|
||||||
|
st->codecpar->codec_type = codec->type;
|
||||||
return codec;
|
return codec;
|
||||||
} else
|
} else
|
||||||
return avcodec_find_decoder(st->codecpar->codec_id);
|
return avcodec_find_decoder(st->codecpar->codec_id);
|
||||||
@@ -3429,6 +3432,8 @@ const OptionDef options[] = {
|
|||||||
"Ignore unknown stream types" },
|
"Ignore unknown stream types" },
|
||||||
{ "copy_unknown", OPT_BOOL | OPT_EXPERT, { ©_unknown_streams },
|
{ "copy_unknown", OPT_BOOL | OPT_EXPERT, { ©_unknown_streams },
|
||||||
"Copy unknown stream types" },
|
"Copy unknown stream types" },
|
||||||
|
{ "recast_media", OPT_BOOL | OPT_EXPERT, { &recast_media },
|
||||||
|
"allow recasting stream type in order to force a decoder of different media type" },
|
||||||
{ "c", HAS_ARG | OPT_STRING | OPT_SPEC |
|
{ "c", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
|
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
|
||||||
"codec name", "codec" },
|
"codec name", "codec" },
|
||||||
|
Reference in New Issue
Block a user