MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / encode_write_frame

Function encode_write_frame

doc/examples/transcode.c:463–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461}
462
463static int encode_write_frame(unsigned int stream_index, int flush)
464{
465 StreamContext *stream = &stream_ctx[stream_index];
466 FilteringContext *filter = &filter_ctx[stream_index];
467 AVFrame *filt_frame = flush ? NULL : filter->filtered_frame;
468 AVPacket *enc_pkt = filter->enc_pkt;
469 int ret;
470
471 av_log(NULL, AV_LOG_INFO, "Encoding frame\n");
472 /* encode filtered frame */
473 av_packet_unref(enc_pkt);
474
475 if (filt_frame && filt_frame->pts != AV_NOPTS_VALUE)
476 filt_frame->pts = av_rescale_q(filt_frame->pts, filt_frame->time_base,
477 stream->enc_ctx->time_base);
478
479 ret = avcodec_send_frame(stream->enc_ctx, filt_frame);
480
481 if (ret < 0)
482 return ret;
483
484 while (ret >= 0) {
485 ret = avcodec_receive_packet(stream->enc_ctx, enc_pkt);
486
487 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
488 return 0;
489
490 /* prepare packet for muxing */
491 enc_pkt->stream_index = stream_index;
492 av_packet_rescale_ts(enc_pkt,
493 stream->enc_ctx->time_base,
494 ofmt_ctx->streams[stream_index]->time_base);
495
496 av_log(NULL, AV_LOG_DEBUG, "Muxing frame\n");
497 /* mux encoded frame */
498 ret = av_interleaved_write_frame(ofmt_ctx, enc_pkt);
499 }
500
501 return ret;
502}
503
504static int filter_encode_write_frame(AVFrame *frame, unsigned int stream_index)
505{

Callers 2

flush_encoderFunction · 0.85

Calls 7

av_logFunction · 0.85
av_packet_unrefFunction · 0.85
av_rescale_qFunction · 0.85
avcodec_send_frameFunction · 0.85
avcodec_receive_packetFunction · 0.85
av_packet_rescale_tsFunction · 0.85

Tested by

no test coverage detected