|
play video in loop |
Xpicolo
Member #16,781
December 2017
|
Hi, Thanks, |
beoran
Member #12,636
March 2011
|
Why not rewind the video with al_seek_video(video,0) when you get the ALLEGRO_EVENT_VIDEO_FINISHED event? |
Xpicolo
Member #16,781
December 2017
|
I tried this, not work. |
beoran
Member #12,636
March 2011
|
http://liballeg.org/a5docs/trunk/video.html#al_seek_video According to the docs, rewinding is not supported for all video formats and decoders. What format is the video? And what video driver for Allegro5 are you using? |
Xpicolo
Member #16,781
December 2017
|
I use .ogv file and OpenGL. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
.ogv file is just a container. We need to know the codec. VLC Media Player can give you all the info you need. Play the .ogv video with VLC, and then press CTRL + J to view the codec info. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Chris Katko
Member #1,881
January 2002
|
To elaborate further: Some file formats only have one codec. But other file are actually "container" file formats. mkv, for example. That means they can have many different types of actual video and audio in the same file. Think of it like a zip, but dedicated to audio and video. So you may have 100 mkv files that work fine, and 1 that doesn't. The reason is, that one (assuming it isn't corrupted) is using a different (unsupported) codec than the other 100. So if it's not working, you need to find (and tell us) the codec that's missing or failing to load the file--not the container. -----sig: |
Xpicolo
Member #16,781
December 2017
|
Codec: Xiph.org's Theora Video (theo) |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Just for now, you can always play / stream the video again when you get the VIDEO_FINISHED event. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Xpicolo
Member #16,781
December 2017
|
But that means to close, re-open and re-start video stream ? I'm wrong? |
SiegeLord
Member #7,827
October 2006
|
What you need to do is right after you call al_seek_video_video(video, 0) is also call al_set_video_playing(video, true). Then it should work (and does for me on my machine). "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Xpicolo
Member #16,781
December 2017
|
Thanks SiegeLord, But I have a problem with delay when i restart video with seek. Firts, my .ovg file is at 10 FPS, but events ALLEGRO_EVENT_VIDEO_FRAME_SHOW occur @ 170 ms events FRAME_SHOW at 299 msec, play position 0.20 < why after 299msec and where is pos. 0.0 , 0.1 ? restart play from 0.000000 restart play from 0.000000 1#include <stdio.h>
2#include <allegro5/allegro.h>
3#include <allegro5/allegro_image.h>
4#include <allegro5/allegro_video.h>
5
6int width = 1024;
7int height = 768;
8
9ALLEGRO_DISPLAY *display;
10
11int main(int argc, char *argv[])
12{
13 ALLEGRO_VIDEO *video;
14 ALLEGRO_BITMAP *frame;
15 ALLEGRO_EVENT_QUEUE *queue;
16 ALLEGRO_EVENT event;
17
18 al_init();
19 al_init_image_addon();
20 al_init_video_addon();
21
22 display=al_create_display(width, height);
23 queue=al_create_event_queue();
24
25 video=al_open_video("main.ogv");
26
27 al_register_event_source(queue, al_get_video_event_source(video));
28 al_register_event_source(queue, al_get_display_event_source(display));
29
30 al_start_video(video, al_get_default_mixer());
31
32 double old_time=al_get_time();
33
34 while(1)
35 {
36 al_wait_for_event(queue, &event);
37
38 if(event.type==ALLEGRO_EVENT_VIDEO_FRAME_SHOW)
39 {
40 printf("events FRAME_SHOW at %.0f msec, ",(al_get_time()-old_time)*1000);
41 old_time=al_get_time();
42
43 ALLEGRO_BITMAP *frame = al_get_video_frame(video);
44 printf("play pozition %.2f\n",al_get_video_position(video, ALLEGRO_VIDEO_POSITION_ACTUAL));
45 al_draw_bitmap(frame, 0, 0, 0);
46 al_flip_display();
47 }
48 else if(event.type==ALLEGRO_EVENT_VIDEO_FINISHED)
49 {
50 al_seek_video(video, 0.00);
51 printf("\nrestart play from %f\n",al_get_video_position(video, ALLEGRO_VIDEO_POSITION_ACTUAL));
52 al_set_video_playing(video, true);
53
54 }
55 }
56 return 0;
57}
|
SiegeLord
Member #7,827
October 2006
|
Can you share your video with us? Just want to make sure there's no some weird interaction between it and the video addon. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Xpicolo
Member #16,781
December 2017
|
this is the .ogv file |
SiegeLord
Member #7,827
October 2006
|
Thanks for that, and the code. Indeed, there are a number of issues with playback, there are dropped frames, pauses and a bit of desync. There's nothing that you can do about it (the code and the file is fine), but we need to adjust how Allegro handles some things. I'll try to get it done before 5.2.4 release. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|