Unified · Split
| @@ -2368,7 +2368,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, · 2367 unmodified lines | ||
| 2368 | 2368 | return err < 0 ? err : ret; |
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | −static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eof, | |
| 2371 | +static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof, | |
| 2372 | 2372 | int *decode_failed) |
| 2373 | 2373 | { |
| 2374 | 2374 | AVFrame *decoded_frame; |
| @@ -2459,6 +2459,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int eo · 84 unmodified lines | ||
| 2459 | 2459 | ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; |
| 2460 | 2460 | |
| 2461 | 2461 | best_effort_timestamp= decoded_frame->best_effort_timestamp; |
| 2462 | + *duration_pts = decoded_frame->pkt_duration; | |
| 2462 | 2463 | |
| 2463 | 2464 | if (ist->framerate.num) |
| 2464 | 2465 | best_effort_timestamp = ist->cfr_next_pts++; |
| @@ -2629,6 +2630,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 164 unmodified lines | ||
| 2629 | 2630 | // while we have more to decode or while the decoder did output something on EOF |
| 2630 | 2631 | while (ist->decoding_needed) { |
| 2631 | 2632 | int64_t duration_dts = 0; |
| 2633 | + int64_t duration_pts = 0; | |
| 2632 | 2634 | int got_output = 0; |
| 2633 | 2635 | int decode_failed = 0; |
| 2634 | 2636 | |
| @@ -2641,7 +2643,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 6 unmodified lines | ||
| 2641 | 2643 | &decode_failed); |
| 2642 | 2644 | break; |
| 2643 | 2645 | case AVMEDIA_TYPE_VIDEO: |
| 2644 | − ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, !pkt, | |
| 2646 | + ret = decode_video (ist, repeating ? NULL : &avpkt, &got_output, &duration_pts, !pkt, | |
| 2645 | 2647 | &decode_failed); |
| 2646 | 2648 | if (!repeating || !pkt || got_output) { |
| 2647 | 2649 | if (pkt && pkt->duration) { |
| @@ -2660,7 +2662,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 12 unmodified lines | ||
| 2660 | 2662 | } |
| 2661 | 2663 | |
| 2662 | 2664 | if (got_output) |
| 2663 | − ist->next_pts += duration_dts; //FIXME the duration is not correct in some cases | |
| 2665 | + ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); | |
| 2664 | 2666 | break; |
| 2665 | 2667 | case AVMEDIA_TYPE_SUBTITLE: |
| 2666 | 2668 | if (repeating) |