Browse Source

change driver_h264_rtspclient.

yuchuli 2 years ago
parent
commit
1ff32cbf25

+ 4 - 0
src/driver/driver_h264_rtspclient/ffmpeg_outputer.h

@@ -52,8 +52,12 @@ class FfmpegOutputer {
  //           av_dict_set(&opts, "fps", "30", 0);
  //           av_dict_set(&opts, "fps", "30", 0);
         }
         }
 
 
+        assert(opts!= NULL);
+        assert(m_ofmt_ctx != NULL);
+
         //Write file header
         //Write file header
         ret = avformat_write_header(m_ofmt_ctx, &opts);
         ret = avformat_write_header(m_ofmt_ctx, &opts);
+ //       std::cout<<" run hear. "<<std::endl;
         if (ret < 0) {
         if (ret < 0) {
             printf("Error occurred when opening output URL\n");
             printf("Error occurred when opening output URL\n");
             return -1;
             return -1;

+ 3 - 0
src/driver/driver_h264_rtspclient/rtspclientup.cpp

@@ -55,6 +55,7 @@ void rtspclientup::threadrstp(const char *strrtsp, int nwidth, int nheight)
         std::cout<<"can't get codepar from file."<<std::endl;
         std::cout<<"can't get codepar from file."<<std::endl;
         return ;
         return ;
     }
     }
+    out_stream->codecpar->codec_id = AV_CODEC_ID_H264;
     out_stream->codecpar->bit_rate = 2000000;
     out_stream->codecpar->bit_rate = 2000000;
     out_stream->codecpar->width = nwidth;
     out_stream->codecpar->width = nwidth;
     out_stream->codecpar->height = nheight;
     out_stream->codecpar->height = nheight;
@@ -65,6 +66,8 @@ void rtspclientup::threadrstp(const char *strrtsp, int nwidth, int nheight)
         ret = pusher->OpenOutputStream(strrtsp, fmtctx);
         ret = pusher->OpenOutputStream(strrtsp, fmtctx);
         while ((ret != 0)&&mbthreadrun) {
         while ((ret != 0)&&mbthreadrun) {
             std::cout<<"OpenOutputStream Fail. "<<std::endl;
             std::cout<<"OpenOutputStream Fail. "<<std::endl;
+            delete pusher;
+            pusher = new FfmpegOutputer();
             std::this_thread::sleep_for(std::chrono::seconds(1));
             std::this_thread::sleep_for(std::chrono::seconds(1));
             ret = pusher->OpenOutputStream(strrtsp, fmtctx);
             ret = pusher->OpenOutputStream(strrtsp, fmtctx);
 
 

+ 1 - 0
src/tool/tool_siasun/main.cpp

@@ -7,5 +7,6 @@ int main(int argc, char *argv[])
     MainWindow w;
     MainWindow w;
     w.show();
     w.show();
 
 
+
     return a.exec();
     return a.exec();
 }
 }

+ 0 - 2
src/tool/tool_siasun/mainwindow.cpp

@@ -10,8 +10,6 @@
 
 
 #include <QFileDialog>
 #include <QFileDialog>
 
 
-
-
 #define VIEW_WIDTH 6000
 #define VIEW_WIDTH 6000
 #define VIEW_HEIGHT 6000
 #define VIEW_HEIGHT 6000