10#include "libwebpencoder_p.h"
12#include "pipewireproduce_p.h"
18#include <libavcodec/avcodec.h>
19#include <libavfilter/buffersink.h>
20#include <libavfilter/buffersrc.h>
21#include <libavutil/pixfmt.h>
24#include "logging_record.h"
26LibWebPEncoder::LibWebPEncoder(PipeWireProduce *produce)
27 : SoftwareEncoder(produce)
31bool LibWebPEncoder::initialize(
const QSize &size)
33 createFilterGraph(size);
35 auto codec = avcodec_find_encoder_by_name(
"libwebp");
37 qCWarning(PIPEWIRERECORD_LOGGING) <<
"libwebp codec not found";
41 m_avCodecContext = avcodec_alloc_context3(codec);
42 if (!m_avCodecContext) {
43 qCWarning(PIPEWIRERECORD_LOGGING) <<
"Could not allocate video codec context";
48 m_avCodecContext->width = size.
width();
49 m_avCodecContext->height = size.
height();
50 m_avCodecContext->pix_fmt = AV_PIX_FMT_YUVA420P;
51 m_avCodecContext->time_base = AVRational{1, 1000};
53 AVDictionary *options =
nullptr;
55 applyEncodingPreference(options);
57 if (
int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) {
58 qCWarning(PIPEWIRERECORD_LOGGING) <<
"Could not open codec" << av_err2str(result);
65int LibWebPEncoder::percentageToAbsoluteQuality(
const std::optional<quint8> &quality)
67 return quality.value_or(-1);
70void LibWebPEncoder::applyEncodingPreference([[maybe_unused]] AVDictionary *options)
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:20 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.