2 Commits

Author SHA1 Message Date
e8760dcfe5 优化编码参数解决问题:
1、编码后数据量过大导致大疆图传中断;
2、大疆遥控器解码后,视频出现偶尔后退的情况;
2024-09-25 13:46:55 +08:00
bd4d055129 待解决bug:有的仪器使用avio_open/av_write_frame将视频写入文件会崩溃,而且写入的视频无法播放; 2024-03-01 10:15:27 +08:00
2 changed files with 13 additions and 13 deletions

View File

@ -3,7 +3,7 @@
int main(int argc, char *argv[])
{
std::cout<<"ximeaAirborneSystem 版本:"<< "41." <<std::endl;
std::cout<<"ximeaAirborneSystem 版本:"<< "43." <<std::endl;
QCoreApplication a(argc, argv);
//UdpServer* x=new UdpServer();

View File

@ -1232,8 +1232,8 @@ void PushFlow::encodePushFlow()
codecContext->height = m_iHeight;
codecContext->time_base = {1, m_iFramerateVideo};
codecContext->pix_fmt = AV_PIX_FMT_YUV420P; // 设置为YUV420P格式
codecContext->gop_size = 1;//多少帧产生一组关键帧
codecContext->max_b_frames = 1;//b帧参考帧
codecContext->gop_size = 50;//多少帧产生一组关键帧
codecContext->max_b_frames = 0;//b帧参考帧设置为1会导致视频回退的现象
// codecContext->bit_rate = 1000000; // 设置比特率为 1000000
// 打开视频编码器
@ -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]);