我使用下面的代碼:的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