我使用下面的代码:的ffmpeg, '协议没有发现' 错误
const char *sFileOutput;
AVOutputFormat *ofmt;
AVFormatContext *ofcx;
int main(int argc, char* argv[])
{
av_log_set_level(AV_LOG_DEBUG);
av_register_all();
avcodec_register_all();
avformat_network_init();
char s1[40]={0};
const time_t timer = time(NULL);
u = localtime(&timer);
strftime(s1, 40, "%d.%m.%Y-%H:%M:%S.avi", u);
sFileOutput=&s1;
//char *sFileOutput = "01.01.2017-23.23.23.avi";
ofmt = av_guess_format(NULL, sFileOutput, NULL);
ofcx = avformat_alloc_context();
ofcx->oformat = ofmt;
int ret2=avio_open(&ofcx->pb, sFileOutput, AVIO_FLAG_WRITE);
if(ret2<0){
fprintf(stderr, "\nError occurred when opening output file: %s\n",av_err2str(ret2));
}
}
当我运行它,我有错误控制台:
Error occurred when opening output file: Protocol not found
,但如果我去掉字符串
char *sFileOutput = "01.01.2017-23.23.23.avi";
即使没有问题,程序工作没有错误。请告诉我什么是错的。
谢谢你的回答,它也帮助我。但真正的问题是生成的名称包含':'。我将字符串更改为 – gogoer