Openfl.media.Video

Hello everyone,
I’m new to the forums, so first of all, hi. :wave:
I’m currently developing my first project in Haxe/OpenFL, using HaxeFlixel to help out. It’s nearly done, all there’s left is to embed a couple of tutorial videos. However, after hours of googling (and outdated pages, Google really likes old.haxe.org), it seems like OpenFL just doesn’t support video on cpp.
I was about to quit, but then I found this page. Now I’m not sure what to think. This class is not barely mentioned on the internet, everyone just seems to use the flash.media equivalent.
So: is it possible or not to play an flv in a windows targeted project?
Thanks in advance for the help,
Mike

For all you poor souls out there trying to play video, the only way I managed was to use webm ( https://github.com/soywiz/haxe-openfl-webm ), use a audioless video and play the audio at the same time.

1 Like

On Flash, FLV and MP4 H.264 support is built in the player. This required licensing (and of course work) on Adobe’s side to have this implemented. I’m not sure of a good cross-platform way to handle video?

There is some support for HTML5 video on the HTML5 target, using similar classes. I would like to see more improvements in this area. Does the webm code seem to perform alright?

There is also Bink video support working for OpenFL, but this requires a license to use

1 Like

The webm code preforms okay, when the video doesn’t have sound, playback is fine. However, for some reason, haxeflixel performs super poorly after I play any videos, making me believe there’s probably some bad mem management somewhere.
I’d be great to have video playback. I read that NME had a cross platform implementation of StageVideo? Maybe it’s outdated. I dunno, I’m fairly new to the Haxe thing and there seems to be a big mix-up of outdated/new names and resources.
I couldn’t find anything regarding Bink/OpenFL.

(Also thanks for replying!)

The Bink video extension is private, due to the required licensing, we need to protect our relationship with RAD games. Bink is used in many serious titles, but the price might be too expensive for many independent projects ($$$$)

http://www.radgametools.com/bnkmain.htm

NME had some video support for Android and iOS, ideally, we should have a cross-platform implementation, though using hardware-accelerated video decoding on mobile is likely vital for performance

Perhaps WebM is viable, if it work in an extension format, we could consider using it in OpenFL and Lime as a built-in part of the library, or at least do something like #if extension-webm so that including <haxelib name="extension-webm" /> makes the openfl.media.Video class possible on desktop.

A portable system like that lets the feature develop on its own, but integrate nicely when you opt-in to it. I’ve been busy focusing on other aspects of the platform, though, but would be happy to see progress in this area :slight_smile:

How about gstreamer? We might be able to support hardware-accelerated video decoding with that on many platforms. Playing HD video on CPU is not easy thing for mobile devices.

I want to be careful about licenses, just because we “can” decode does not mean that we are licensed to do so. Case in point, I would integrate MP3 playback, but that does (arguably) require a $$$$ license per title. I want to be sure that I’m not just encouraging people to be dishonest, knowing or not

If decoder is already available in target system and we can use that, licensing shouldn’t be a problem.
H.264 decoder is available on most systems today.

For paid apps, You should be licensed to distribute H.264 video longer than 12 minutes, but this is the same for Flash.

I’m not encouraging you to integrate software MP3 /AAC/H.264 decoder into OpenFL. Instead of that we can use decoder available in the system.
Nobody uses MP3 for newly developed apps if Ogg Vorbis and AAC are also available, I guess.

There might be licensing problems with longer H.264 videos, but is that really our responsibility to not let developers distribute such videos?

@vroad interesting, I had not heard about the 12 minute free-pass on H.264 encoded content. It looks like that applies to content creators, on the software side (if we included a decoder) it’s steeper – $0.20 per unit from 100,000 to 5 million downloads. I’m not sure that versions matter, we’re well over 100,000 downloads (the haxelib counter is broken)

Do you think WebM is viable, or is it reasonable to expect the system to have an H.264 decoder available?

Based on this table, I do think that H.264 would be favorable for compatibility, since Flash, HTML5 and native targets could theoretically consume the same video files

http://caniuse.com/#feat=mpeg4

Older Oses like Windows Vista does not have built-in H.264 decoder, though most people use Windows7 and newer. This might be a problem when you compile for native and want to support older computers.

I think that haxelib download counter have nothing to do with license fee. It is calculated from sales of each app.

WebM is better in the term of license fee, but hardware decoder is not available on many platforms. We can embed software WebM decoder to OpenFL in case decoder is not available in the system, as it’s royalty free. It’s worth considering.

Daala also looks promising as a royalty-free codec, but it’s not something we can use today, unfortunately.

According to what I read, if you use a decoder, licensing is based on units shipped, including free software, so free or not, we would be liable for paying a license fee on OpenFL per download, unless I’m totally mistaken, which is one thing that might have motivated Google to invest in WebM to begin with (which seems like a spiritual successor to FLV, On2 VP6/VP7 vs. On2 VP8/VP9)

At the risk of bloat, “libavcodec” (from ffmpeg) appears to have notably better decode performance for VP8 and VP9, obviously, it would also make it simpler to add additional format support, though I’m not sure what could be done officially. This might be a better route to take than using libvpx, like the “haxe-openfl-webm” extension uses.

I wonder how to take advantage of hardware decode support, where available, though? I could not find information about this

EDIT: Is the license of ffmpeg a concern?

Whether it’s legal or not, MPEG LA will not charge for the copy of open-source software I guess.
Either way we need to stay away from non-free implementations like ffmpeg(with enable-nonfree.) Without enable-nonfree option, I think you don’t need to worry about that.

I’m currently experimenting with gstreamer. It was a bit hard to understand the API, but now I can obtain video frame.

Hardware decode seems not supported on Windows with gstreamer, but could be supported in the future with DXVA?

Well there is fluvadec plugin for gstreamer, which supports hardware decoding on various platforms including windows. Though this is not free.

I was also mistaken about mp4 playback. if “Platform Update Supplement for Windows Vista” is installed to a Windows Vista machine, that machine can also decode H.264 video/AAC audio as well.

So if you don’t think about XP and Vista without this update, you can use H.264.
Another problem for XP is that H.264 decoder is only exposed Media Foundation API, which XP doesn’t support.

I’ve also heard that Firefox is using royalty-free H.264 decoder binary created by Cisco. This only supports video decoding though. I’ve never heard of free AAC decoder like this.

I found out that FFmpeg already had DXVA2 support. So by integrating this to OpenFL, we can also support hardware decoding on Windows easily?
I started writing my own implementation with MediaFoundation before finding out that…

Microsoft even has the library which interoperates with ffmpeg, though it looks like only for Windows store apps.

And I might be misunderstanding H.264 license for H.264 videos as well.

I saw many websites saying "Only content distributor and manufacturers of DVD duplicators are responsible for paying the license."
If that’s correct I don’t have to worry about licensing issue, at least for H.264 content itself!