[FFmpeg-devel] [PATCH 1/8] ffserver.c: Different timestamp scaling, still does not properly work with mp4 files?

Stephan Holljes klaxa1337 at googlemail.com
Sun May 20 21:53:57 EEST 2018


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 ffserver.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 39e1c32..bd7c694 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -127,13 +127,13 @@ void *read_thread(void *arg)
             pkt.dts = 0;
         }
         
-        pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, tb, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
-        pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, tb, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
-        pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, tb);
-        pkt.pos = -1;
+        //pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, tb, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+        //pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, tb, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+        //pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, tb);
+        //pkt.pos = -1;
         
         // current pts
-        pts = pkt.pts; //av_rescale_q(pkt.pts, in_stream->time_base, tb);
+        pts = av_rescale_q(pkt.pts, in_stream->time_base, tb);
         
         // current stream "uptime"
         now = av_gettime_relative() - start;
@@ -249,8 +249,13 @@ void write_segment(struct Client *c)
             if (ret < 0)
                 break;
             
-            pkt.dts = seg->ts[pkt_count];
-            pkt.pts = seg->ts[pkt_count+1];
+            pkt.dts = av_rescale_q_rnd(seg->ts[pkt_count], fmt_ctx->streams[pkt.stream_index]->time_base,
+                                                        c->ofmt_ctx->streams[pkt.stream_index]->time_base,
+                                                               AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+            pkt.pts = av_rescale_q_rnd(seg->ts[pkt_count+1], fmt_ctx->streams[pkt.stream_index]->time_base,
+                                                        c->ofmt_ctx->streams[pkt.stream_index]->time_base,
+                                                               AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+            pkt.pos = -1;
             pkt_count += 2;
             ret = av_write_frame(c->ofmt_ctx, &pkt);
             av_packet_unref(&pkt);
-- 
2.16.2



More information about the ffmpeg-devel mailing list