|
@@ -127,6 +127,7 @@ void ThreadEnc()
|
|
|
char * strbufnv12 = new char[30000000];
|
|
|
int ret;
|
|
|
|
|
|
+RESTART:
|
|
|
#ifndef USE_QSV
|
|
|
av_register_all();
|
|
|
|
|
@@ -246,6 +247,9 @@ void ThreadEnc()
|
|
|
frame->width = c->width;
|
|
|
frame->height = c->height;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ret = av_frame_get_buffer(frame, 0);
|
|
|
if (ret < 0) {
|
|
|
fprintf(stderr, "Could not allocate the video frame data\n");
|
|
@@ -265,6 +269,18 @@ void ThreadEnc()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ static int ntest = 0; //test change framerate.
|
|
|
+ // ntest++;
|
|
|
+ int64_t new_bitrate = 4000000;
|
|
|
+ if(ntest == 300)
|
|
|
+ {
|
|
|
+ // 关闭原编码器
|
|
|
+ avcodec_close(c);
|
|
|
+ gnframerate = new_bitrate;
|
|
|
+ goto RESTART;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
gMutexLock.lock();
|
|
|
memcpy(strbuf,gstrbuffer,gnwidth*gnheight*3/2);
|
|
|
gbNewData = false;
|
|
@@ -284,6 +300,8 @@ void ThreadEnc()
|
|
|
|
|
|
frame->pts = i;i++;
|
|
|
|
|
|
+
|
|
|
+ std::cout<<" bitrate: "<<c->bit_rate<<std::endl;
|
|
|
/* encode the image */
|
|
|
QTime xTime;
|
|
|
xTime.start();
|