History

libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

Matthieu Bouron committed 11 years ago

Commit cf16b451 parent 021b0231 file · +15 −6Browse files

Unified · Split

libavdevice/avfoundation.m+15−6
@@ -908,9 +908,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 907 unmodified lines
908908 return AVERROR(EIO);
909909 }
910910
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+
914919 pkt->stream_index = ctx->video_stream_index;
915920 pkt->flags |= AV_PKT_FLAG_KEY;
916921
@@ -938,9 +943,13 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 21 unmodified lines
938943 return AVERROR(EIO);
939944 }
940945
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+ }
944953
945954 pkt->stream_index = ctx->audio_stream_index;
946955 pkt->flags |= AV_PKT_FLAG_KEY;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t