diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-11-30 22:34:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-11-30 22:34:53 +0100 |
| commit | ce17803bf356f3e796dccde43b4cc3656609e7fc (patch) | |
| tree | 834c90f8f4bcb6cf8a68d4dfd17c8d6375fb45e1 /src | |
| parent | d9e6b138e84e7a8504075b8581cca4d0fabfbc40 (diff) | |
More accurate calculation of export video pts; may fix #1663.
Also specify audio pts on the way in to the encoder to stop FFmpeg
complaining.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ffmpeg_file_encoder.cc | 7 | ||||
| -rw-r--r-- | src/lib/ffmpeg_file_encoder.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index e5ea64599..7bac7b130 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -63,6 +63,7 @@ FFmpegFileEncoder::FFmpegFileEncoder ( , _video_frame_size (video_frame_size) , _video_frame_rate (video_frame_rate) , _audio_frame_rate (audio_frame_rate) + , _audio_frames (0) { _pixel_format = pixel_format (format); @@ -296,7 +297,8 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time) frame->width = image->size().width; frame->height = image->size().height; frame->format = _pixel_format; - frame->pts = time.seconds() / av_q2d (_video_stream->time_base); + DCPOMATIC_ASSERT (_video_stream->time_base.num == 1); + frame->pts = time.get() * _video_stream->time_base.den / DCPTime::HZ; AVPacket packet; av_init_packet (&packet); @@ -391,6 +393,8 @@ FFmpegFileEncoder::audio_frame (int size) DCPOMATIC_ASSERT (false); } + frame->pts = _audio_frames / (av_q2d (_audio_stream->time_base) * _audio_frame_rate); + AVPacket packet; av_init_packet (&packet); packet.data = 0; @@ -411,6 +415,7 @@ FFmpegFileEncoder::audio_frame (int size) av_frame_free (&frame); _pending_audio->trim_start (size); + _audio_frames += size; } void diff --git a/src/lib/ffmpeg_file_encoder.h b/src/lib/ffmpeg_file_encoder.h index 9f1e75b68..57f9135fa 100644 --- a/src/lib/ffmpeg_file_encoder.h +++ b/src/lib/ffmpeg_file_encoder.h @@ -84,6 +84,8 @@ private: int _video_frame_rate; int _audio_frame_rate; + int64_t _audio_frames; + boost::shared_ptr<AudioBuffers> _pending_audio; /** Store of shared_ptr<Image> to keep them alive whilst raw pointers into |
