- /* Audio and video frame PTS values may not start with 0. We want
- to fiddle them so that:
-
- 1. One of them starts at time 0.
- 2. The first video PTS value ends up on a frame boundary.
-
- Then we remove big initial gaps in PTS and we allow our
- insertion of black frames to work.
-
- We will do pts_to_use = pts_from_ffmpeg + pts_offset;
- */
-
- bool const have_video = c->first_video();
- bool const have_audio = c->audio_stream () && c->audio_stream()->first_audio;
-
- /* First, make one of them start at 0 */
-
- if (have_audio && have_video) {
- _pts_offset = - min (c->first_video().get(), c->audio_stream()->first_audio.get());
- } else if (have_video) {
- _pts_offset = - c->first_video().get();
- } else if (have_audio) {
- _pts_offset = - c->audio_stream()->first_audio.get();
- }