70 GUIVideoEncoder(
const char*
const out_file,
const int width,
const int height,
double frameDelay) {
79 if (frameDelay > 0.) {
80 framerate = (int)(1000. / frameDelay);
86 video_st->time_base.num = 1;
87 video_st->time_base.den = framerate;
89 const AVCodec* codec = avcodec_find_encoder(
myFormatContext->oformat->video_codec);
90 if (codec ==
nullptr) {
92 codec = avcodec_find_encoder_by_name(
"libx265");
94 if (codec ==
nullptr) {
100 throw ProcessError(
TL(
"Could not allocate video codec context!"));
125 if (
myCodecCtx->codec_id == AV_CODEC_ID_H264) {
126 av_opt_set(
myCodecCtx->priv_data,
"preset",
"slow", 0);
131 if (
myCodecCtx->codec_id == AV_CODEC_ID_HEVC) {
132 av_opt_set(
myCodecCtx->priv_data,
"preset",
"ultrafast", 0);
133 av_opt_set(
myCodecCtx->priv_data,
"tune",
"zero-latency", 0);
135 if (avcodec_open2(
myCodecCtx, codec,
nullptr) < 0) {
138 avcodec_parameters_from_context(video_st->codecpar,
myCodecCtx);
147 if (av_frame_get_buffer(
myFrame, 32) < 0) {
148 throw ProcessError(
TL(
"Could not allocate the video frame data!"));
163 myPkt = av_packet_alloc();
164 if (
myPkt ==
nullptr) {