| 67 | } |
| 68 | |
| 69 | static int choose_encoder(const OptionsContext *o, AVFormatContext *s, |
| 70 | MuxStream *ms, const AVCodec **enc) |
| 71 | { |
| 72 | OutputStream *ost = &ms->ost; |
| 73 | enum AVMediaType type = ost->type; |
| 74 | const char *codec_name = NULL; |
| 75 | |
| 76 | *enc = NULL; |
| 77 | |
| 78 | opt_match_per_stream_str(ost, &o->codec_names, s, ost->st, &codec_name); |
| 79 | |
| 80 | if (type != AVMEDIA_TYPE_VIDEO && |
| 81 | type != AVMEDIA_TYPE_AUDIO && |
| 82 | type != AVMEDIA_TYPE_SUBTITLE) { |
| 83 | if (codec_name && strcmp(codec_name, "copy")) { |
| 84 | const char *type_str = av_get_media_type_string(type); |
| 85 | av_log(ost, AV_LOG_FATAL, |
| 86 | "Encoder '%s' specified, but only '-codec copy' supported " |
| 87 | "for %s streams\n", codec_name, type_str); |
| 88 | return AVERROR(ENOSYS); |
| 89 | } |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | if (!codec_name) { |
| 94 | ms->par_in->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->type); |
| 95 | *enc = avcodec_find_encoder(ms->par_in->codec_id); |
| 96 | if (!*enc) { |
| 97 | av_log(ost, AV_LOG_FATAL, "Automatic encoder selection failed " |
| 98 | "Default encoder for format %s (codec %s) is " |
| 99 | "probably disabled. Please choose an encoder manually.\n", |
| 100 | s->oformat->name, avcodec_get_name(ms->par_in->codec_id)); |
| 101 | return AVERROR_ENCODER_NOT_FOUND; |
| 102 | } |
| 103 | } else if (strcmp(codec_name, "copy")) { |
| 104 | int ret = find_codec(ost, codec_name, ost->type, 1, enc); |
| 105 | if (ret < 0) |
| 106 | return ret; |
| 107 | ms->par_in->codec_id = (*enc)->id; |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | static char *get_line(AVIOContext *s, AVBPrint *bprint) |
| 114 | { |
no test coverage detected