Menu

Problems with videos with alpha channel

2014-08-19
2014-08-20
  • Konstanty Kalicki

    I started tinkering with alpha in videos and stumbled upons some problems. I'm using decoded images as textures in DX9 and it works great when I'm using TH_RGB flag. When I specify TH_ARGB frame width returned by TheoraVideoFrame::getWidth() gets halved. I can see this is by design, but I can't find any docs with info as to why. As a result my video is 2x narrower and overlaid.

    This is what I should get:
    alternate text

    This is what I get:
    alternate text

    The problem goes away when I specify TH_RGB but resurfaces in any format using alpha channel. I suspect that alpha is stored in some non standard way (maybe whole alpha frame appened after RGB buffer?).

    Any advice as to what I am doing wrong would be MUCH appreciated :-)

     
  • Krešimir Špes

    Krešimir Špes - 2014-08-19

    From what I can see, you're using an RGBA texture but don't need the alpha information from a video file? Libtheoraplayer has alpha channel support (see here: http://libtheoraplayer.cateia.com/wiki/index.php?title=Demo:Sprite_Animation) which by design halves the width of the clip.

    If you just want to paste your video over an RGBA texture, use TH_RGBX or TH_XBGR for directx.

    Did I understand your problem correctly?

     
  • Konstanty Kalicki

    Hey, thanks for quick reply! I already have working playback without alpha, now I actually want to use the alpha channel but weird stuff happens when I pass TH_RGBA flag. I have video rendered in 3DsMax with alpha channel and converted to theora with ffmpeg2theora-0.29.exe. When I decode it with TH_RGB everything is fine. When I switch to TH_RGBA I get 1/2 width and left and right sides are overlaid like on the screencaps I attached.

    Thanks for pointing that sample to me. I looked at it before but missed that single frame image. Does this means that in order to have alpha in my video I have to create every frame twice as wide as orginal and add greyscale alpha mask on the right side of the video?

    Like that in case of my cubes:
    alternate text
    ?

    I was under the impression, that theora can encode 32bit pixels.

     

    Last edit: Konstanty Kalicki 2014-08-19
  • Krešimir Špes

    Krešimir Špes - 2014-08-19

    yes, this is correct, all frames must include the alpha channel. and plus, you also have to ensure that the frame width is mod 16, otherwise you'll have overlapping problems, I have a fix for this but haven't inculded it yet because it induces performance problems.

     
  • Konstanty Kalicki

    Everything is working now, thanks!

     
  • Krešimir Špes

    Krešimir Špes - 2014-08-20

    excellent, glad to hear ;)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.