Unified · Split
| @@ -908,9 +908,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 907 unmodified lines | |||
| 908 | return AVERROR(EIO); | 908 | return AVERROR(EIO); |
| 909 | } | 909 | } |
| 910 | 910 | ||
| 911 | pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts, | 911 | CMItemCount count; |
| 912 | AV_TIME_BASE_Q, | 912 | CMSampleTimingInfo timing_info; |
| 913 | avf_time_base_q); | 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 | pkt->stream_index = ctx->video_stream_index; | 919 | pkt->stream_index = ctx->video_stream_index; |
| 915 | pkt->flags |= AV_PKT_FLAG_KEY; | 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 | return AVERROR(EIO); | 943 | return AVERROR(EIO); |
| 939 | } | 944 | } |
| 940 | 945 | ||
| 941 | pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_audio_pts, | 946 | CMItemCount count; |
| 942 | AV_TIME_BASE_Q, | 947 | CMSampleTimingInfo timing_info; |
| 943 | avf_time_base_q); | 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 | pkt->stream_index = ctx->audio_stream_index; | 954 | pkt->stream_index = ctx->audio_stream_index; |
| 946 | pkt->flags |= AV_PKT_FLAG_KEY; | 955 | pkt->flags |= AV_PKT_FLAG_KEY; |