Note that newer libsub version is required.
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 32a0e0f8620f3741ab09bd6c7456305541692130..6d1ad68f79bb79d939e4baf25991b792ef4bbaa9 100644 (file)
@@ -383,11 +383,12 @@ FFmpegFileEncoder::flush ()
                        throw EncodeError (N_("avcodec_receive_packet"), N_("FFmpegFileEncoder::flush"), r);
                } else {
                        packet->stream_index = _video_stream_index;
+                       packet->duration = _video_stream->time_base.den / _video_frame_rate;
                        av_interleaved_write_frame (_format_context, packet.get());
                }
 
                flushed_audio = true;
-               for (auto i: _audio_streams) {
+               for (auto const& i: _audio_streams) {
                        if (!i->flush()) {
                                flushed_audio = false;
                        }
@@ -395,7 +396,9 @@ FFmpegFileEncoder::flush ()
        }
 
        auto const r = av_write_trailer(_format_context);
-       DCPOMATIC_ASSERT(r == 0);
+       if (r) {
+               throw EncodeError(N_("av_write_trailer"), N_("FFmpegFileEncoder::flush"), r);
+       }
 }
 
 
@@ -438,6 +441,7 @@ FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time)
                throw EncodeError (N_("avcodec_receive_packet"), N_("FFmpegFileEncoder::video"), r);
        } else if (r >= 0) {
                packet->stream_index = _video_stream_index;
+               packet->duration = _video_stream->time_base.den / _video_frame_rate;
                av_interleaved_write_frame (_format_context, packet.get());
        }
 }