From a6dd7933e0bd8ae1fd083639758f7fee9fc7a151 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期二, 10 九月 2019 16:34:10 +0800
Subject: [PATCH] Merge branch 'master' of ssh://192.168.1.14:29418/valib/goffmpeg

---
 csrc/ffmpeg/format/FormatOut.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/csrc/ffmpeg/format/FormatOut.cpp b/csrc/ffmpeg/format/FormatOut.cpp
index d319969..804c8ed 100644
--- a/csrc/ffmpeg/format/FormatOut.cpp
+++ b/csrc/ffmpeg/format/FormatOut.cpp
@@ -339,7 +339,6 @@
             char option_key[]="movflags";
             char option_value[]="frag_keyframe+empty_moov";
             av_dict_set(&avdic,option_key,option_value,0);
-
             flag = writeHeader(&avdic);
             av_dict_free(&avdic);
 
@@ -365,6 +364,7 @@
     bool FormatOut::endWriter(){
 
         auto flag =  writeTrailer();
+        closeResource();
         record_ = false;
 
         return flag;
@@ -397,12 +397,17 @@
         
         AVRational time_base_q = { 1, AV_TIME_BASE };
         //Duration between 2 frames (us)
-        int64_t calc_duration = (double)(AV_TIME_BASE)*(1 / fps_);  //鍐呴儴鏃堕棿鎴�
+        // int64_t calc_duration = (double)(AV_TIME_BASE)*(1 / fps_);  //鍐呴儴鏃堕棿鎴�
+        int64_t calc_duration = (int64_t)(AV_TIME_BASE / fps_);  //鍐呴儴鏃堕棿鎴�
         //Parameters
         pkt.pts = av_rescale_q(time_stamp*calc_duration, time_base_q, time_base);
         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);
+        // }
+        
     }
 
     bool FormatOut::writeFrame(AVPacket &pkt, const int64_t &frame_cnt,

--
Gitblit v1.8.0