[Libav-user] How to access the struct AVCodecTag?
Anton Shekhovtsov
shekh.anton at gmail.com
Wed Mar 18 00:11:58 EET 2020
вт, 17 мар. 2020 г. в 23:51, Giuseppe Torelli <giutorcom at gmail.com>:
>
>> I'm not sure if this is completely sane but I'm using this method for
>> testing how FFMpeg can mix codec and container: create memory writing
>> context, prepare writing of container, add single stream with the specific
>> encoding format, try to finish.
>> If there is any error assume the format is not supported in the container.
>>
>
> Would you please share some code?
>
https://sourceforge.net/p/vdfiltermod/cch_input/ci/master/tree/export.cpp#l884
This is part of VirtualDub2
IOWBuffer io;
int buf_size = 4096;
void* buf = av_malloc(buf_size);
AVIOContext* avio_ctx = avio_alloc_context((unsigned
char*)buf,buf_size,1,&io,0,&IOWBuffer::Write,&IOWBuffer::Seek);
AVFormatContext* ofmt = avformat_alloc_context();
ofmt->pb = avio_ctx;
ofmt->oformat = this->ofmt->oformat;
AVStream* st = avformat_new_stream(ofmt, 0);
avcodec_parameters_copy(st->codecpar, si.st->codecpar);
st->sample_aspect_ratio = si.st->sample_aspect_ratio;
st->avg_frame_rate = si.st->avg_frame_rate;
av_stream_set_r_frame_rate(st,st->avg_frame_rate);
st->time_base = si.st->time_base;
if(st->codecpar->codec_type==AVMEDIA_TYPE_AUDIO){
if(ofmt->oformat==av_guess_format("mp4", 0, 0)){
st->codecpar->codec_tag = 0;
}
}
bool failed = true;
if(avformat_write_header(ofmt, 0)<0) goto cleanup;
if(av_write_trailer(ofmt)<0) goto cleanup;
failed = false;
cleanup:
av_free(avio_ctx->buffer);
av_free(avio_ctx);
avformat_free_context(ofmt);
if(failed){
std::string msg;
msg += avcodec_get_name(codec_id);
msg += ": codec not currently supported in container ";
msg += format_name;
mContext.mpCallbacks->SetError(msg.c_str());
return false;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20200318/51ea1f45/attachment.html>
More information about the Libav-user
mailing list