| 1184 | } |
| 1185 | |
| 1186 | static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) |
| 1187 | { |
| 1188 | enum AVMediaType type = ost->st->codecpar->codec_type; |
| 1189 | char *codec_name = NULL; |
| 1190 | |
| 1191 | if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { |
| 1192 | MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); |
| 1193 | if (!codec_name) { |
| 1194 | ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->filename, |
| 1195 | NULL, ost->st->codecpar->codec_type); |
| 1196 | ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id); |
| 1197 | if (!ost->enc) { |
| 1198 | av_log(NULL, AV_LOG_FATAL, "Automatic encoder selection failed for " |
| 1199 | "output stream #%d:%d. Default encoder for format %s (codec %s) is " |
| 1200 | "probably disabled. Please choose an encoder manually.\n", |
| 1201 | ost->file_index, ost->index, s->oformat->name, |
| 1202 | avcodec_get_name(ost->st->codecpar->codec_id)); |
| 1203 | return AVERROR_ENCODER_NOT_FOUND; |
| 1204 | } |
| 1205 | } else if (!strcmp(codec_name, "copy")) |
| 1206 | ost->stream_copy = 1; |
| 1207 | else { |
| 1208 | ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); |
| 1209 | ost->st->codecpar->codec_id = ost->enc->id; |
| 1210 | } |
| 1211 | ost->encoding_needed = !ost->stream_copy; |
| 1212 | } else { |
| 1213 | /* no encoding supported for other media types */ |
| 1214 | ost->stream_copy = 1; |
| 1215 | ost->encoding_needed = 0; |
| 1216 | } |
| 1217 | |
| 1218 | return 0; |
| 1219 | } |
| 1220 | |
| 1221 | static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) |
| 1222 | { |
no test coverage detected