MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ drain_packets()

bool MayaFlux::IO::VideoEncodeContext::drain_packets ( FFmpegMuxContext mux)
private

Definition at line 343 of file VideoEncodeContext.cpp.

344{
345 AVPacket* pkt = av_packet_alloc();
346 if (!pkt) {
347 m_last_error = "av_packet_alloc failed";
348 return false;
349 }
350
351 bool ok = true;
352 while (true) {
353 int ret = avcodec_receive_packet(codec_context, pkt);
354 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
355 break;
356 if (ret < 0) {
357 char errbuf[AV_ERROR_MAX_STRING_SIZE];
358 av_strerror(ret, errbuf, sizeof(errbuf));
359 m_last_error = std::string("avcodec_receive_packet failed: ") + errbuf;
360 ok = false;
361 break;
362 }
363
364 pkt->stream_index = m_stream_index;
365 av_packet_rescale_ts(pkt,
366 codec_context->time_base,
367 m_stream->time_base);
368
369 if (!mux.write_packet(pkt)) {
370 m_last_error = mux.last_error();
371 ok = false;
372 break;
373 }
374
375 av_packet_unref(pkt);
376 }
377
378 av_packet_free(&pkt);
379 return ok;
380}
AVStream * m_stream
Weak ref into FFmpegMuxContext; not owned.
AVCodecContext * codec_context
Owned; freed in destructor.

References codec_context, MayaFlux::IO::FFmpegMuxContext::last_error(), m_last_error, m_stream, m_stream_index, and MayaFlux::IO::FFmpegMuxContext::write_packet().

Referenced by drain(), and encode_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: