[FFmpeg-user] Cant find proper code for using complex filter and overlay with VAAPI

KoreanFanOfficial koreanfanofficial at gmail.com
Mon Jun 8 02:37:36 EEST 2020


For record with vaapi i use command:

---->DRI_PRIME=1 LIBVA_DRIVER_NAME=radeonsi ffmpeg -y -hwaccel vaapi
-vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
-framerate 30 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -ac 2 -i
default \
-vf 'hwupload,scale_vaapi=w=1280:h=720:format=nv12' \
-vcodec h264_vaapi -g 60 -sei identifier+timing+recovery_point \
-bsf:v extract_extradata -b:v 3M -maxrate 3M -bf 0 -movflags +faststart
-c:a aac -b:a 128k -ar 44100 \
-f flv vaapi.flv<---- and it works.

---->Try use complex filter with vaapi:
DRI_PRIME=1 LIBVA_DRIVER_NAME=radeonsi ffmpeg -y -hwaccel vaapi
-vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
-framerate 30 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -ac 2 -i
default \
-filter_complex \
"[0:v]hwupload,scale_vaapi=w=1280:h=720:format=nv12,setpts=PTS-STARTPTS[bg]"
\
-map "[bg]" -map 1:a -c:v h264_vaapi -g 60 -sei
identifier+timing+recovery_point \
-bsf:v extract_extradata -b:v 3M -maxrate 3M -bf 0 -movflags +faststart
-c:a aac -b:a 128k -ar 44100 \
-f flv vaapi_complex.flv<---- and it works.

Try use complex filter with vaapi and overlay
1)DRI_PRIME=1 LIBVA_DRIVER_NAME=radeonsi ffmpeg -y -loglevel debug -hwaccel
vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \
-framerate 30 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -ac 2 -i
default -i logo.png \
-filter_complex \
"[0:v]hwupload,scale_vaapi=w=1280:h=720:format=nv12,setpts=PTS-STARTPTS[bg];
\
[bg][2:v]overlay=0:H-h[bg2]" \
-map "[bg2]" -map 1:a -c:v h264_vaapi -g 60 -sei
identifier+timing+recovery_point \
-bsf:v extract_extradata -b:v 3M -maxrate 3M -bf 0 -movflags +faststart
-c:a aac -b:a 128k -ar 44100 \
-f flv test1.flv and i got error:

---->DRI_PRIME=1 LIBVA_DRIVER_NAME=radeonsi ffmpeg -y -loglevel debug
-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format
vaapi \
> -framerate 30 -video_size 1920x1080 -f x11grab -i :0.0 -f pulse -ac 2 -i
default -i logo.png \
> -filter_complex \
>
"[0:v]hwupload,scale_vaapi=w=1280:h=720:format=nv12,setpts=PTS-STARTPTS[bg];
\
> [bg][2:v]overlay=0:H-h[bg2]" \
> -map "[bg2]" -map 1:a -c:v h264_vaapi -g 60 -sei
identifier+timing+recovery_point \
> -bsf:v extract_extradata -b:v 3M -maxrate 3M -bf 0 -movflags +faststart
-c:a aac -b:a 128k -ar 44100 \
> -f flv test1.flv
ffmpeg version n4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.1.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static
--disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp
--enable-gnutls --enable-gpl --enable-ladspa --enable-libaom
--enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm
--enable-libfreetype --enable-libfribidi --enable-libgsm
--enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug
--enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr
--enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora
--enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
--enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec
--enable-nvenc --enable-omx --enable-shared --enable-version3
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with
argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging
level) with argument 'debug'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW
accelerated decoding) with argument 'vaapi'.
Reading option '-vaapi_device' ... matched as option 'vaapi_device' (set
VAAPI hardware device (DRM path or X11 display name)) with argument
'/dev/dri/renderD128'.
Reading option '-hwaccel_output_format' ... matched as option
'hwaccel_output_format' (select output format used with HW accelerated
decoding) with argument 'vaapi'.
Reading option '-framerate' ... matched as AVOption 'framerate' with
argument '30'.
Reading option '-video_size' ... matched as AVOption 'video_size' with
argument '1920x1080'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'x11grab'.
Reading option '-i' ... matched as input url with argument ':0.0'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'pulse'.
Reading option '-ac' ... matched as option 'ac' (set number of audio
channels) with argument '2'.
Reading option '-i' ... matched as input url with argument 'default'.
Reading option '-i' ... matched as input url with argument 'logo.png'.
Reading option '-filter_complex' ... matched as option 'filter_complex'
(create a complex filtergraph) with argument
'[0:v]hwupload,scale_vaapi=w=1280:h=720:format=nv12,setpts=PTS-STARTPTS[bg];
[bg][2:v]overlay=0:H-h[bg2]'.
Reading option '-map' ... matched as option 'map' (set input stream
mapping) with argument '[bg2]'.
Reading option '-map' ... matched as option 'map' (set input stream
mapping) with argument '1:a'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument
'h264_vaapi'.
Reading option '-g' ... matched as AVOption 'g' with argument '60'.
Reading option '-sei' ... matched as AVOption 'sei' with argument
'identifier+timing+recovery_point'.
Reading option '-bsf:v' ... matched as option 'bsf' (A comma-separated list
of bitstream filters) with argument 'extract_extradata'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '3M'.
Reading option '-maxrate' ... matched as AVOption 'maxrate' with argument
'3M'.
Reading option '-bf' ... matched as AVOption 'bf' with argument '0'.
Reading option '-movflags' ... matched as AVOption 'movflags' with argument
'+faststart'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument
'aac'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use
-b:v)) with argument '128k'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate
(in Hz)) with argument '44100'.
Reading option '-f' ... matched as option 'f' (force format) with argument
'flv'.
Reading option 'test1.flv' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option vaapi_device (set VAAPI hardware device (DRM path or X11
display name)) with argument /dev/dri/renderD128.
[AVHWDeviceContext @ 0x557b57709b80] libva: VA-API version 1.7.0
[AVHWDeviceContext @ 0x557b57709b80] libva: User environment variable
requested driver 'radeonsi'
[AVHWDeviceContext @ 0x557b57709b80] libva: Trying to open
/usr/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x557b57709b80] libva: Found init function
__vaDriverInit_1_7
[AVHWDeviceContext @ 0x557b57709b80] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x557b57709b80] Initialised VAAPI connection: version
1.7
[AVHWDeviceContext @ 0x557b57709b80] Format 0x3231564e -> nv12.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x30313050 -> p010le.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x36313050 -> unknown.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x30323449 -> yuv420p.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x32315659 -> yuv420p.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x56595559 -> unknown.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x59565955 -> uyvy422.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x41524742 -> bgra.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x41424752 -> rgba.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x58524742 -> bgr0.
[AVHWDeviceContext @ 0x557b57709b80] Format 0x58424752 -> rgb0.
[AVHWDeviceContext @ 0x557b57709b80] VAAPI driver: Mesa Gallium driver
20.0.7 for Radeon RX 560 Series (POLARIS11, DRM 3.36.0, 5.6.15-1-MANJARO,
LLVM 10.0.0).
[AVHWDeviceContext @ 0x557b57709b80] Driver not found in known nonstandard
list, using standard behaviour.
Applying option filter_complex (create a complex filtergraph) with argument
[0:v]hwupload,scale_vaapi=w=1280:h=720:format=nv12,setpts=PTS-STARTPTS[bg];
[bg][2:v]overlay=0:H-h[bg2].
Successfully parsed a group of options.
Parsing a group of options: input url :0.0.
Applying option hwaccel (use HW accelerated decoding) with argument vaapi.
Applying option hwaccel_output_format (select output format used with HW
accelerated decoding) with argument vaapi.
Applying option f (force format) with argument x11grab.
Successfully parsed a group of options.
Opening an input file: :0.0.
[x11grab @ 0x557b57953b80] Probe buffer size limit of 5000000 bytes reached
[x11grab @ 0x557b57953b80] Stream #0: not enough frames to estimate rate;
consider increasing probesize
Input #0, x11grab, from ':0.0':
  Duration: N/A, start: 1591571915.754162, bitrate: N/A
    Stream #0:0, 1, 1/1000000: Video: rawvideo, 1 reference frame (BGR[0] /
0x524742), bgr0, 1920x1080, 0/1, 30 fps, 1000k tbr, 1000k tbn, 1000k tbc
Successfully opened the file.
Parsing a group of options: input url default.
Applying option f (force format) with argument pulse.
Applying option ac (set number of audio channels) with argument 2.
Successfully parsed a group of options.
Opening an input file: default.
[pulse @ 0x557b57904340] All info found
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'default':
  Duration: N/A, start: 1591571915.813984, bitrate: 1536 kb/s
    Stream #1:0, 1, 1/1000000: Audio: pcm_s16le, 48000 Hz, stereo, s16,
1536 kb/s
Successfully opened the file.
Parsing a group of options: input url logo.png.
Successfully parsed a group of options.
Opening an input file: logo.png.
[NULL @ 0x557b578ecc80] Opening 'logo.png' for reading
[file @ 0x557b5789b5c0] Setting default whitelist 'file,crypto'
[png_pipe @ 0x557b578ecc80] Format png_pipe probed with size=2048 and
score=99
[png_pipe @ 0x557b578ecc80] Before avformat_find_stream_info() pos: 0 bytes
read:32768 seeks:0 nb_streams:1
[png_pipe @ 0x557b578ecc80] After avformat_find_stream_info() pos: 80378
bytes read:80378 seeks:0 frames:1
Input #2, png_pipe, from 'logo.png':
  Duration: N/A, bitrate: N/A
    Stream #2:0, 1, 1/25: Video: png, 1 reference frame, rgb24(pc),
244x243, 0/1, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
[Parsed_scale_vaapi_1 @ 0x557b578ed280] Setting 'w' to value '1280'
[Parsed_scale_vaapi_1 @ 0x557b578ed280] Setting 'h' to value '720'
[Parsed_scale_vaapi_1 @ 0x557b578ed280] Setting 'format' to value 'nv12'
[Parsed_setpts_2 @ 0x557b578fe780] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_overlay_3 @ 0x557b57898440] Setting 'x' to value '0'
[Parsed_overlay_3 @ 0x557b57898440] Setting 'y' to value 'H-h'
Parsing a group of options: output url test1.flv.
Applying option map (set input stream mapping) with argument [bg2].
Applying option map (set input stream mapping) with argument 1:a.
Applying option c:v (codec name) with argument h264_vaapi.
Applying option bsf:v (A comma-separated list of bitstream filters) with
argument extract_extradata.
Applying option b:v (video bitrate (please use -b:v)) with argument 3M.
Applying option c:a (codec name) with argument aac.
Applying option b:a (video bitrate (please use -b:v)) with argument 128k.
Applying option ar (set audio sampling rate (in Hz)) with argument 44100.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: test1.flv.
[file @ 0x557b57884a40] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 8 logical cores
Stream mapping:
  Stream #0:0 (rawvideo) -> hwupload (graph 0)
  Stream #2:0 (png) -> overlay:overlay (graph 0)
  overlay (graph 0) -> Stream #0:0 (h264_vaapi)
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if
it occurs once at the start per stream)
[rawvideo @ 0x557b5787d3c0] PACKET SIZE: 8294400, STRIDE: 7680
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if
it occurs once at the start per stream)
    Last message repeated 1 times
[Parsed_scale_vaapi_1 @ 0x557b57884d40] Setting 'w' to value '1280'
[Parsed_scale_vaapi_1 @ 0x557b57884d40] Setting 'h' to value '720'
[Parsed_scale_vaapi_1 @ 0x557b57884d40] Setting 'format' to value 'nv12'
[Parsed_setpts_2 @ 0x557b57815740] Setting 'expr' to value 'PTS-STARTPTS'
[Parsed_overlay_3 @ 0x557b57986e40] Setting 'x' to value '0'
[Parsed_overlay_3 @ 0x557b57986e40] Setting 'y' to value 'H-h'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'video_size' to
value '1920x1080'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'pix_fmt' to value
'123'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'time_base' to
value '1/1000000'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'pixel_aspect' to
value '0/1'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'sws_param' to
value 'flags=2'
[graph 0 input from stream 0:0 @ 0x557b57987a00] Setting 'frame_rate' to
value '30/1'
[graph 0 input from stream 0:0 @ 0x557b57987a00] w:1920 h:1080 pixfmt:bgr0
tb:1/1000000 fr:30/1 sar:0/1 sws_param:flags=2
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'video_size' to
value '244x243'
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'pix_fmt' to value
'2'
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'time_base' to
value '1/25'
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'pixel_aspect' to
value '0/1'
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'sws_param' to
value 'flags=2'
[graph 0 input from stream 2:0 @ 0x557b57988900] Setting 'frame_rate' to
value '25/1'
[graph 0 input from stream 2:0 @ 0x557b57988900] w:244 h:243 pixfmt:rgb24
tb:1/25 fr:25/1 sar:0/1 sws_param:flags=2
[format @ 0x557b57815640] Setting 'pix_fmts' to value 'vaapi_vld'
[auto_scaler_0 @ 0x557b5788aa40] w:iw h:ih flags:'bilinear' interl:0
[Parsed_overlay_3 @ 0x557b57986e40] auto-inserting filter 'auto_scaler_0'
between the filter 'Parsed_setpts_2' and the filter 'Parsed_overlay_3'
Impossible to convert between the formats supported by the filter
'Parsed_setpts_2' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #2:0
[AVIOContext @ 0x557b57884c00] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x557b5789b640] Statistics: 80378 bytes read, 0 seeks
Conversion failed!<----


2)test command 1) with libx264
ffmpeg -y -f x11grab -video_size 1920x1080 -framerate 30 -i :0.0+0,0 \
-f pulse -ac 2 -i default -i logo.png -filter_complex \
"[0:v]scale=1280:-1,setpts=PTS-STARTPTS[bg]; \
[bg][2:v]overlay=0:H-h[bg2]" \
-map "[bg2]" -map 1:a -c:v libx264 -g 60 -preset ultrafast \
-b:v 3M -maxrate 3M -c:a aac -b:a 128k -ar 44100 \
-f flv test2.flv and it works with libx264


пн, 8 июн. 2020 г. в 02:01, Ted Park <kumowoon1025 at gmail.com>:

> Hi there,
>
> > Always i got error:
> > ---->Impossible to convert between the formats supported by the filter
> > 'Parsed_format_' and the filter 'auto_scaler_' Error reinitializing
> > filters! Failed to inject frame into filter network: Function not
> > implemented
>
> There is an automatic format conversion being attempted that is not
> happening. What is the input format of x11grab? The command is too
> complicated right now to investigate efficiently. Can you try a simple
> screen capture and single overlay with increased verbosity (-loglevel
> debug)?
>
> Regards,
> Ted Park
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list