Unified · Split
| @@ -908,9 +908,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 907 unmodified lines | ||
| 908 | 908 | return AVERROR(EIO); |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | − pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts, | |
| 912 | − AV_TIME_BASE_Q, | |
| 913 | − avf_time_base_q); | |
| 911 | + CMItemCount count; | |
| 912 | + CMSampleTimingInfo timing_info; | |
| 913 | + | |
| 914 | + if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1, &timing_info, &count) == noErr) { | |
| 915 | + AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale); | |
| 916 | + pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q); | |
| 917 | + } | |
| 918 | + | |
| 914 | 919 | pkt->stream_index = ctx->video_stream_index; |
| 915 | 920 | pkt->flags |= AV_PKT_FLAG_KEY; |
| 916 | 921 | |
| @@ -938,9 +943,13 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 21 unmodified lines | ||
| 938 | 943 | return AVERROR(EIO); |
| 939 | 944 | } |
| 940 | 945 | |
| 941 | − pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_audio_pts, | |
| 942 | − AV_TIME_BASE_Q, | |
| 943 | − avf_time_base_q); | |
| 946 | + CMItemCount count; | |
| 947 | + CMSampleTimingInfo timing_info; | |
| 948 | + | |
| 949 | + if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1, &timing_info, &count) == noErr) { | |
| 950 | + AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale); | |
| 951 | + pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q); | |
| 952 | + } | |
| 944 | 953 | |
| 945 | 954 | pkt->stream_index = ctx->audio_stream_index; |
| 946 | 955 | pkt->flags |= AV_PKT_FLAG_KEY; |