#include <SkVideoEncoder.h>
Definition at line 28 of file SkVideoEncoder.h.
◆ SkVideoEncoder()
SkVideoEncoder::SkVideoEncoder |
( |
| ) |
|
◆ ~SkVideoEncoder()
SkVideoEncoder::~SkVideoEncoder |
( |
| ) |
|
Definition at line 116 of file SkVideoEncoder.cpp.
116 {
117 this->reset();
118
119 if (fSWScaleCtx) {
120 sws_freeContext(fSWScaleCtx);
121 }
122}
◆ addFrame()
bool SkVideoEncoder::addFrame |
( |
const SkPixmap & |
pm | ) |
|
If you have your own pixmap, call addFrame(). Note this may fail if it uses an unsupported ColorType (requires kN32_SkColorType) or AlphaType, or the dimensions don't match those set in beginRecording.
Definition at line 257 of file SkVideoEncoder.cpp.
257 {
259 return false;
260 }
262 return false;
263 }
264
265 if (
check_err(av_frame_make_writable(fFrame))) {
266 return false;
267 }
268
269 fFrame->pts = fCurrentPTS;
270 fCurrentPTS += fDeltaPTS;
271
272 const uint8_t*
src[] = { (
const uint8_t*)pm.
addr() };
274 sws_scale(fSWScaleCtx,
src, strides, 0, fInfo.
height(), fFrame->data, fFrame->linesize);
275
276 return this->sendFrame(fFrame);
277}
constexpr int SkToInt(S x)
static bool check_err(int err, const int silentList[]=nullptr)
static bool is_valid(SkISize dim)
const SkImageInfo & info() const
const void * addr() const
SkISize dimensions() const
SkColorType colorType() const
◆ beginFrame()
SkCanvas * SkVideoEncoder::beginFrame |
( |
| ) |
|
As an alternative to calling addFrame(), you can call beginFrame/endFrame, and the encoder will manage allocating a surface/canvas for you.
SkCanvas* canvas = encoder.beginFrame(); // your drawing code here, drawing into canvas encoder.endFrame();
Definition at line 304 of file SkVideoEncoder.cpp.
304 {
305 if (!fSurface) {
307 if (!fSurface) {
308 return nullptr;
309 }
310 }
314 return canvas;
315}
void clear(SkColor color)
void restoreToCount(int saveCount)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
◆ beginRecording()
bool SkVideoEncoder::beginRecording |
( |
SkISize |
dim, |
|
|
int |
fps |
|
) |
| |
Begins a new recording. Balance this (after adding all of your frames) with a call to endRecording().
Definition at line 228 of file SkVideoEncoder.cpp.
228 {
230 return false;
231 }
232
236 if (!this->init(fps)) {
237 return false;
238 }
239
240 fCurrentPTS = 0;
241 fDeltaPTS = 1;
242
245 SkASSERT(sws_isSupportedOutput(AV_PIX_FMT_YUV420P) > 0);
246
247
248
249
250 fSWScaleCtx = sws_getCachedContext(fSWScaleCtx,
253 SWS_FAST_BILINEAR, nullptr, nullptr, nullptr);
254 return fSWScaleCtx != nullptr;
255}
@ kOpaque_SkAlphaType
pixel is opaque
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
static SkString fmt(SkColor4f c)
constexpr int32_t width() const
constexpr int32_t height() const
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
◆ endFrame()
bool SkVideoEncoder::endFrame |
( |
| ) |
|
Definition at line 317 of file SkVideoEncoder.cpp.
317 {
318 if (!fSurface) {
319 return false;
320 }
323}
bool peekPixels(SkPixmap *pixmap)
bool addFrame(const SkPixmap &)
◆ endRecording()
Call this after having added all of your frames. After calling this, no more frames can be added to this recording. To record a new video, call beginRecording().
Definition at line 325 of file SkVideoEncoder.cpp.
325 {
326 if (!fFormatCtx) {
327 return nullptr;
328 }
329
330 this->sendFrame(nullptr);
331 av_write_trailer(fFormatCtx);
332
334 this->reset();
336}
std::shared_ptr< const fml::Mapping > data
The documentation for this class was generated from the following files: