Main Menu

mod_vlc

Started by josebita, March 17, 2010, 05:58:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

josebita

I've created a page hosting the latest code and packs containing only the minimum set of libraries for playing some popular codecs for windows.
Right now, the I've got codec packs for:
 - WebM (3.4MiB).
 - Ogg Theora+Vorbis (1.4MiB).
 - Dirac (1.4MiB).
In the next few days I'll upload packs for non-free but popular codecs (flv, xvid, h264...).

http://code.google.com/p/bennugd-vlc/

josebita

Support for MPEG4 video encapsulated as AVI. MPEG & AC3 surround audio support.

panreyes

#17
Hi Josebita,
I finally tried to put video in Bennu, and I used the mod_vlc's WebM package.
It works flawlessly the first time a video is played, but the second play_video would return -1.
May it be a bug?

josebita

You're posting in the English forum!

I'll have a look at it, but do you stop the video? Also, please post your code so I can have a look at it, but I think I know where the problem might be coming from.

panreyes

This is all the code about video:
graph = video_play("quizz/"+fichero+"/"+nombre_video+".webm",1024,768);
    while(! video_is_playing() && ! key(_esc)) // Wait for the video to actually start
        FRAME;
    end
while(! key(_esc) and video_is_playing())
        FRAME;
end
if(video_is_playing()) video_stop(); end
graph=0;

BTW, I had 2 options: moving the post or writing in again in english. I preferred the second XD Ups sorry, I meant LOL

panreyes

#20
Also, the error only occurs when I'm not stopping the video with stop_video() before it ends.

Little patch:
timer=0;
duration_in_ms=video_get_length()-100;
while(timer<duration_in_ms)

josebita

Yes, I believe you should do stop_video() even if the video has actually finished playing. because stop_video also does some unloading.

panreyes

If the video is stopped on his own because it has ended, if you use stop_video after that, the game will hang.

josebita

I see... I'll fix it as soon as possible to make things a bit more "intelligent".

Windgate

There are many "play video" projects now, there is any (very) simple demo at which we could play the oficial Prg BennuGD intro (mpg, divx...)?

It could be very very very useful for the current Great BennuGD Game Project.

¿Direct download, please?

Thanks ;)
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

panreyes

I would also change the way mod_vlc searches the files on ./vlc

I use Bennu from %PATH%, and this module makes me have half module in c:\bennugd and the other in c:\proyecto\vlc

It should look for c:\bennugd\vlc instead of c:\proyecto\vlc. I mean, it should look into bgdi's folder, not project's folder :)

josebita

I've been trying to find why the code crashes without any luck, yet. Sorry. I'll try to find a cause for the crash and make it play more than one video asap. :(

As of the thing with the paths... It's not that easy. The path to look for the vlc plugins is not hardcoded but is relative to the current working dir. I believe this is the best solution for distributing your game.
As for your development needs, I'm not sure but I believe that adding the path to the vlc modules dir to your global PATH variable should help.

josebita

I believe the attached library should fix the bug that didn't allow more than one video to be played (only one video can be played at a time).

The interpreter will probably crash when quitting, however...

The following example (which is a slightly modified version of the bundled example player) will allow you to play more than one video. When you press the escape key the video playback will stop. If you press "q" the app will quit but if you press the space bar, video playback will restart.
[code language="bennu"]import "mod_key"
import "mod_vlc"
import "mod_video"
import "mod_mouse"
import "mod_say"
import "mod_map"
import "mod_file"
import "mod_proc"
import "mod_timers"

#define SCR_WIDTH  640
#define SCR_HEIGHT 480

/* Player main window */
Process main()
Private
    string fname="";
    int time=0, delay=30, track=1;

Begin
    // Handle the command line
    if(argc != 2)
        say("Must be given file to play, quitting.");
        exit();
    end;

    // Try to find the file that the user wants us to play, or die
    fname = argv[1];
    if(! fexists(fname))
        say("Couldn't find "+fname+" to be played, quitting.");
        exit();
    end

    /* Start the graphics subsystem */
    set_mode(SCR_WIDTH, SCR_HEIGHT, 16);

    /* Finally play the video and place it in the middle of the screen */
    graph = video_play(fname, SCR_WIDTH, SCR_HEIGHT);
    x = SCR_WIDTH/2; y = SCR_HEIGHT/2;
    while(! video_is_playing()) // Wait for the video to actually start
        FRAME;
    end;
    while(! key(_esc))
        if(timer[0] > time+delay)
            if(key(_space))
                video_pause();
                time = timer[0];
            end;
            if(key(_right))
                video_set_time(video_get_time()+100);
                time = timer[0];
            end;
            if(key(_left))
                video_set_time(video_get_time()-100);
                time = timer[0];
            end;
            if(key(_m))
                video_mute();
                time = timer[0];
            end;
            if(key(_up))
                video_set_volume(video_get_volume()+5);
                time = timer[0];
            end;
            if(key(_down))
                video_set_volume(video_get_volume()-5);
                time = timer[0];
            end;
            if(key(_enter))
                track = video_get_track()+1;
                if(track > video_get_tracks()-1)
                    track = 0;
                end;
                video_set_track(track);
                say("Audio track "+video_get_track()+" of "+video_get_tracks());
                say("            "+video_get_track_description());
                time = timer[0];
            end;
        end;
        FRAME;
    end;

    video_stop();
    while(! key(_q))
        // If you press space bar, we start over
        if(key(_space))
            main();
            return;
        end;
        FRAME;
    end;
End;[/code]

Windgate

Im waiting for a .zip with a full working sample, with the .prg, the .dll and a sample video... Everything is separated now: Here a .prg sample, here the .dll, here other versions of the same .dll :-[, here an old working sample with a .mpg that doesn't work with the current BennuGD dlls...

Just download, compile and run, for stupid users like me... And you ;)

http://code.google.com/p/bennugd-vlc/

Google Code has 2Gb accounts, why not a FULL working sample? :(
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

josebita

The packs there contain fully working examples. The idea of the packs is to include the bare minimum you need.
For example, download the webm pack & this video and from the folder with the prg file do:

bgdc mod_vlc.prg
bgdi mod_vlc sunflower.webm

I find it pretty straightforward. The code and dll posted here are not definitive and will be updated on the packs once I have time to do it.