collinsmith / riiablo

Diablo II remade using Java and LibGDX
http://riiablo.com
Apache License 2.0
872 stars 99 forks source link

add support for videos #59

Open collinsmith opened 5 years ago

collinsmith commented 5 years ago

Format for video files are bink video (.bik) which is supported by ffmpeg. Existing library gdx-video uses ffmpeg wrapper, but in my tests doesn't work with a bik (I couldn't get it to work with other formats either), and that project appears to be abandoned, so it might be best to develop out my own. VLC which uses ffmpeg plays the files fine. I suppose I can try and write my own decoder in java (assuming bink file format is open sourced), but I'm concerned that will be too slow, at least for mobile.

This isn't a high priority issue -- I can live without cutscenes for now -- but I'd like to explore it in the future -- perhaps after looking into #8

Command I used to convert bik to mp4 ffmpeg -i BlizNorth640x480.bik out.mp4


I'll also note that the video files are provided with 640x146 and 640x292 sizes, so if I need to, I can use the smaller res on mobile for faster streaming.

collinsmith commented 3 years ago

Useful links https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/bink.c https://wiki.multimedia.cx/index.php/Bink_Container https://github.com/FFmpeg/FFmpeg/blob/a0ac49e38ee1d1011c394d7be67d0f08b2281526/libavcodec/avfft.c https://github.com/mpenkov/ffmpeg-tutorial/blob/master/tutorial07.c

collinsmith commented 3 years ago

Need to attach a debugger to ffmpeg to generate test data from input that I can test codec against, otherwise this is very difficult. Video codec doesn't seem as difficult as audio codec -- requires custom Huffman coding tree though.

collinsmith commented 3 years ago

fe7cdc4caa398fc24ccd9640138ad18271b40793 gdx-video was updated and looks like it's being developed again. I wrote a sample tool video player which can play webm videos with vp8 video codec and vorbis audio codec. Did not work with raw bik files even though ffmpeg can play them fine in vlc. Maybe need to pass args to gdx-video native wrapper or convert the stream somehow. Worst case, at least there's a functioning video player in libgdx now.