Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/transcoder/src/transcoder_ffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ bool TranscoderFFmpeg::transcode(std::string input_path,
flag = true;
// free memory
end:
if (filters_ctx) {
for (int i = 0; i < (decoder ? decoder->fmtCtx->nb_streams : 0); i++) {
avfilter_graph_free(&filters_ctx[i].filter_graph);
}
av_free(filters_ctx);
filters_ctx = nullptr;
}
if (decoder && decoder->fmtCtx) {
avformat_close_input(&decoder->fmtCtx);
decoder->fmtCtx = NULL;
Expand Down Expand Up @@ -593,6 +600,7 @@ int TranscoderFFmpeg::encode_video(AVStream *inStream, AVFrame *frame) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
goto end;
}
av_frame_unref(frame);// because we use AV_BUFFERSRC_FLAG_KEEP_REF
/* pull filtered frames from the filtergraph */
while (1) {
if ((ret = av_buffersink_get_frame(fc->buffersink_ctx, frame)) == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
Expand All @@ -602,6 +610,7 @@ int TranscoderFFmpeg::encode_video(AVStream *inStream, AVFrame *frame) {
if (ret < 0)
goto end;
ret = encode_write_video(frame);
av_frame_unref(frame);
if (ret < 0)
goto end;
}
Expand Down Expand Up @@ -659,6 +668,7 @@ int TranscoderFFmpeg::encode_audio(AVStream *in_stream, AVFrame *frame) {
av_log(NULL, AV_LOG_ERROR, "Error while feeding the filtergraph\n");
goto end;
}
av_frame_unref(frame);// because we use AV_BUFFERSRC_FLAG_KEEP_REF
/* pull filtered frames from the filtergraph */
while (1) {
if ((ret = av_buffersink_get_frame(fc->buffersink_ctx, frame)) == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
Expand All @@ -668,6 +678,7 @@ int TranscoderFFmpeg::encode_audio(AVStream *in_stream, AVFrame *frame) {
if (ret < 0)
goto end;
ret = encode_write_audio(frame);
av_frame_unref(frame);
if (ret < 0)
goto end;
}
Expand Down Expand Up @@ -730,8 +741,6 @@ int TranscoderFFmpeg::transcode_video(bool skip_encode) {
if (decoder->pkt) {
av_packet_unref(decoder->pkt);
}

av_frame_unref(decoder->frame);
}

end:
Expand Down Expand Up @@ -765,7 +774,6 @@ int TranscoderFFmpeg::transcode_audio(bool skip_encode) {
if (decoder->pkt) {
av_packet_unref(decoder->pkt);
}
av_frame_unref(decoder->frame);
}
return ret;
}
Expand Down
Loading