[FFmpeg-cvslog] fftools/ffmpeg_enc: factorize calling enc_init()

Anton Khirnov git at videolan.org
Sun Apr 9 16:50:47 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Mar 25 20:13:34 2023 +0100| [f098eaee56b5dd7707b572f9fd0512f8bc72ed77] | committer: Anton Khirnov

fftools/ffmpeg_enc: factorize calling enc_init()

It is done in the same way for both audio and video, so can be moved to
enc_frame().

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f098eaee56b5dd7707b572f9fd0512f8bc72ed77
---

 fftools/ffmpeg_enc.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 1387e05cf6..2f1803a74c 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -762,10 +762,6 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
     AVCodecContext *enc = ost->enc_ctx;
     int ret;
 
-    ret = enc_open(ost, frame);
-    if (ret < 0)
-        exit_program(1);
-
     if (frame->pts == AV_NOPTS_VALUE)
         frame->pts = ost->next_pts;
     else {
@@ -967,10 +963,6 @@ static void do_video_out(OutputFile *of,
     InputStream *ist = ost->ist;
     AVFilterContext *filter = ost->filter->filter;
 
-    ret = enc_open(ost, next_picture);
-    if (ret < 0)
-        exit_program(1);
-
     frame_rate = av_buffersink_get_frame_rate(filter);
     if (frame_rate.num > 0 && frame_rate.den > 0)
         duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
@@ -1062,6 +1054,11 @@ static void do_video_out(OutputFile *of,
 void enc_frame(OutputStream *ost, AVFrame *frame)
 {
     OutputFile *of = output_files[ost->file_index];
+    int ret;
+
+    ret = enc_open(ost, frame);
+    if (ret < 0)
+        exit_program(1);
 
     if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame);
     else                                                do_audio_out(of, ost, frame);



More information about the ffmpeg-cvslog mailing list