diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2010-12-04 17:46:13 +0300 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2010-12-04 17:46:13 +0300 |
commit | 118ccae0307a5a2645ab1817158e36e9c0c80cf4 (patch) | |
tree | c8c63c5d2bb3ccd187ad3d1e19ceb8197d5f0608 | |
parent | 1c3b408f884dcd59f32be3fd49d23e91111e3109 (diff) |
add subtitle codec autodetection
Originally committed as revision 25884 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | ffmpeg.c | 9 | ||||
-rw-r--r-- | libavformat/utils.c | 2 |
2 files changed, 10 insertions, 1 deletions
@@ -3569,6 +3569,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) AVOutputStream *ost; AVCodec *codec=NULL; AVCodecContext *subtitle_enc; + enum CodecID codec_id; st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); if (!st) { @@ -3579,9 +3580,14 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) subtitle_enc = st->codec; output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); if(!subtitle_stream_copy){ - subtitle_enc->codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, + if (subtitle_codec_name) { + codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name); + } else { + codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); + codec = avcodec_find_encoder(codec_id); + } } avcodec_get_context_defaults3(st->codec, codec); @@ -3600,6 +3606,7 @@ static void new_subtitle_stream(AVFormatContext *oc, int file_idx) if (subtitle_stream_copy) { st->stream_copy = 1; } else { + subtitle_enc->codec_id = codec_id; set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); } diff --git a/libavformat/utils.c b/libavformat/utils.c index 44d1c62592..c8e6d6602a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -274,6 +274,8 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, return codec_id; }else if(type == AVMEDIA_TYPE_AUDIO) return fmt->audio_codec; + else if (type == AVMEDIA_TYPE_SUBTITLE) + return fmt->subtitle_codec; else return CODEC_ID_NONE; } |