VIdeo playback

Tagged: , ,

This topic contains 16 replies, has 6 voices, and was last updated by  Simon Armstrong 2 years ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #5689

    byo
    Participant

    Hello.

    First of all, I want to say thay I’m an old Blitzbasic, then BlitzPlus, then Blitz3D, Blitzmax and now Monkey user. I hardly posted anything on the official forums though. I admire Mark Sibly for all the amazing tools he developed. Congrats for Monkey2!

    That being said, how do I add videos to Monkey2?
    I’m intending to make a simple FMV game or sort of and I understand we have OpenAl for audio but how to embed movie clips?

    Thanks and best regards,

    byo

    #5697

    Mark Sibly
    Keymaster

    There’s no video playback in yet but thanks for reminding me, it’s definitely high up the todo list now!

    #5708

    DruggedBunny
    Participant

    Don’t know what your plans are, Mark, but VLC is pretty easy to use:

    http://www.blitzbasic.com/codearcs/codearcs.php?code=3230

    See notes about licensing (needs to be in dynamic library form for LGPL compliance, etc)… seems like you could provide a carefully-selected subset of non-GPL codecs with it to support a bunch of ‘default’ formats at least.

    #5710

    byo
    Participant

    Excellent, Mark!

    I see great potential and many uses for games:

    • Intros
    • Cutscenes
    • FMV games (the latest Tex Murphy game shows it’s a genre that’s back to business)
    • Playback from smartphone camera (pre recorded, of course)

    I understand that it must be a format and codec that’s compatible with desktop PCs and mobile devices, right?
    WebM sounds tempting but Chrome has some issues playing it for some users.
    Theora looks usable as well.

    I think I read about embedding VLC and a lot of people are recommending it on forums.

    Any solution would be great really.

    Thanks!

    #5714

    Mark Sibly
    Keymaster

    A quick google suggests ffmpeg might be a good place to start:

    https://www.ffmpeg.org/

    There’s also a tutorial for getting it working with SDL:

    http://dranger.com/ffmpeg/

    Any objections to starting with this?

    Embedding VLC (which is only an app?) doesn’t sound very easy or ‘cross platformy’, esp. for straming stuff to textures etc but I’ve had no experience with this – any pointers?

    #5717

    DruggedBunny
    Participant

    Re. VLC — I don’t have a strong preference, but I should have said libVLC — which is the (cross-platform) library that VLC (the ‘app’) is based on! There’s an example in the comments on my link for rendering to pixmaps, by the way.

    This is the actual loading/playing process (see comments) for libvlc in BlitzMax, after loading the DLL and assigning functions from it:

    #5718

    Mark Sibly
    Keymaster

    libVLC looks pretty good, except for the LGPL aspect. However, just checked and ffmpeg is also LGPL so I’m hosed-ish either way (well, it becomes a bit trickier anyway…).

    Does libVLC do audio too?

    #5720

    arpie
    Participant

    I am far from expert with multimedia frameworks but you may want to look into gstreamer as a possible alternative.  It is a higher-level module-based system which will be more complex to integrate, but more powerful and flexible in the longrun (it can use ffmpeg as a backend).  It is (afaik) written in C (using GObjects for OO), so should be easy to port?

    Documentation is here :

    https://gstreamer.freedesktop.org/documentation/frequently-asked-questions/index.html

    I have googled for gstreamer with SDL and not found any useful leads, although people do seem to be doing it.

    Equally, ffmpeg is also very highly regarded at least in the Linux world.  I would have no objection to either.

    As for VLC, I have always found its playback quality to be not great (funny interlacing effects on some videos), however I believe their decoders are considered to be amongst the fastest out there.

    Just out of interest, I have just checked which apps here in the Linux world use which libraries.  ffmpeg and gstreamer are both required by a lot of packages.  Of note, though, ffmpeg is the video library of choice for firefox, chromium (that’s chrome stripped of any licencing issues), mplayer and blender.  GStreamer is used by handbrake (handbrake.fr), Totem (Gnome’s standard video player) and Shotwell.  Based on that comparison, I’d say ffmpeg is probably a good way to go.

    #5721

    Mark Sibly
    Keymaster

    One issue with ffmpeg is that you apparently need to statically link with fancier codecs via cmake switches (going by this page: https://ffmpeg.org/general.html).

    This is a hassle with a LGPL product as it means a whole new dll needs to be generated for each combination of codecs, correct?

    Also, it’s likely that, due to patent issues, (grrrr…) I wont be able to include all the codecs everyone may want or be legally able to use etc in the official release, but with ffmpeg there’s doesn’t seem to be an easy way to add them.

    #5727

    arpie
    Participant

    I don’t see an issue with a very limited set of codecs (even just one) being supported, as long as those few codecs are available on all platforms.  Any videos I want to include in a game I can easily convert to a format that is supported.  I don’t see any mileage in you spending time trying to support a hundred different codecs when just one that works everywhere would be perfectly acceptable (and probably a lot easier to support and make 100% bug-free).  We are (mostly) writing games, not multimedia apps.  One rock-solid supported codec is way better than multiple flakey ones.

    Do people have a preferred format?  Is there any one format that is entirely free of patent issues?  I would have thought Ogg Theora would fit the bill, wouldn’t it?  Or have I read that there is a potential patent issue lurking round the corner? [edit : looks like no – http://en.swpat.org/wiki/Theora ]

    #5731

    arpie
    Participant

    After some googling, I would suggest that the only format worth supporting is VP8 (or VP9?), aka WebM.  It is effectively a successor to Theora and is pretty-much guaranteed patent free.  Its only drawback seems to be slower encoding speed than Theora – for games, I don’t see this being a big deal?  VP8 and VP9 both appear to be supported by the same library in ffmpeg (libvpx).  I’ll stop making suggestions now, in case anybody else has any thoughts on this that may contradict mine 🙂

    http://en.swpat.org/wiki/VP8_and_WebM

    http://www.webmproject.org/about/

    http://git.videolan.org/?p=ffmpeg.git&a=search&h=HEAD&st=commit&s=libvpx

    #5734

    DruggedBunny
    Participant

    Re. Libvlc, yes, audio is covered — as in the example I posted plays audio without anything else needed.

    I’m only speaking from a libvlc perspective (since that’s all I’ve played with), but whatever you go with, consider supporting only something like Ogg Theora by default, as arpie suggests. Codecs are a legal minefield!

    Supporting other formats can fall upon the individual developer, while everyone can recode as Ogg Theora one way or another… same should apply for ffmpeg, really.

    It really depends whether you intend to support playing any random video (legal minefield, blah blah) or just allowing a way to play some form of self-produced video… in which case, figure out the ‘safe’ codecs and support only those.

    #5855

    Mark Sibly
    Keymaster

    Ok, just pushed a new ‘theoraplayer’ module to the github master branch! See new theoratest banana…

    It uses the ‘theora player’ library – see: http://libtheoraplayer.cateia.com/wiki/index.php/Main_Page although docs there are wildly out of date.

    It’s kind of low level (you need to paste video frame data to a texture) but seems to work well and is very flexible this way. We can wrap it in something higher level later if necessary.

    Should work on all targets except emscripten (it uses threads, which might be ‘fixable’).

    And damn, that KDE anim is cute!

    #5858

    arpie
    Participant

    Woohoo!  Low level is good…  it means more flexibility.  Working perfectly here on Linux.

    #5868

    byo
    Participant

    Amazing. I heard great things about the theoraplayer before.
    Will need to test this as soon as I get back from a work trip.

    Thanks a lot!

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.