-
Notifications
You must be signed in to change notification settings - Fork 19
Description
OS: CentOS Linux release 7.2.1511 (Core)
CPU: i7-6770HQ
MSDK: 2017
repository: branch intel_plugins-3.3.1
I'm trying to follow the gop struct of the input, but few data written to output seconds later.
step 1:
blew command works well:
./ffmpeg_g -i "http://192.168.86.26:9000/live/s1_720p.flv" -vcodec h264_qsv -vsync passthrough -b:v 2000k -g 500 -async_depth 4 -acodec copy -f flv -y ~/output.flv
step 2:
modiry ffmpeg.c to keep picture type AV_PICTURE_TYPE_I
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1236,6 +1236,8 @@ static void do_video_out(OutputFile *of,
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
++ if (in_picture->key_frame)
++ in_picture->pict_type = AV_PICTURE_TYPE_I;
and force idr:
./ffmpeg_g -i "http://192.168.86.26:9000/live/s1_720p.flv" -vcodec h264_qsv -vsync passthrough -force_idr 1 -b:v 2000k -g 500 -async_depth 4 -acodec copy -f flv -y ~/output.flv
after ffmpeg start a few seconds, output file ~/output.flv grows very slow.
do some work:
1, print q->async_fifo size:
q->async_fifo grows double in step 2:520,1040,2080,4160... ...,66560,133120,266240
only when q->async_fifo has no space, qsvenc read data from q->async_fifo and output them.
2, why q->async_fifo grows very quickly?
modify code in libavutil/fifo.c:
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -113,7 +113,7 @@ int av_fifo_grow(AVFifoBuffer f, unsigned int size)
size += av_fifo_size(f);
if (old_size < size)
-- return av_fifo_realloc2(f, FFMAX(size, 2old_size));
++ return av_fifo_realloc2(f, FFMIN(size, 2*old_size));
return 0;
}
q->async_fifo grows slowly, and in step 2, output file ~/output.flv grows normally.
3, if q->async_fifo has more than ASYNC_FIFO_ELEM_SIZE data, qsvenc read data from q->async_fifo
modify libavcode/qsvenc.c
@@ -1253,15 +1258,18 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
if (ret < 0)
return ret;
-- if (!av_fifo_space(q->async_fifo) ||
++ if ((frame && ASYNC_FIFO_ELEM_SIZE < av_fifo_size(q->async_fifo)) ||
(!frame && av_fifo_size(q->async_fifo))) {
AVPacket new_pkt;
mfxBitstream *bs;
mfxSyncPoint *sync;
in step 2, output file ~/output.flv grows normally, and q->async_fifo keep it's size.
questions:
1, why q->async_fifo always keep growing when force idr enabled?
2, why qsvenc read data from q->async_fifo only when q->async_fifo has no space?