From db2d75de067daa15671820022b692217aa16aa5b Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sun, 5 Dec 2021 20:15:10 +0900 Subject: [PATCH] More tweaking of encoding params for video Also tweaked the notes/docs about resulting encoded video output. --- README.md | 9 +++++---- src/video.cc | 4 +++- src/video.h | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3f77554..1624484 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,11 @@ output video being encoded hasn't been implemented yet. The current implementation writes each video frame to a PNG image in the current directory.~~ -Video decoding and encoding is finished, but there is some noticable drops in -quality when encoding to colored dithered video. It may be better to just -output each frame to individual PNGs, then combining them later just like as -mentioned here: https://trac.ffmpeg.org/wiki/Slideshow . +Video decoding and encoding is finished, ~~but there is some noticable drops in +quality when encoding to colored dithered video~~ but the resulting video may +end up being too large. It may be better to just output each frame to individual +PNGs, then combining them later just like as mentioned here with the params you +want set: https://trac.ffmpeg.org/wiki/Slideshow . # Other Notes diff --git a/src/video.cc b/src/video.cc index c378471..afcf0cc 100644 --- a/src/video.cc +++ b/src/video.cc @@ -212,8 +212,10 @@ bool Video::DitherVideo(const std::string &output_filename, Image *blue_noise, enc_codec_context->height = height; enc_stream->time_base = time_base; enc_codec_context->time_base = time_base; - enc_codec_context->gop_size = 12; + enc_codec_context->gop_size = 128; enc_codec_context->global_quality = 23; + enc_codec_context->qmax = 35; + enc_codec_context->qmin = 20; enc_codec_context->pix_fmt = AVPixelFormat::AV_PIX_FMT_YUV444P; if (avf_enc_context->oformat->flags & AVFMT_GLOBALHEADER) { enc_codec_context->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; diff --git a/src/video.h b/src/video.h index 3d060bb..2b3f053 100644 --- a/src/video.h +++ b/src/video.h @@ -47,8 +47,8 @@ class Video { * \brief Dithers the frames in the input video. * * If output_as_pngs is true, then the output will be individaul PNGs of each - * frame instead of a video file. This may be desireable because the output - * video struggles to maintain video quality. + * frame instead of a video file. This may be desireable for more control over + * the params set when encoding the resulting video. * * \return True on success. */