diff options
author | Matthieu Bouron <matthieu.bouron@gmail.com> | 2015-03-13 22:16:55 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-29 05:08:33 +0300 |
commit | cf16b459a873b990efc10d93e9912ab01b8a0fba (patch) | |
tree | 4bd6bb04e0194cfa42cd27472fdd72fa75b26400 /libavdevice | |
parent | 021b0237518100cee39241ef64596086af616375 (diff) |
libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API
Reviewed-by: Thilo Borgmann <thilo.borgmann@mail.de>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/avfoundation.m | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m index 52e686a97f..5140ecbc0e 100644 --- a/libavdevice/avfoundation.m +++ b/libavdevice/avfoundation.m @@ -908,9 +908,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } - pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts, - AV_TIME_BASE_Q, - avf_time_base_q); + CMItemCount count; + CMSampleTimingInfo timing_info; + + if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1, &timing_info, &count) == noErr) { + AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale); + pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q); + } + pkt->stream_index = ctx->video_stream_index; pkt->flags |= AV_PKT_FLAG_KEY; @@ -938,9 +943,13 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EIO); } - pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_audio_pts, - AV_TIME_BASE_Q, - avf_time_base_q); + CMItemCount count; + CMSampleTimingInfo timing_info; + + if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1, &timing_info, &count) == noErr) { + AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale); + pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q); + } pkt->stream_index = ctx->audio_stream_index; pkt->flags |= AV_PKT_FLAG_KEY; |