Opened 8 years ago

Closed 8 years ago

#5734 closed defect (invalid)

Coherent support to VP8 with alpha channel

Reported by: cdlvcdlv Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

You can retrieve alpha channel from any video format, except VP8/webm.

% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v libvpx -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" bouncing_ball_with_alpha.webm
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v qtrle -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" bouncing_ball_with_alpha.webm

ffmpeg version - all

The problem is that ffmpeg and ffplay ignore the encoded alpha channel (that I think is encoded in the container webm, i.e. matroska).

You can use any video with alpha (lagarith, qtrle, huffyuv...) and transcode from one to another, given that some of them can only be decoded but not encoded: you can transcode from lagarith to qtrle but no the other way round. In any case, the alpha channel is never lost unless you specify it to be discarded.

But if you use VP8/webm, you will not be able to make further transcodings and retain the transparency. If you deleted the original, your alpha channel is there, but in a black hole. The only way I know to show it is there is using Chrome (I think Opera too, but I have not tested it). I suppose that how they do it is in the source code of Chromium.

I have read it is difficult (see link below and its response). But, is it true what he says: "In a simple test, I passed AV_PIX_FMT_YUVA420P to avpicture_alloc() and was able to get the linesize[] and data[] filled correctly for a YUVA picture"?

http://mplayerhq.hu/pipermail/ffmpeg-user/2014-September/023436.html

To date, there's no tool that can retrieve alpha channel in a webm video.

http://superuser.com/questions/1044453/extract-alpha-channel-from-webm-video

Change History (6)

comment:1 by cdlvcdlv, 8 years ago

Sorry, the second command should be:
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v qtrle bouncing_ball_with_alpha.mov

comment:2 by Carl Eugen Hoyos, 8 years ago

Resolution: needs_more_info
Status: newclosed

This works fine here with libvpx.
Please reopen this ticket if you can reproduce with current FFmpeg git head and if you can provide both command line(s) and complete, uncut console output.

comment:3 by Ronald S. Bultje, 8 years ago

I think he wants to default to libvpx for vp8a (not vp8) until the native decoder has alpha support, or alternatively add alpha support to the native decoder also.

comment:4 by cdlvcdlv, 8 years ago

Resolution: needs_more_info
Status: closedreopened

1.- Generate webm with alpha.
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v libvpx -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" bouncing_ball_with_alpha.webm
2.- Generate qtrle with alpha.
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v qtrle bouncing_ball_with_alpha.mov
3.- Generate huffyuv with alpha.
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png -c:v huffyuv bouncing_ball_with_alpha.avi
4.- Create a background video.
% ffmpeg -i https://upload.wikimedia.org/wikipedia/commons/e/e6/Typing_example.ogv -ss 0 -t 5 -c copy -map 0 background.ogv
5.- Test the three videos over background:
% ffplay -i background.ogv -vf "movie=bouncing_ball_with_alpha.mov[ov]; [in][ov]overlay"
% ffplay -i background.ogv -vf "movie=bouncing_ball_with_alpha.avi[ov]; [in][ov]overlay"
% ffplay -i background.ogv -vf "movie=bouncing_ball_with_alpha.webm[ov]; [in][ov]overlay"

Results:
Qtrle: right
https://i.imgsafe.org/6535b63d1d.png
Huffyuv: right
https://i.imgsafe.org/6527f9c1ce.png
Webm: wrong
https://i.imgsafe.org/6538bf089a.png

Version used: Zeranoe build N-80999-gf41e37b

comment:5 by cdlvcdlv, 8 years ago

I've found this recent thread. Will this patch be added to ffmpeg? It would solve the issue.
http://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/196403.html

comment:6 by Carl Eugen Hoyos, 8 years ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.