From b73029149580370e62dd6c14a270aea902f85cf2 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期三, 18 九月 2019 09:52:30 +0800
Subject: [PATCH] fix rec bug

---
 csrc/ffmpeg/format/FormatOut.cpp |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/csrc/ffmpeg/format/FormatOut.cpp b/csrc/ffmpeg/format/FormatOut.cpp
index 804c8ed..a6e8c3c 100644
--- a/csrc/ffmpeg/format/FormatOut.cpp
+++ b/csrc/ffmpeg/format/FormatOut.cpp
@@ -404,34 +404,32 @@
         pkt.dts = pkt.pts;
         pkt.duration = av_rescale_q(calc_duration, time_base_q, time_base); //(double)(calc_duration)*(double)(av_q2d(time_base_q)) / (double)(av_q2d(time_base));
         
-        // if (pkt.duration < 0 || time_base.den != 90000){
-            // logIt("CALCULATE DURATION : %lld, fame count : %lld, TIMEBASE: %d", calc_duration,time_stamp, time_base.den);
-        // }
-        
+        // logIt("FRAME ID: %lld, PTS : %lld, DTS : %lld", frame_cnt, pkt.pts, pkt.dts);        
     }
 
     bool FormatOut::writeFrame(AVPacket &pkt, const int64_t &frame_cnt,
                               bool interleaved/* = true*/){
 
         adjustPTS(pkt, frame_cnt);
-        return writeFrame2(pkt, interleaved);
+        auto ret = writeFrame2(pkt, interleaved);
+        if (!ret){
+            logIt("write to file failed, pkt.pts: %lld, dts: %lld, frame count: %d",
+                    pkt.pts, pkt.dts, frame_cnt);
+        }
+        return ret;
     }
 
     bool FormatOut::writeFrame2(AVPacket &pkt, bool interleaved){
         
         int ret = 0;
-        if(interleaved)
+        if(interleaved){
             ret = av_interleaved_write_frame(ctx_, &pkt);
-        else
-        {
+        }else{
             // returns 1 if flushed and there is no more data to flush
             ret = av_write_frame(ctx_, &pkt);
         }
     
-        if(ret < 0)
-        {
-            logIt("write packet to file failed:%s",
-                    getAVErrorDesc(ret).c_str()); 
+        if(ret < 0){
             return false;
         }
 

--
Gitblit v1.8.0