[Libav-user] Scale filter converting to grayscale

Philippe Gorley philippe.gorley at savoirfairelinux.com
Mon Apr 30 22:10:57 EEST 2018


I'm having trouble getting filters to work correctly. It creates dummy 
YUV frames, scales them using libavfilter, and saves the raw data to 
disk (heavily based on filtering_video.c). The end goal is to use 
libavfilter instead of implementing such things ourselves.

It segfaults when writing the frame. I'm expecting a yuv420p frame, but 
the filtered frame is in grayscale (AV_PIX_FMT_GRAY8), even though I 
specify yuv420p in the filter string (scale=w=200:h=100:dst_format=0).

Here is the code: https://pastebin.com/rNegZcng
I'm on FFmpeg master (commit cae6f806a6367c7760ab6ed059d343d4a8eebd56).

And here are the logs I'm getting:
detected 4 logical cores
[in @ 0x1e41200] Setting 'video_size' to value '320x240'
[in @ 0x1e41200] Setting 'pix_fmt' to value '0'
[in @ 0x1e41200] Setting 'time_base' to value '1/1'
[in @ 0x1e41200] Setting 'pixel_aspect' to value '1/1'
[in @ 0x1e41200] w:320 h:240 pixfmt:yuv420p tb:1/1 fr:0/1 sar:1/1 sws_param:
[Parsed_scale_0 @ 0x1e42280] Setting 'w' to value '200'
[Parsed_scale_0 @ 0x1e42280] Setting 'h' to value '100'
[Parsed_scale_0 @ 0x1e42280] Setting 'dst_format' to value '0'
[Parsed_scale_0 @ 0x1e42280] w:200 h:100 flags:'bilinear' interl:0
[AVFilterGraph @ 0x1e407c0] query_formats: 3 queried, 2 merged, 0 
already done, 0 delayed
[Parsed_scale_0 @ 0x1e42280] w:320 h:240 fmt:yuv420p sar:1/1 -> w:200 
h:100 fmt:gray sar:2/3 flags:0x2
[Parsed_scale_0 @ 0x1e42280] w:320 h:240 fmt:yuv420p sar:0/1 -> w:200 
h:100 fmt:gray sar:0/1 flags:0x2
[swscaler @ 0x1e42f80] bad dst image pointers
Frame scaled from 320x240 to 200x100
Segmentation fault

#0  __mempcpy_sse2 () at ../sysdeps/x86_64/memcpy.S:196
#1  0x00007ffff7364242 in _IO_new_file_xsputn (f=0x635430, data=0x0, 
n=0x64) at fileops.c:1319
#2  0x00007ffff73597bb in __GI__IO_fwrite (buf=0x0, size=0x64, 
count=0x1, fp=0x635430) at iofwrite.c:39
#3  0x000000000040114b in save_yuv_frame (frame=0x604040, 
frame_number=0x0) at video_filter.c:52
#4  0x0000000000401a4f in main (argc=0x1, argv=0x7fffffffda48) at 

Any tips on what I'm doing wrong and why libavfilter is converting my 
frame to AV_PIX_FMT_GRAY8?


Philippe Gorley
Free Software Consultant | Montréal, Qc
Savoir-faire Linux

Confidentiality Message: This communication (including any files
transmitted with it) is intended solely for the person or entity to
whom it is addressed, and may contain confidential or privileged
The disclosure, distribution or copying of this message is strictly
forbidden. Should you have received this communication in error,
kindly contact the sender promptly, destroy any copies and delete
this message from your computer system.

More information about the Libav-user mailing list