MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / choose_encoder

Function choose_encoder

fftools/ffmpeg_mux_init.c:69–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static 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
113static char *get_line(AVIOContext *s, AVBPrint *bprint)
114{

Callers 1

ost_addFunction · 0.85

Calls 6

av_get_media_type_stringFunction · 0.85
av_logFunction · 0.85
av_guess_codecFunction · 0.85
avcodec_find_encoderFunction · 0.85
avcodec_get_nameFunction · 0.85
find_codecFunction · 0.70

Tested by

no test coverage detected