[Ffmpeg-devel] Re: Listing suitable codec for each format
Dean Bender
dean98
Fri Mar 30 07:39:00 CEST 2007
forgot the attachment.. sorry,
flvformat = L_av_alloc_format_context();
sprintf(flvformat->filename,fileName);
char * codecname = lowercase(cl_videoCodec->string);
Com_Printf ("Trying format %s\n",cl_videoFormat->string);
Com_Printf ("Trying codec %s\n",cl_videoCodec->string);
flvformat->oformat = L_guess_format(cl_videoFormat->string, NULL, NULL);
if (!flvformat->oformat) {
Com_Printf ( S_COLOR_RED "Invalid format (%s) . Enter \\listFormat
to see valid formats for ffmpeg\n",cl_videoFormat->string);
return qfalse;
}
struct AVCodecTag ** tag = (flvformat->oformat->codec_tag);
AVCodec * p=0;
int i=0;
//tag[0][x] for video, tag[1][x] for audio
Com_Printf("firstcodec : %s\n",tag[0][0].id);
//return qfalse; <-- some formats hang here. tag[][] is null maybe ?
p = L_avcodec_find_encoder(tag[0][0].id);
while(p){
Com_Printf("codec %d: %s\n",i,p->name);
if( Q_stricmp(p->name,cl_videoCodec->string) == 0 ){
codec = p;
Com_Printf("match\n");
break;
}
i++;
p= L_avcodec_find_encoder(tag[0][i].id);
}
if (!codec) {
Com_Printf ( S_COLOR_YELLOW "Codec (%s) not suitable for format
(%s). Reverting to a compatible codec
(%s)\n",cl_videoCodec->string,cl_videoFormat->string,L_avcodec_find_encoder(flvformat->oformat->video_codec)->name);
codec = L_avcodec_find_encoder( flvformat->oformat->video_codec );
}
if (!codec) {
Com_Printf ( S_COLOR_RED "Invalid codec (%s) . Enter \\listCodec
to see valid codecs for ffmpeg\n",cl_videoCodec->string);
return qfalse;
}
return qfalse;
On 3/30/07, Dean Bender <dean98 at gmail.com> wrote:
> Hello all,
>
> First, I'm new to the ffmpeg API and I'm surprised that the
> documentation is very lacking. I wish I can help in some areas when I
> have more time this summer.
>
> Now let's get to my problem. I'm trying to use ffmpeg as the AV
> encoder in a modified quake3 source code. I've figured out how to use
> the encoding component using libavcodec/libavformat. Now I'm trying to
> automate things, by detecting if the user-specified codec and format
> are a good match (not all codecs can be used with any formats right ?)
> I looked at the ffmpeg's doxygen and saw that there is an AVCodecTag
> ** codec_tag that sounds exactly like what I need for what I'm trying
> to do. However I'm stumped now because the array isn't filled in for
> every single formats. I have attached the code I'm using to get the
> codec_tag array and list them.
>
> One more thing, why is the AVCodecTag declared as a struct member for
> AVOutputFormat, but only defined in riff.c ? It seems to be so
> illogical to me. Please explain to me, thanks.
>
> Regards,
>
> Hassan
>
More information about the ffmpeg-devel
mailing list