待解决bug:有的仪器使用avio_open/av_write_frame将视频写入文件会崩溃,而且写入的视频无法播放;
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "41." <<std::endl;
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "42." <<std::endl;
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//UdpServer* x=new UdpServer();
|
||||
|
@ -1246,17 +1246,17 @@ void PushFlow::encodePushFlow()
|
||||
}
|
||||
|
||||
// 打开输出文件
|
||||
if (avio_open(&formatContext->pb, outputVideoPath, AVIO_FLAG_WRITE) < 0)
|
||||
{
|
||||
qDebug() << "Error: Failed to open output file";
|
||||
avcodec_close(codecContext);
|
||||
avcodec_free_context(&codecContext);
|
||||
avformat_free_context(formatContext);
|
||||
return;
|
||||
}
|
||||
// if (avio_open(&formatContext->pb, outputVideoPath, AVIO_FLAG_WRITE) < 0)
|
||||
// {
|
||||
// qDebug() << "Error: Failed to open output file";
|
||||
// avcodec_close(codecContext);
|
||||
// avcodec_free_context(&codecContext);
|
||||
// avformat_free_context(formatContext);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 写入文件头
|
||||
avformat_write_header(formatContext, nullptr);
|
||||
// avformat_write_header(formatContext, nullptr);
|
||||
|
||||
// 使用sws_scale进行颜色空间转换
|
||||
SwsContext* swsContext = sws_getContext(m_iWidth, m_iHeight, AV_PIX_FMT_BGR24,
|
||||
@ -1345,7 +1345,7 @@ void PushFlow::encodePushFlow()
|
||||
|
||||
fclose(fp);
|
||||
// 写入文件尾
|
||||
av_write_trailer(formatContext);
|
||||
// av_write_trailer(formatContext);
|
||||
|
||||
// 释放AVFrame和相关资源
|
||||
av_freep(&frame->data[0]);
|
||||
|
Reference in New Issue
Block a user