Просмотр исходного кода

V1.6.1

1.文件编码改成GBK,支持vs编译器
叶海辉 6 лет назад
Родитель
Сommit
5649a14d3c

+ 11 - 0
VideoRecorder.pro

@@ -8,6 +8,17 @@ QT       += core gui network
 
 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
+UI_DIR  = obj/Gui
+MOC_DIR = obj/Moc
+OBJECTS_DIR = obj/Obj
+
+
+#将输出文件直接放到源码目录下的bin目录下,将dll都放在了次目录中,用以解决运行后找不到dll的问
+#DESTDIR=$$OUT_PWD/bin/
+DESTDIR=$$PWD/bin/
+QMAKE_CXXFLAGS += -std=c++11
+
+
 TARGET = VideoRecorder
 TEMPLATE = app
 


BIN
bin/VideoRecorder.exe


BIN
bin/avcodec-56.dll


BIN
bin/avdevice-56.dll


BIN
bin/avfilter-5.dll


BIN
bin/avformat-56.dll


BIN
bin/avutil-54.dll


BIN
bin/ffmpeg.exe


BIN
bin/postproc-53.dll


BIN
bin/swresample-1.dll


BIN
bin/swscale-3.dll


+ 4 - 6
src/main.cpp

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -16,14 +16,12 @@ int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
 
-    QTextCodec *codec = QTextCodec::codecForName("UTF-8"); //获�系统编�
+    QTextCodec *codec = QTextCodec::codecForName("GBK"); //»ñȡϵͳ±àÂë
     QTextCodec::setCodecForLocale(codec);
-    QTextCodec::setCodecForCStrings(codec);
-    QTextCodec::setCodecForTr(codec);
 
     MainWindow w;
 
-    //第二个�数为录制文件的路径
+    //µÚ¶þ¸ö²ÎÊýÎªÂ¼ÖÆÎļþµÄ·¾¶
     if (argc >= 2)
     {
         QString str = QString(argv[1]);

+ 31 - 26
src/mainwindow.cpp

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -32,10 +32,15 @@ MainWindow::MainWindow(QWidget *parent) :
         exit(1);
     }
 
-    setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);  //使窗�的标题���
+    setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);  //ʹ´°¿ÚµÄ±êÌâÀ¸Òþ²Ø
     setAttribute(Qt::WA_TranslucentBackground, true);
 
+#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
     AppDataPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+#else
+    AppDataPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
+#endif
+
     QString dirName = AppDataPath + "\\ScreenRecorder\\etc";
     SettingFile = dirName + "\\set.conf";
 
@@ -61,7 +66,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
     selectRectWidget = new SelectRect(NULL,SelectRect::RecordGif);
     QDesktopWidget* desktopWidget = QApplication::desktop();
-    deskRect = desktopWidget->screenGeometry();//获��用桌�大�
+    deskRect = desktopWidget->screenGeometry();//»ñÈ¡¿ÉÓÃ×ÀÃæ´óС
     m_rate = deskRect.height() * 1.0 / deskRect.width();
     selectRectWidget->setRate(m_rate);
 
@@ -75,7 +80,7 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(ui->toolButton_audio,SIGNAL(clicked(bool)),this,SLOT(slotToolBtnToggled(bool)));
     connect(ui->toolButton_file,SIGNAL(clicked(bool)),this,SLOT(slotToolBtnToggled(bool)));
 
-    ///动画类 用�实现窗体从上方慢慢出现
+    ///¶¯»­Àà ÓÃÀ´ÊµÏÖ´°Ìå´ÓÉÏ·½ÂýÂý³öÏÖ
     animation = new QPropertyAnimation(this, "geometry");
     animation->setDuration(1000);
 
@@ -93,7 +98,7 @@ MainWindow::MainWindow(QWidget *parent) :
     {
         selectRectWidget->show();
         selectRectWidget->setPointHide();
-        ui->hideRectButton->setText("��");
+        ui->hideRectButton->setText(QStringLiteral("Òþ²Ø"));
     }
 }
 
@@ -133,7 +138,7 @@ void MainWindow::mousePressEvent(QMouseEvent * event)
 }
 
 void MainWindow::mouseMoveEvent(QMouseEvent * event)
-{  //实现鼠标移动窗�
+{  //ʵÏÖÊó±êÒÆ¶¯´°¿Ú
     if (event->buttons() & Qt::LeftButton)
     {
         if (isLeftBtnPressed)
@@ -249,7 +254,7 @@ void MainWindow::loadFile()
     selectRectWidget->setRect(rect);
     ui->startButton->setEnabled(true);
     selectRectWidget->setVisible(false);
-    ui->hideRectButton->setText("显示");
+    ui->hideRectButton->setText(QStringLiteral("ÏÔʾ"));
     ui->startButton->setEnabled(true);
 }
 
@@ -322,8 +327,8 @@ void MainWindow::initDev()
         devFile.close();
     }
 
-    /// 执行ffmpeg命令行 获�音视频设备
-    /// 请将ffmpeg.exe和程�放到�一个目录下
+    /// Ö´ÐÐffmpegÃüÁîÐÐ »ñÈ¡ÒôÊÓÆµÉ豸
+    /// Ç뽫ffmpeg.exeºÍ³ÌÐò·Åµ½Í¬Ò»¸öĿ¼ÏÂ
 
     QString ffmpegPath = QCoreApplication::applicationDirPath() + "/ffmpeg.exe";
     ffmpegPath.replace("/","\\\\");
@@ -459,9 +464,9 @@ void MainWindow::slotToolBtnToggled(bool isChecked)
     else if (QObject::sender() == ui->toolButton_file)
     {
         QString s = QFileDialog::getSaveFileName(
-                   this, "选择�存文件的路劲",
-                       saveFileName,//�始目录
-                    "视频文件 (*.mp4);;");
+                   this, QStringLiteral("Ñ¡Ôñ±£´æÎļþµÄ·¾¶"),
+                       saveFileName,//³õʼĿ¼
+                    QStringLiteral("ÊÓÆµÎļþ (*.mp4);;"));
          if (!s.isEmpty())
          {
              saveFileName = s.replace("/","\\\\");
@@ -475,11 +480,11 @@ void MainWindow::slotToolBtnToggled(bool isChecked)
 
 void MainWindow::slotSelectRectFinished(QRect re)
 {
-    /// 1.传给ffmpeg编�的图�宽高必须是�数。
-    /// 2.图��剪的起始�置和结��置也必须是�数
-    /// 而手动选择的区域很有�能会是奇数,因此需�处�一下 给他弄��数
-    /// 处�的方法很简答:其实就是往�或者往�移一个�素
-    /// 一个�素的大�肉眼基本也看�出�啥区别。
+    /// 1.´«¸øffmpeg±àÂëµÄͼÏñ¿í¸ß±ØÐëÊÇżÊý¡£
+    /// 2.ͼÏñ²Ã¼ôµÄÆðʼλÖúͽáÊøÎ»ÖÃÒ²±ØÐëÊÇżÊý
+    /// ¶øÊÖ¶¯Ñ¡ÔñµÄÇøÓòºÜÓпÉÄÜ»áÊÇÆæÊý£¬Òò´ËÐèÒª´¦ÀíһϠ¸øËûŪ³ÉżÊý
+    /// ´¦ÀíµÄ·½·¨ºÜ¼ò´ð£ºÆäʵ¾ÍÊÇÍùǰ»òÕßÍùºóÒÆÒ»¸öÏñËØ
+    /// Ò»¸öÏñËØµÄ´óСÈâÑÛ»ù±¾Ò²¿´²»³öÀ´É¶Çø±ð¡£
 
     int x = re.x();
     int y = re.y();
@@ -510,7 +515,7 @@ void MainWindow::slotSelectRectFinished(QRect re)
 
     rect = QRect(x,y,w,h);
 
-    QString str = QString("==当�区域==\n\n起点(%1,%2)\n\n大�(%3 x %4)")
+    QString str = QStringLiteral("==µ±Ç°ÇøÓò==\n\nÆðµã(%1,%2)\n\n´óС(%3 x %4)")
             .arg(rect.left()).arg(rect.left()).arg(rect.width()).arg(rect.height());
 
     ui->showRectInfoLabel->setText(str);
@@ -518,7 +523,7 @@ void MainWindow::slotSelectRectFinished(QRect re)
     ui->startButton->setEnabled(true);
     ui->editRectButton->setEnabled(true);
     ui->hideRectButton->setEnabled(true);
-    ui->hideRectButton->setText("��");
+    ui->hideRectButton->setText(QStringLiteral("Òþ²Ø"));
 
     saveFile();
 
@@ -556,7 +561,7 @@ bool MainWindow::startRecord()
         {
             ret = -2;
             msg = "filepath not set";
-            QMessageBox::critical(this,"�示","请先设置�存文件路径");
+            QMessageBox::critical(this, QStringLiteral("Ìáʾ"), QStringLiteral("ÇëÏÈÉèÖñ£´æÎļþ·¾¶"));
         }
         else
         {
@@ -566,7 +571,7 @@ bool MainWindow::startRecord()
 
             if (audioDevName.isEmpty())
             {
-                QMessageBox::critical(this,"�示","出错了,音频或视频设备未就绪,程�无法�行�");
+                QMessageBox::critical(this, QStringLiteral("Ìáʾ"), QStringLiteral("³ö´íÁË,ÒôƵ»òÊÓÆµÉ豸δ¾ÍÐ÷£¬³ÌÐòÎÞ·¨ÔËÐУ¡"));
 
                 ret = -3;
                 msg = "audio device not set";
@@ -589,7 +594,7 @@ bool MainWindow::startRecord()
                 }
                 else
                 {
-                    QMessageBox::critical(this,"�示","出错了,�始化录�设备失败�");
+                    QMessageBox::critical(this, QStringLiteral("Ìáʾ"), QStringLiteral("³ö´íÁË,³õʼ»¯Â¼ÆÁÉ豸ʧ°Ü£¡"));
 
                     ret = -4;
                     msg = "init screen device failed!";
@@ -607,7 +612,7 @@ bool MainWindow::startRecord()
                 }
                 else
                 {
-                    QMessageBox::critical(this,"�示","出错了,�始化音频设备失败�");
+                    QMessageBox::critical(this, QStringLiteral("Ìáʾ"), QStringLiteral("³ö´íÁË,³õʼ»¯ÒôƵÉ豸ʧ°Ü£¡"));
                     ret = -5;
                     msg = "init audio device failed!";
                     goto end;
@@ -722,12 +727,12 @@ void MainWindow::slotHideRectBtnClick()
     if (selectRectWidget->isVisible())
     {
        selectRectWidget->setVisible(false);
-       ui->hideRectButton->setText("显示");
+       ui->hideRectButton->setText(QStringLiteral("ÏÔʾ"));
     }
     else
     {
        selectRectWidget->setVisible(true);
-       ui->hideRectButton->setText("��");
+       ui->hideRectButton->setText(QStringLiteral("Òþ²Ø"));
     }
 }
 

+ 17 - 17
src/mainwindow.h

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -42,7 +42,7 @@ public:
     explicit MainWindow(QWidget *parent = 0);
     ~MainWindow();
 
-    /// 设置�存的视频文件的路径
+    /// ÉèÖñ£´æµÄÊÓÆµÎļþµÄ·¾¶
     void setSaveFile(QString fileName);
 
 public slots:
@@ -62,27 +62,27 @@ private:
     bool isLeftBtnPressed;
     QPoint dragPosition;
 
-    QPropertyAnimation *animation; //动画类 用�实现窗体从上方慢慢出现
+    QPropertyAnimation *animation; //¶¯»­Àà ÓÃÀ´ÊµÏÖ´°Ìå´ÓÉÏ·½ÂýÂý³öÏÖ
 
-    QString AppDataPath; //�存�置文件的目录
-    QString SettingFile; //�存�置文件的路径
+    QString AppDataPath; //±£´æÅäÖÃÎļþµÄĿ¼
+    QString SettingFile; //±£´æÅäÖÃÎļþµÄ·¾¶
 
-    QString saveFileName; //视频路径
+    QString saveFileName; //ÊÓÆµÂ·¾¶
 
     ScreenRecorder *m_screenRecorder;
-    QRect deskRect; //�用桌�大�
-    SelectRect *selectRectWidget;  //选择区域的控件
-    QRect rect; //当�录制的区域
-    float m_rate; //�幕宽高比
+    QRect deskRect; //¿ÉÓÃ×ÀÃæ´óС
+    SelectRect *selectRectWidget;  //Ñ¡ÔñÇøÓòµÄ¿Ø¼þ
+    QRect rect; //µ±Ç°Â¼ÖƵÄÇøÓò
+    float m_rate; //ÆÁÄ»¿í¸ß±È
 
-    QTimer * m_timer; //定时器 用于获�时间
+    QTimer * m_timer; //¶¨Ê±Æ÷ ÓÃÓÚ»ñȡʱ¼ä
 
     RecoderState m_recordeState;
 
-    void initDev(); //获�录音设备的列表
+    void initDev(); //»ñȡ¼ÒôÉ豸µÄÁбí
 
-    void loadFile(); //加载�置文件
-    void saveFile(); //写入�置文件
+    void loadFile(); //¼ÓÔØÅäÖÃÎļþ
+    void saveFile(); //дÈëÅäÖÃÎļþ
 
 //    QString m_erroMsg;
     bool startRecord();
@@ -93,12 +93,12 @@ private slots:
     void slotToolBtnToggled(bool);
     void slotBtnClicked();
 
-    ///选择录�区域相关 - Begin
+    ///Ñ¡Ôñ¼ÆÁÇøÓòÏà¹Ø - Begin
     void slotSelectRectBtnClick();
     void slotEditRectBtnClick();
     void slotHideRectBtnClick();
     void slotSelectRectFinished(QRect);
-    ///选择录�区域相关 - End
+    ///Ñ¡Ôñ¼ÆÁÇøÓòÏà¹Ø - End
 
     void slotTimerTimeOut();
 

+ 12 - 12
src/video/getvideothread.cpp

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -19,7 +19,7 @@ void Yuv420Cut(int x,int y,int desW,int desH,int srcW,int srcH,uint8_t *srcBuffe
     int yIndex = 0;
     bufferIndex = 0 + x + y*srcW;
     tmpRange = srcW * desH;
-    for (int i=0;i<tmpRange;) //�行拷�Y分�数�
+    for (int i=0;i<tmpRange;) //ÖðÐп½±´Y·ÖÁ¿Êý¾Ý
     {
         memcpy(desBuffer+yIndex,srcBuffer+bufferIndex+i,desW);
         i += srcW;
@@ -31,7 +31,7 @@ void Yuv420Cut(int x,int y,int desW,int desH,int srcW,int srcH,uint8_t *srcBuffe
     int uWidthCopy = desW/2;
     bufferIndex = srcW * srcH+x/2 + y /2 *srcW / 2;
     tmpRange = srcW * desH / 4;
-    for (int i=0;i<tmpRange;) //�行拷�U分�数�
+    for (int i=0;i<tmpRange;) //ÖðÐп½±´U·ÖÁ¿Êý¾Ý
     {
         memcpy(desBuffer+uIndex,srcBuffer+bufferIndex+i,uWidthCopy);
         i += uIndexStep;
@@ -44,7 +44,7 @@ void Yuv420Cut(int x,int y,int desW,int desH,int srcW,int srcH,uint8_t *srcBuffe
     int vWidthCopy = desW/2;
     bufferIndex = srcW*srcH + srcW*srcH/4 + x/2 + y /2 *srcW / 2;
     tmpRange = srcW * desH / 4;
-    for (int i=0;i<tmpRange;) //�行拷�V分�数�
+    for (int i=0;i<tmpRange;) //ÖðÐп½±´V·ÖÁ¿Êý¾Ý
     {
         memcpy(desBuffer+vIndex,srcBuffer+bufferIndex+i,vWidthCopy);
         i += vIndexStep;
@@ -102,7 +102,7 @@ ErroCode GetVideoThread::init(QString videoDevName, bool useVideo, QString audio
         QString audioDevOption = QString("audio=%1").arg(audioDevName);
 
         if(avformat_open_input(&pFormatCtx,audioDevOption.toUtf8(),ifmt,NULL)!=0){
-            fprintf(stderr,"Couldn't open input stream audio.(无法打开输入�)\n");
+            fprintf(stderr,"Couldn't open input stream audio.£¨ÎÞ·¨´ò¿ªÊäÈëÁ÷£©\n");
             return AudioOpenFailed;
         }
 
@@ -113,7 +113,7 @@ ErroCode GetVideoThread::init(QString videoDevName, bool useVideo, QString audio
     {
         QString videoDevOption = QString("video=%1").arg(videoDevName);
         if(avformat_open_input(&pFormatCtx,videoDevOption.toUtf8(),ifmt,NULL)!=0){
-            qDebug()<<"Couldn't open input stream video.(无法打开输入�)\n";
+            qDebug()<<"Couldn't open input stream video.£¨ÎÞ·¨´ò¿ªÊäÈëÁ÷£©\n";
             return VideoOpenFailed;
         }
     }
@@ -130,7 +130,7 @@ ErroCode GetVideoThread::init(QString videoDevName, bool useVideo, QString audio
             }
         if(videoindex==-1)
         {
-            printf("Didn't find a video stream.(没有找到视频�)\n");
+            printf("Didn't find a video stream.£¨Ã»ÓÐÕÒµ½ÊÓÆµÁ÷£©\n");
             return VideoOpenFailed;
         }
 
@@ -169,7 +169,7 @@ ErroCode GetVideoThread::init(QString videoDevName, bool useVideo, QString audio
             }
         if(audioindex==-1)
         {
-            printf("Didn't find a video stream.(没有找到视频�)\n");
+            printf("Didn't find a video stream.£¨Ã»ÓÐÕÒµ½ÊÓÆµÁ÷£©\n");
             return AudioOpenFailed;
         }
 
@@ -300,7 +300,7 @@ void GetVideoThread::run()
 
     AVPacket *packet=(AVPacket *)av_malloc(sizeof(AVPacket));
 //    //Output Information-----------------------------
-//    printf("File Information(文件信�)---------------------\n");
+//    printf("File Information£¨ÎļþÐÅÏ¢£©---------------------\n");
 //    av_dump_format(pFormatCtx,0,NULL,0);
 //    printf("-------------------------------------------------\n");
 
@@ -349,7 +349,7 @@ void GetVideoThread::run()
 
             if(ret < 0)
             {
-                printf("video Decode Error.(解�错误)\n");
+                printf("video Decode Error.£¨½âÂë´íÎó£©\n");
                 return;
             }
 
@@ -366,7 +366,7 @@ void GetVideoThread::run()
                     memcpy(picture_buf+y_size+y_size/4,pFrameYUV->data[2],y_size/4);
                     uint8_t * yuv_buf = (uint8_t *)av_malloc(size);
 
-                    ///将YUV图��剪�目标大�
+                    ///½«YUVͼÏñ²Ã¼ô³ÉÄ¿±ê´óС
                     Yuv420Cut(pic_x,pic_y,pic_w,pic_h,pCodecCtx->width,pCodecCtx->height,picture_buf,yuv_buf);
                     m_saveVideoFileThread->videoDataQuene_Input(yuv_buf,yuvSize*3/2,time);
                     av_free(picture_buf);

+ 2 - 2
src/video/getvideothread.h

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 

+ 19 - 19
src/video/savevideofile.cpp

@@ -1,7 +1,7 @@
 
 /**
- * 叶海辉
- * QQ121376426
+ * Ҷ����
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -168,12 +168,12 @@ void SaveVideoFileThread::videoDataQuene_Input(uint8_t * buffer,int size,long ti
 
 /**
  * @brief SaveVideoFileThread::videoDataQuene_get
- * 由于采集屏幕获取到的图像每秒钟的张数是不固定的
- * 而我们是用固定帧率的方式来写视频
- * 因此需要保证每秒钟的视频图像张数都是固定的
- * 下面这个函数就是做了这个操作:
- * 1.视频数据不足的时候重复使用上一帧
- * 2.视频数据太多的时候 丢掉一些
+ * ���ڲɼ���Ļ��ȡ����ͼ��ÿ���ӵ������Dz��̶���
+ * ���������ù̶�֡�ʵķ�ʽ��д��Ƶ
+ * ������Ҫ��֤ÿ���ӵ���Ƶͼ���������ǹ̶���
+ * ������������������������������
+ * 1.��Ƶ���ݲ�����ʱ���ظ�ʹ����һ֡
+ * 2.��Ƶ����̫����ʱ�� ����һЩ
  * @param time
  * @return
  */
@@ -199,7 +199,7 @@ BufferDataNode *SaveVideoFileThread::videoDataQuene_get(double time)
                     }
                     else
                     {
-                        //队列里面才一帧数据 先不处理
+                        //����������һ֡���� �Ȳ�����
                         SDL_UnlockMutex(videoMutex);
                         return NULL;
                     }
@@ -405,7 +405,7 @@ bool SaveVideoFileThread::write_audio_frame(AVFormatContext *oc, AVStream *st)
         free(node);
     }
 
-//    memset(samples,0,audio_input_frame_size * 2 * c->channels); //静音
+//    memset(samples,0,audio_input_frame_size * 2 * c->channels); //����
 
 //    fread(samples, 1, audio_input_frame_size*4, pcmInFp);
 
@@ -529,7 +529,7 @@ void SaveVideoFileThread::open_video(AVFormatContext *oc, AVStream *st)
     //H.264
     //av_dict_set(&param, "preset", "slow", 0);
     av_dict_set(&param, "preset", "superfast", 0);
-    av_dict_set(&param, "tune", "zerolatency", 0);  //实现实时编码
+    av_dict_set(&param, "tune", "zerolatency", 0);  //ʵ��ʵʱ����
 
     codec = avcodec_find_encoder(c->codec_id);
     if (!codec){
@@ -606,7 +606,7 @@ bool SaveVideoFileThread::write_video_frame(AVFormatContext *oc, AVStream *st, d
         }
     }
 
-    ///没有视频数据 则先返回 等待视频数据
+    ///û����Ƶ���� ���ȷ��� �ȴ���Ƶ����
     if (node == NULL)
     {
         return false;
@@ -617,7 +617,7 @@ bool SaveVideoFileThread::write_video_frame(AVFormatContext *oc, AVStream *st, d
 
         memcpy(picture_buf,node->buffer, y_size*3/2);
 
-        picture->data[0] = picture_buf;  // 亮度Y
+        picture->data[0] = picture_buf;  // ����Y
         picture->data[1] = picture_buf+ y_size;  // U
         picture->data[2] = picture_buf+ y_size*5/4; // V
     }
@@ -700,7 +700,7 @@ bool SaveVideoFileThread::startWrite()
 {
     isStop = false;
 
-    ///创建一个线程专门用来解码视频
+    ///����һ���߳�ר������������Ƶ
     SDL_CreateThread(writeVideoThreadFunc, "writeVideoThreadFunc", this);
 
     return true;
@@ -724,9 +724,9 @@ int writeVideoThreadFunc(void *arg)
 
     int i;
 
-    /// ffmpegg可以根据文件名称自动获取视频格式
-    /// 如需换别的格式 只需要改文件名和对应的format_name(就是下面的Mp4)即可
-    /// 因此无需了解具体的视频封装格式
+    /// ffmpegg���Ը����ļ������Զ���ȡ��Ƶ��ʽ
+    /// ���軻���ĸ�ʽ ֻ��Ҫ���ļ����Ͷ�Ӧ��format_name������������Mp4������
+    /// ���������˽���������Ƶ��װ��ʽ
 
     /* allocate the output media context */
     avformat_alloc_output_context2(&oc, NULL, "mp4", pointer->filename);
@@ -808,7 +808,7 @@ int writeVideoThreadFunc(void *arg)
                 {
                     break;
                 }
-                SDL_Delay(1); //延时1ms
+                SDL_Delay(1); //��ʱ1ms
             }
         } else {
             if (!pointer->write_video_frame(oc, video_st,pointer->video_pts*1000))
@@ -817,7 +817,7 @@ int writeVideoThreadFunc(void *arg)
                 {
                     break;
                 }
-                SDL_Delay(1); //延时1ms
+                SDL_Delay(1); //��ʱ1ms
             }
         }
     }

+ 7 - 7
src/video/savevideofile.h

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -36,9 +36,9 @@ struct BufferDataNode
 
 /**
  * @brief The SaveVideoFileThread class
- * �存生�视频
- * 主��考了 ffmpeg的output_example.c
- * output_example.c�以自行百度下载到
+ * ±£´æÉú³ÉÊÓÆµ
+ * Ö÷Òª²Î¿¼ÁË ffmpegµÄoutput_example.c
+ * output_example.c¿ÉÒÔ×ÔÐаٶÈÏÂÔØµ½
  */
 
 class SaveVideoFileThread
@@ -78,7 +78,7 @@ public:
 
     int m_videoFrameRate;
 
-    uint8_t picture_buf[2000*2000*4]; //这个大���够存一帧h264就行,这里实际上�需�这么大
+    uint8_t picture_buf[2000*2000*4]; //Õâ¸ö´óСֻҪ¹»´æÒ»Ö¡h264¾ÍÐУ¬ÕâÀïʵ¼ÊÉϲ»ÐèÒªÕâô´ó
     bool isStop;
 
     float t, tincr, tincr2;
@@ -108,7 +108,7 @@ public:
     BufferDataNode * AudioDataQueneHead;
     BufferDataNode * AudioDataQueneTail;
 
-    BufferDataNode * lastVideoNode; //上一次的帧(帧�足的时候用上一次的帧�补全)
+    BufferDataNode * lastVideoNode; //ÉÏÒ»´ÎµÄÖ¡£¨Ö¡²»×ãµÄʱºòÓÃÉÏÒ»´ÎµÄÖ¡À´²¹È«£©
     int videoBufferCount;
     int audioBufferCount;
 

+ 4 - 4
src/video/screenrecorder.cpp

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -51,7 +51,7 @@ ErroCode ScreenRecorder::init(QString videoDevName, bool useVideo, QString audio
         ErroCode code = m_videoThread->init(videoDevName,useVideo,"",false);
         if (code != SUCCEED)
         {
-            qDebug()<<"视频�始化失败";
+            qDebug()<<"ÊÓÆµ³õʼ»¯Ê§°Ü";
             return code;
         }
     }
@@ -61,7 +61,7 @@ ErroCode ScreenRecorder::init(QString videoDevName, bool useVideo, QString audio
         ErroCode code = m_audioThread->init("",false,audioDevName,useAudio);
         if (code != SUCCEED)
         {
-            qDebug()<<"音频�始化失败";
+            qDebug()<<"ÒôƵ³õʼ»¯Ê§°Ü";
             return code;
         }
     }

+ 9 - 9
src/video/screenrecorder.h

@@ -1,7 +1,7 @@
 
 /**
- * �海辉
- * QQ群121376426
+ * Ò¶º£»Ô
+ * QQȺ121376426
  * http://blog.yundiantech.com/
  */
 
@@ -30,20 +30,20 @@ public:
     void restoreRecord();
     void stopRecord();
 
-    void setPicRange(int x,int y,int w,int h); //设置录制�幕的区域
+    void setPicRange(int x,int y,int w,int h); //ÉèÖÃÂ¼ÖÆÆÁÄ»µÄÇøÓò
     void setVideoFrameRate(int value);
 
     double getVideoPts();
     double getAudioPts();
 
 private:
-    SaveVideoFileThread * m_saveVideoFileThread; //�存�视频文件的线程
+    SaveVideoFileThread * m_saveVideoFileThread; //±£´æ³ÉÊÓÆµÎļþµÄÏß³Ì
 
-    /// 把视频和音频放到一起获�
-    /// avformat_free_context释放的时候会奔溃
-    /// 无奈,�能把他们放到2个线程中执行
-    GetVideoThread *m_videoThread; //获�视频的线程
-    GetVideoThread *m_audioThread; //获�音频的线程
+    /// °ÑÊÓÆµºÍÒôƵ·Åµ½Ò»Æð»ñÈ¡
+    /// avformat_free_contextÊͷŵÄʱºò»á±¼À£
+    /// ÎÞÄΣ¬Ö»ÄܰÑËûÃǷŵ½2¸öÏß³ÌÖÐÖ´ÐÐ
+    GetVideoThread *m_videoThread; //»ñÈ¡ÊÓÆµµÄÏß³Ì
+    GetVideoThread *m_audioThread; //»ñÈ¡ÒôƵµÄÏß³Ì
 
     bool m_useVideo;
     bool m_useAudio;