]> git.sesse.net Git - ffmpeg/blobdiff - ffmpeg.c
ffmpeg: set pkt_timebase
[ffmpeg] / ffmpeg.c
index 2fa8acb8dfa0fb87569fbf53219737bf05a368fc..4afc55b40c384e59f0d762c5dda7d7324ec6b248 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1948,7 +1948,7 @@ static int poll_filters(void)
                 avcodec_get_frame_defaults(ost->filtered_frame);
             filtered_frame = ost->filtered_frame;
 
-            while (!ost->is_past_recording_time) {
+            while (1) {
                 ret = av_buffersink_get_buffer_ref(ost->filter->filter, &picref,
                                                    AV_BUFFERSINK_FLAG_NO_REQUEST);
                 if (ret < 0) {
@@ -2357,6 +2357,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
     else
         avcodec_get_frame_defaults(ist->decoded_frame);
     decoded_frame = ist->decoded_frame;
+    av_codec_set_pkt_timebase(avctx, ist->st->time_base);
 
     update_benchmark(NULL);
     ret = avcodec_decode_audio4(avctx, decoded_frame, got_output, pkt);
@@ -2476,6 +2477,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
         avcodec_get_frame_defaults(ist->decoded_frame);
     decoded_frame = ist->decoded_frame;
     pkt->dts  = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base);
+    av_codec_set_pkt_timebase(ist->st->codec, ist->st->time_base);
 
     update_benchmark(NULL);
     ret = avcodec_decode_video2(ist->st->codec,
@@ -2500,6 +2502,16 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
     if(best_effort_timestamp != AV_NOPTS_VALUE)
         ist->next_pts = ist->pts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);
 
+    if (debug_ts) {
+        av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video "
+                "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64" best_effort_ts_time:%s keyframe:%d frame_type:%d \n",
+                ist->st->index, av_ts2str(decoded_frame->pts),
+                av_ts2timestr(decoded_frame->pts, &ist->st->time_base),
+                best_effort_timestamp,
+                av_ts2timestr(best_effort_timestamp, &ist->st->time_base),
+                decoded_frame->key_frame, decoded_frame->pict_type);
+    }
+
     pkt->size = 0;
     pre_process_video_frame(ist, (AVPicture *)decoded_frame, &buffer_to_free);