switch (format) {
case ExportFormat::PRORES_4444:
- _sample_format = AV_SAMPLE_FMT_S16;
+ _sample_format = AV_SAMPLE_FMT_S32;
_video_codec_name = "prores_ks";
- _audio_codec_name = "pcm_s16le";
+ _audio_codec_name = "pcm_s24le";
av_dict_set(&_video_options, "profile", "4", 0);
av_dict_set(&_video_options, "threads", "auto", 0);
break;
case ExportFormat::PRORES_HQ:
- _sample_format = AV_SAMPLE_FMT_S16;
+ _sample_format = AV_SAMPLE_FMT_S32;
_video_codec_name = "prores_ks";
- _audio_codec_name = "pcm_s16le";
+ _audio_codec_name = "pcm_s24le";
av_dict_set (&_video_options, "profile", "3", 0);
av_dict_set (&_video_options, "threads", "auto", 0);
break;
_audio_streams.clear ();
avcodec_close (_video_codec_context);
avio_close (_format_context->pb);
+ _format_context->pb = nullptr;
avformat_free_context (_format_context);
}
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;
}
}
}
- av_write_trailer (_format_context);
+ auto const r = av_write_trailer(_format_context);
+ if (r) {
+ throw EncodeError(N_("av_write_trailer"), N_("FFmpegFileEncoder::flush"), r);
+ }
}
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());
}
}