Commit a4eb142c by lenz su

解码分辨率 帧率 编码格式 打印到excel

parent 0ba2cf40
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.2, 2020-01-04T16:33:07. --> <!-- Written by QtCreator 4.10.2, 2020-01-04T19:56:44. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
#include "QDataStream" #include "QDataStream"
#include "iostream" #include "iostream"
using namespace std; using namespace std;
#include <fstream>
#include <string>
#include <QDateTime>
bool isloged=false;
VideoDecoder::VideoDecoder() VideoDecoder::VideoDecoder()
{ {
pCodec = nullptr; pCodec = nullptr;
...@@ -33,8 +36,8 @@ void VideoDecoder::initWidth(int width, int height) ...@@ -33,8 +36,8 @@ void VideoDecoder::initWidth(int width, int height)
#else #else
int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1); //按1字节进行内存对齐,得到的内存大小最接近实际大小 int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 1); //按1字节进行内存对齐,得到的内存大小最接近实际大小
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 0); //按0字节进行内存对齐,得到的内存大小是0 // int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 0); //按0字节进行内存对齐,得到的内存大小是0
// int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 4); //按4字节进行内存对齐,得到的内存大小稍微大一些 // int yuvSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, pCodecCtx->width, pCodecCtx->height, 4); //按4字节进行内存对齐,得到的内存大小稍微大一些
unsigned int numBytes = static_cast<unsigned int>(yuvSize); unsigned int numBytes = static_cast<unsigned int>(yuvSize);
bufferYUV = static_cast<uint8_t *>(av_malloc(numBytes * sizeof(uint8_t))); bufferYUV = static_cast<uint8_t *>(av_malloc(numBytes * sizeof(uint8_t)));
...@@ -350,15 +353,15 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i ...@@ -350,15 +353,15 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
return 0; return 0;
} }
// while (0 == avcodec_receive_frame(pCodecCtx, pFrame)) // while (0 == avcodec_receive_frame(pCodecCtx, pFrame))
while(1) while(1)
{ {
int ret = avcodec_receive_frame(pCodecCtx, pFrame); int ret = avcodec_receive_frame(pCodecCtx, pFrame);
if (ret != 0) if (ret != 0)
{ {
// char buffer[1024] = {0}; // char buffer[1024] = {0};
// av_strerror(ret, buffer, 1024); // av_strerror(ret, buffer, 1024);
// fprintf(stderr, "avcodec_receive_frame = %d %s\n", ret, buffer); // fprintf(stderr, "avcodec_receive_frame = %d %s\n", ret, buffer);
break; break;
} }
...@@ -382,6 +385,17 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i ...@@ -382,6 +385,17 @@ bool VideoDecoder::decode(uint8_t *inputbuf, int frame_size, uint8_t *&outBuf, i
outBuf = bufferYUV; outBuf = bufferYUV;
outWidth = pCodecCtx->width; outWidth = pCodecCtx->width;
outHeight = pCodecCtx->height; outHeight = pCodecCtx->height;
if(!isloged){
ofstream oFile;
oFile.open("test.csv",ios::out|ios::trunc);
oFile<<"width"<<","<<"height"<<","<<"pix_fmt"<<","<<"fps"<<endl;
oFile<< pCodecCtx->width<<","<<pCodecCtx->height<<","<<"AV_PIX_FMT_YUV420P"<<","<<pCodecCtx->time_base.den<<endl;
oFile.close();
isloged=true;
}
} }
av_packet_unref(&pkt); av_packet_unref(&pkt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment