Opened 5 years ago
Closed 5 years ago
#8509 closed defect (fixed)
Converting 8 bit ARGB to Prores 4444 using prores_ks produces alpha channel that is not 100% opaque
Reported by: | Brian | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | swscale |
Version: | git-master | Keywords: | alpha |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
I am using ffmpeg to convert an 8bit ARGB source to Prores 4444 mov. Anywhere the alpha is 255 in the source; the output alpha when loading the resulting MOV file into after effects, the alpha comes out as 254 and has slight transparency. The RGB channels are all correctly 255.
Command Line:
ffmpeg -y -i "Viewport.tga" -c:v prores_ks -pix_fmt yuva444p10le -profile:v 4444 -alpha_bits 16 "Prores444.mov"
I will attach the input TGA file and can attach the output prores file also.
I've tested with both TGA input files, and RAW, so I know the issue is not with the input; it is something in the Prores output.
Using QTRLE for an output codec works fine; all alpha channel values are correct.
FFMPEG Output:
ffmpeg started on 2020-02-03 at 13:51:49 Report written to "ffmpeg-20200203-135149.log" Log level: 48 Command line: ffmpeg -y -i "d:\\TempProjects\\Viewport.tga" -c:v prores_ks -pix_fmt yuva444p10le -profile:v 4444 -alpha_bits 16 "d:\\tempprojects\\Prores444.mov" -report ffmpeg version git-2020-02-03-1c15111 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9.2.1 (GCC) 20200122 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf libavutil 56. 38.100 / 56. 38.100 libavcodec 58. 67.100 / 58. 67.100 libavformat 58. 37.100 / 58. 37.100 libavdevice 58. 9.103 / 58. 9.103 libavfilter 7. 73.100 / 7. 73.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Splitting the commandline. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-i' ... matched as input url with argument 'd:\TempProjects\Viewport.tga'. Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'prores_ks'. Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuva444p10le'. Reading option '-profile:v' ... matched as option 'profile' (set profile) with argument '4444'. Reading option '-alpha_bits' ... matched as AVOption 'alpha_bits' with argument '16'. Reading option 'd:\tempprojects\Prores444.mov' ... matched as output url. Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option report (generate a report) with argument 1. Successfully parsed a group of options. Parsing a group of options: input url d:\TempProjects\Viewport.tga. Successfully parsed a group of options. Opening an input file: d:\TempProjects\Viewport.tga. [NULL @ 0000026ca402ca80] Opening 'd:\TempProjects\Viewport.tga' for reading [file @ 0000026ca402da00] Setting default whitelist 'file,crypto,data' [image2 @ 0000026ca402ca80] Format image2 probed with size=2048 and score=50 [image2 @ 0000026ca402ca80] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1 [image2 @ 0000026ca402ca80] After avformat_find_stream_info() pos: 87738 bytes read:87738 seeks:0 frames:1 Input #0, image2, from 'd:\TempProjects\Viewport.tga': Duration: 00:00:00.04, start: 0.000000, bitrate: 17547 kb/s Stream #0:0, 1, 1/25: Video: targa, bgra, 1920x1080, 25 tbr, 25 tbn, 25 tbc Successfully opened the file. Parsing a group of options: output url d:\tempprojects\Prores444.mov. Applying option c:v (codec name) with argument prores_ks. Applying option pix_fmt (set pixel format) with argument yuva444p10le. Applying option profile:v (set profile) with argument 4444. Successfully parsed a group of options. Opening an output file: d:\tempprojects\Prores444.mov. [file @ 0000026ca403d240] Setting default whitelist 'file,crypto,data' Successfully opened the file. Stream mapping: Stream #0:0 -> #0:0 (targa (native) -> prores (prores_ks)) 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) detected 12 logical cores [graph 0 input from stream 0:0 @ 0000026ca403d880] Setting 'video_size' to value '1920x1080' [graph 0 input from stream 0:0 @ 0000026ca403d880] Setting 'pix_fmt' to value '28' [graph 0 input from stream 0:0 @ 0000026ca403d880] Setting 'time_base' to value '1/25' [graph 0 input from stream 0:0 @ 0000026ca403d880] Setting 'pixel_aspect' to value '0/1' [graph 0 input from stream 0:0 @ 0000026ca403d880] Setting 'frame_rate' to value '25/1' [graph 0 input from stream 0:0 @ 0000026ca403d880] w:1920 h:1080 pixfmt:bgra tb:1/25 fr:25/1 sar:0/1 [format @ 0000026ca4098c40] Setting 'pix_fmts' to value 'yuva444p10le' [auto_scaler_0 @ 0000026ca4099200] Setting 'flags' to value 'bicubic' [auto_scaler_0 @ 0000026ca4099200] w:iw h:ih flags:'bicubic' interl:0 [format @ 0000026ca4098c40] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format' [AVFilterGraph @ 0000026ca4096ec0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed [auto_scaler_0 @ 0000026ca4099200] w:1920 h:1080 fmt:bgra sar:0/1 -> w:1920 h:1080 fmt:yuva444p10le sar:0/1 flags:0x4 [prores_ks @ 0000026ca40c1940] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca40c1940] frame size upper bound: 33813678 [prores_ks @ 0000026ca404fcc0] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca404fcc0] frame size upper bound: 33813678 [prores_ks @ 0000026ca4911f00] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4911f00] frame size upper bound: 33813678 [prores_ks @ 0000026ca491db80] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca491db80] frame size upper bound: 33813678 [prores_ks @ 0000026ca4929800] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4929800] frame size upper bound: 33813678 [prores_ks @ 0000026ca4935680] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4935680] frame size upper bound: 33813678 [prores_ks @ 0000026ca4947d00] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4947d00] frame size upper bound: 33813678 [prores_ks @ 0000026ca4953b80] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4953b80] frame size upper bound: 33813678 [prores_ks @ 0000026ca495fa00] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca495fa00] frame size upper bound: 33813678 [prores_ks @ 0000026ca496b840] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca496b840] frame size upper bound: 33813678 [prores_ks @ 0000026ca4978600] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4978600] frame size upper bound: 33813678 [prores_ks @ 0000026ca4984d40] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4984d40] frame size upper bound: 33813678 [prores_ks @ 0000026ca4037240] profile 4, 1020 slices, interlacing: no, 28500 bits per MB [prores_ks @ 0000026ca4037240] frame size upper bound: 33813678 Output #0, mov, to 'd:\tempprojects\Prores444.mov': Metadata: encoder : Lavf58.37.100 Stream #0:0, 0, 1/12800: Video: prores (prores_ks) (ap4h / 0x68347061), yuva444p10le, 1920x1080, q=2-31, 200 kb/s, 25 fps, 12800 tbn, 25 tbc Metadata: encoder : Lavc58.67.100 prores_ks Clipping frame in rate conversion by 0.000008 cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) cur_dts is invalid st:0 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream) [out_0_0 @ 0000026ca4098a80] EOF on sink link out_0_0:default. No more output streams to write to, finishing. frame= 1 fps=0.0 q=-0.0 Lsize= 50kB time=00:00:00.00 bitrate=5273025.6kbits/s speed=0.000222x video:49kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.432348% Input file #0 (d:\TempProjects\Viewport.tga): Input stream #0:0 (video): 1 packets read (87738 bytes); 1 frames decoded; Total: 1 packets (87738 bytes) demuxed Output file #0 (d:\tempprojects\Prores444.mov): Output stream #0:0 (video): 1 frames encoded; 1 packets muxed (50686 bytes); Total: 1 packets (50686 bytes) muxed 1 frames successfully decoded, 0 decoding errors [AVIOContext @ 0000026ca4096040] Statistics: 2 seeks, 4 writeouts [AVIOContext @ 0000026ca4035c80] Statistics: 87738 bytes read, 0 seeks
Attachments (2)
Change History (16)
by , 5 years ago
Attachment: | Viewport.tga added |
---|
comment:1 by , 5 years ago
Summary: | Converting 8 bit ARGB to Prores 4444 using prores_ks produces alpha channel that is not 100% → Converting 8 bit ARGB to Prores 4444 using prores_ks produces alpha channel that is not 100% opaque |
---|
comment:2 by , 5 years ago
Description: | modified (diff) |
---|---|
Keywords: | prores added; prores_ks removed |
Version: | 4.2 → git-master |
Isn't this a duplicate of ticket #979?
comment:3 by , 5 years ago
I dont think so. The alpha channel itself should not be undergoing any color space conversion.
The RGB components would convert to YUV and back; but the Alpha should not be affected.
It would however undergo an 8bit to 16bit conversion as I believe it is being stored as 16bit in the output file, and that could be where the issue comes from.
comment:4 by , 5 years ago
Replying to bford:
> Using QTRLE for an output codec works fine; all alpha channel values are correct.
Does -vf format=argb
help?
comment:5 by , 5 years ago
Does the following inlined change make a difference?
diff --git a/libswscale/input.c b/libswscale/input.c index 159f70307d..701586be27 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -446,7 +446,7 @@ static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, int16_t *dst = (int16_t *)_dst; int i; for (i=0; i<width; i++) { - dst[i]= src[4*i+3]<<6; + dst[i]= src[4*i+3]<<6 | src[4*i+3]>>2; } }
comment:6 by , 5 years ago
Yes, that resolves the issue!
I think I can see what you've done there.. 255 << 6 = 16320 (not 16384), so you have to account for the difference by adding (255 >> 2) = 63.
Thank you very much for investigating this for me!
follow-up: 8 comment:7 by , 5 years ago
I'm assuming the same change would be applied to abgrToA_c() as well.
Will you submit the patch to the mailing list?
follow-ups: 9 13 comment:8 by , 5 years ago
Component: | avcodec → swscale |
---|
comment:9 by , 5 years ago
Status: | new → open |
---|
Replying to cehoyos:
Replying to bford:
Will you submit the patch to the mailing list?
Next week.
And also palToA_c().
https://patchwork.ffmpeg.org/project/ffmpeg/patch/CAB0OVGqPcdiR=xoHtBXrSxrRJ0tC8XQ58nj1n1sy1nYTh1ZzEw@mail.gmail.com/
follow-up: 11 comment:10 by , 5 years ago
I can't figure out how to comment on the patch, but should this line of the patch:
dst[i]= (pal[d] >> 24)<<6 | pal[d]>>2;
become:
dst[i]= (pal[d] >> 24)<<6 | ((pal[d] >> 24) >> 2);
?
comment:11 by , 5 years ago
Replying to bford:
I can't figure out how to comment on the patch, but should this line of the patch:
dst[i]= (pal[d] >> 24)<<6 | pal[d]>>2;
become:
dst[i]= (pal[d] >> 24)<<6 | ((pal[d] >> 24) >> 2);
?
Aleady was noticed https://patchwork.ffmpeg.org/comment/51189/
comment:12 by , 5 years ago
Could the patch be applied without the change to palToA_c() so that this specific bug can be resolved? The change to palToA_c() is not required to fix this bug report.
comment:13 by , 5 years ago
Replying to cehoyos:
Replying to bford:
Will you submit the patch to the mailing list?
Next week.
https://patchwork.ffmpeg.org/comment/51538/ New patch attached, where?))
comment:14 by , 5 years ago
Keywords: | alpha added; prores removed |
---|---|
Resolution: | → fixed |
Status: | open → closed |
Should be fixed in 5f8c38345247be4baa6d6f0b4ef5f5ce94c1ba7d
Input file with alpha=255