huceke / omxplayer

omxplayer
GNU General Public License v2.0
521 stars 501 forks source link

play looping video #16

Open efolger opened 12 years ago

efolger commented 12 years ago

I would like to see a command line option to allow constant looping of a video or list of video files. I am making a player for video installations at art galleries and this feature is essential.

huceke commented 12 years ago

What about wrapping the player call into a ordinary shell script ?

efolger commented 12 years ago

Yeah, I thought of that, but I want to make the looping play as seamless as possible, the last frame of video is matched to the first ... it should look continuous ... I'll play with it when I have a chance next week. Thanks.

On Thu, Jul 5, 2012 at 4:57 AM, huceke reply@reply.github.com wrote:

What about wrapping the player call into a ordinary shell script ?


Reply to this email directly or view it on GitHub: https://github.com/huceke/omxplayer/issues/16#issuecomment-6774116

Pauly24 commented 12 years ago

I need the exact same requirement, I have already put omxplayer into a loop inside my code but the 3 second wait makes it a bit nasty especially when the video files are relatively short (<10sec)

efolger commented 12 years ago

We need a flag to continue buffering the file from the beginning when it comes to the EOF. That would make the rasp pi a killer for video art applications. I used to do some C programming, but I don't have much time these days. Maybe I'll have a look at it, if no one else can do a quick fix.

Pauly24 commented 12 years ago

I think when omxplayer is called another option can be set for a playlist, this way when the EOF is reached it can start buffering from the next file in the playlist. Not only will this make it seamless looping but also it will implement a playlist function. Two birds with one stone.

huceke commented 12 years ago

Patches welcome :D

efolger commented 12 years ago

Two birds with five stones if you are doing the coding ;)

Pauly24 commented 12 years ago

I'm going to have a look, but my C is very limited so not sure how much help I will be.

trickkiste commented 12 years ago

Would love to see this implemented as well! Gap-less Playback of the playlist would be a killer feature. Non of the "standard" video players does this right! And eventhough gstreamer has a facility for this, this thing is broken all the time.

pfee commented 12 years ago

+1 for gapless looping over a video.

I'll try experimenting with OMXPlayerVideo::close(), OMXPlayerVideo::open() or perhaps feeding an endless sequence of packets into it via OMXPlayerVideo::AddPacket().

I don't need audio for my application, so I'm going to ignore m_player_audio for now.

Have any of the folks above made any progress implementing looping? I am able to get video loops with XBMC, but the delay when restarting the video is too much for my needs.

cscscheng commented 11 years ago

if you split a file to some part it will work ...

but some diffrent file when you do OMXPlayerVideo::close(), OMXPlayerVideo::open() the sceen will show black..

pfee commented 11 years ago

Are there instructions on setting up the build environment for omxplayer? The source code looked reasonable, but I haven't got a build environment setup to permit experimentation. Is it best to build on a Raspberry Pi or is there a convenient way to build on Linux/x86_64 platforms?

kronick commented 11 years ago

I'm trying to tackle this same issue-- I have some ideas from looking at the source code but getting a dev environment set up is a challenge as @pfee mentioned. Any suggestions on the fastest path to getting going? I would love to start contributing.

torarin commented 11 years ago

It is quite convenient to cross-compile using https://github.com/raspberrypi/tools. You can mount the Pi filesystem on your build machine and then use the header files and libraries installed on it when building. If you tell me where you hit an obstacle, I'll try to help.

parasew commented 11 years ago

wrightrocket has a fork that builds on the pi. see https://github.com/wrightrocket/omxplayer why can't we merge the changes so this repo code actually builds on the pi as well?

bendenoz commented 11 years ago

I have been experimenting with this and have a working version (at least for my purpose) Definitely a hack because of the not very clean "UnFlush" method but feel free to test / pull.

https://github.com/bendenoz/omxplayer/commit/cd47dbb47cfa1a2ef2d5a8ca3f80e1348a76fa49

kronick commented 11 years ago

@bendenoz Could you share the binary? I still haven't had success setting up a build environment and this is the main feature I need.

efolger commented 11 years ago

I'm with kronick - love to see a binary. I opened this issue and haven't had time to go anywhere with it.

bendenoz commented 11 years ago

Don't really have a good place to keep it, but it's here for now: http://s3.phileog.com/.../omxplayer-dist.cd47dbb.tgz (probably only temporarily...) Note that it's been build against a recent firmware (at least this one https://github.com/raspberrypi/firmware/commit/bb97480b961370956fa2a4300dc1ea6a7f519141) so you'll likely have to update your boot files as well as the /opt/vc directory (the one from the hardfp directory) Let me know...

efolger commented 11 years ago

Thank you!

exidyboy commented 11 years ago

Thanks bendenoz. I downloaded your binary and after learning a lot of Linux 101 stuff I watched my 20 minute documentary loop for an hour or so but it was not still running in the morning. That could be due to any number of problems at my end although the Pi was still responsive to the command line. Has anyone tested over an extended duration (days).

Is there somewhere I can look on the Pi for evidence of any issue or some environment I can set up to monitor the process ?

Thanks again for this exciting and valuable contribution.

Michael

popcornmix commented 11 years ago

Probably a resource leak. Does omxplayer exit? Is so, then it might be a memory leak on arm side (you may have an oom killer message in dmesg log). If omxplayer is still running but hung, then it's probably not destroying an openmax component, and eventually gpu runs out of memory.

hinxx commented 11 years ago

You can see how much memory is left by issuing "free" command. Also the output of "top" can be useful. There also numerous other sources of memory consumption. For starter you can periodically issue "free" during the night and save the output for later analysis. I believe that memory consumption can be be seen per process, too (IMHO, even "top" can do that).

bendenoz commented 11 years ago

@exidyboy what is your content and did you actually get any error message from the player? I've had it run for almost 24h and could not measure any increase in memory usage, but again haven't done very extensive testing...

exidyboy commented 11 years ago

I set 'free' up to poll every 60 seconds and have been running pi@raspberrypi ~ $ omx/omxplayer-dist/usr/bin/omxplayer.bin --loop Desktop/high.m4v for the past four days - there is no memory leak. I think the 'issue' was that I was running omxplayer.bin via ssh from a terminal window on my PowerBook and when it went to sleep at night omxplayer would exit. Sorry for wasting your time.

Seelen commented 11 years ago

@exidyboy Please tell me if you can solve the black time between the videos, I need the same loop solution

exidyboy commented 11 years ago

Hi Seelen,

I am not the author of this hack to get omxplayer to loop a clip. The author is bendenoz who pops into github from time-to-time. I'm just passionate about the use of the Pi in artistic and cultural institution installations and am doing what I can to facilitate progress against this use case - and looping is one of a number of important functional requirements for these users.

However after some testing tonight I don't get any 'black time' between 'videos'. I assume you mean frames of black appearing between the end of a video and the re-starting of the video (singular) - but nor do I get the completely seamless looping over the end-of-file/start-of-file boundary that I suspect you are looking for and that is really necessary if looping is to ultimately become a meaningful in-built feature of omxplayer as opposed to accomplishing non-seamless repeat play of a clip via an out-of-band script. As bendenoz freely admits this is not yet a fully resolved solution. If you would care to post a clip somewhere I would be happy to test it.

gch99 commented 11 years ago

Much thanks to bendenoz. Running it now, way better than looping in script. Agree with kronick, would like to get a development environment set up. Never done it before either, would like the dummies guide :-)

bendenoz commented 11 years ago

@exidyboy thanks for confirming about the memory issue, and yes sorry for the sporadic replies... What kind of issues are you still seeing with the looping? I'd probably recommend making sure the content starts and ends with a few frames of still images for it to be really seamless...

@gch99, I'm not an expert but I found the easiest was to start from a fresh Ubuntu install so you can easily install all the dependencies (you can use a virtual machine), and follow the instructions on eLinux.org to setup the cross-compiling environment. Be prepared to tweak the Makefiles though...

/Ben

gch99 commented 11 years ago

Question, what is the difference between omxplayer and omxplayer.bin? To get the omxplayer.bin to work ( the one installed and the one from @bendenoz), I had to create a lot of symbolic links in the /usr/lib dir for the libraries in /usr/lib/omxplayer. Where as the omxplayer just worked without any changes. About the looping ... For seamless operation the content should begin and end with the exact same frame, one frame only. The program should not pause or hesitate at all. Thus should try and buffer the 1st few frames so that playout from end back to beginning would be like there is never an end.

exidyboy commented 11 years ago

Hi bendenoz,

To respond to your second suggestion first, in my opinion the ultimate goal of genuinely seamless playback is that frame n+1 is played back exactly the same regardless of whether it is in the middle of the file or n is the last frame and n+1 is the first frame. I'm thinking of a ring buffer. A use case is the creation a moving video wallpaper without distracting freezes that could be a pre-show background at a corporate or cultural event.

In terms of the issues that I have seen in my test environment with the looping player these include uneven playback, jumping playback, indefinite pauses and outright quits. All these may well be artifacts of my Pi environment or pathologies in my test clips. However all the clips play OK on my Mac in VLC and QuickTime.

I'd be interested if other people see the same issues or if the issues are at my end.

Here is a Vimeo of the issues I've seen and links to the test clips for other people to verify or discount these issues as aberrations: http://vimeo.com/60931191

Test Clips as used in the video:

Clip created in Telestream Episode - playback uneven Link to test clip: http://www.michaelborthwick.com.au/big_pi_episode.mp4

Clip created in MPEG Streamclip - short and long stalls, jumping forward, screen flashes Link to test clip: http://www.michaelborthwick.com.au/big_pi_streamclip.mp4

Clip created in HandBrake - frames are not played evenly, omxplayer.bin quits with: omxplayer.bin: OMXReader.cpp:425: OMXPacket* OMXReader::Read(): Assertion `!IsEof()' failed. Aborted Link to test clip: http://www.michaelborthwick.com.au/big_pi_handbrake.mp4

Clip created in Sorenson Squeeze 8.5 - frames of black at end only respected on first play through: Link to test clip: http://www.michaelborthwick.com.au/pi1.mp4

bendenoz commented 11 years ago

Well thanks Michael that was a lot of debugging :smiley: Very useful actually, I was able to repro your issue with the sample content. I've integrated a suggestion from @jvcleave, and kind of fixed the SeekTime call that was a little messed up, and it almost fixes the problem. There is still a short pause on looping, but it should definitely help on your Episode encode as well as the one with soundtrack. The commit is here https://github.com/bendenoz/omxplayer/commit/8fc27e554edfe4167c7fd330ec6f32cd88dd088c and I put a build here too http://s3.phileog.com/.../omxplayer-dist.8fc27e5.tgz Let me know...

exidyboy commented 11 years ago

Thanks so much for confirming that you could reproduce the issues. I edited my post so that it points to a Vimeo with audio commentary http://vimeo.com/60931191 and I will test your new build asap.

hinxx commented 11 years ago

@gch99 The omxplayer is a shell script used to run/execute the actual executable binary file omxplayer.bin. The script (omxplayer) does some sanity work before and after the omxplayer.bin execution. It also tells the omxplayer.bin where the needed libraries are at (LD_LIBRARY_PATH) since folders containing them are not in the standard Linux FHS - http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard.

bendenoz commented 11 years ago

@exidyboy please try this build instead http://s3.phileog.com/.../omxplayer-dist.37e3f44.tar.gz. I made a few more changes, actually using a slightly different method to do the loop, with a less intrusive hack into the core. It should be pretty much frame accurate now (no glitch).

JamesHagerman commented 11 years ago

@bendenoz Is there any chance you can start a pull request for your loop changes?

charlie-s commented 11 years ago

Tested the last linked build - works great for me. Thanks for delivering this.

Pauly24 commented 11 years ago

There's another great version just put up by pasky, you can seamlessly loop multiple files as long as they have the same encoding parameters. ie 'omxplayer -L movie1.mp4 movie2.mp4 movie3.mp4'

https://github.com/pasky/omxplayer

bendenoz commented 11 years ago

Thanks for this. Actually I've been considering implementing "printf" format style input (ie. "video-%03d.mp4"), to allow for multi-file sequences, but currently I discovered an issue with some content which don't seem to have pts values for video packets, and I need to spend more time understanding the internals of how this is managed... I haven't tested @pasky's version yet, but it does look it's a few steps ahead though :)

TitustheFox commented 11 years ago

Hello there, sorry that i asking this, but i'm feeling like a noob, because i dont have any clue how to use github. Im looking for a loop method on my omxplayer and would like to realise this...

My problem is, that i can follow this conversation and i think that i can follow... but dont have any clue how to use this knowledge here. Im a litte bit familiar with c and long time ago i also used basic as programming language...

Im interested in the post's from "bendenoz" because it looks like a compiled version of omxplayer with the option for a loop playback, but i dont have idea , how to install all these github stuff on my raspberry pi ....

what i have to do with all the files which are listed on github???? should i compile these file, (by an ide) by myself or is there an "install.exe "... does someone have a tutorial which i can read to get an idea about github???

I would be very grateful if someone could me help with this ...

cheers t

charlie-s commented 11 years ago

@TitustheFox I think you have 2 options.

a) Go to https://github.com/bendenoz/omxplayer and download the latest copy, compile it, and put it on your Rasp. b) Download the last link from bendenoz (http://s3.phileog.com/uploader/0bf2f9d696385149a37206600bec7f6e/omxplayer-dist.37e3f44.tar.gz) and overwrite the files on your Rasp with the file in this zip. Simple as that. Then add --loop flag when running the command.

TitustheFox commented 11 years ago

Thanks a lot ... i've tried it but i just get the info... "/usr/bin/omxplayer.bin: error while loading shared libraries: /usr/lib/omxplayer/libavutil.so.51: invalid ELF header" . i just have to become familiar with linux ... sometimes it disturbs me that you have to do using all time sudo commands via terminal. i used "sudo mv /file1/from /file2/to but it doesn't work...

So i have to try it again... I hope that i'll get more used to all these stuff because on the end i will try to get 2 player which playing in a loop together and playing as well in sync...

cheers t

bendenoz commented 11 years ago

@TitustheFox, if you have copied the libraries too, it could be you need to upgrade the kernel and firmware of the Pi. It's compiled against a specific version of the firmware (/opt/vc directory)

Also, I believe I identified the cause of the problem I was having with some content, and it seems pretty stable AFAICT, so I'll try to issue a pull request if this helps.

Thanks everyone for helping with testing.

gch99 commented 11 years ago

Error when trying to compile, following directions from https://github.com/pasky/omxplayer. When make ffmpeg get: cd ffmpeg; \ CFLAGS="-DSTDC_CONSTANT_MACROS -DSTDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_HAVE_SBRK -D_LARGEFILE64_SOURCE -DHAVE_CMAKE_CONFIG -DHAVE_VMCS_CONFIG -D_REENTRANT -DUSE_VCHIQ_ARM -DVCHI_BULK_ALIGN=1 -DVCHI_BULK_GRANULARITY=1 -DEGL_SERVER_DISPMANX -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DVIDEOCORE4 -DGRAPHICS_X_VG=1 -U_FORTIFY_SOURCE -Wall -DHAVE_OMXLIB -DUSE_EXTERNAL_FFMPEG -DHAVE_LIBAVCODEC_AVCODEC_H -DHAVE_LIBAVUTIL_MEM_H -DHAVE_LIBAVUTIL_AVUTIL_H -DHAVE_LIBAVFORMAT_AVFORMAT_H -DHAVE_LIBAVFILTER_AVFILTER_H -DOMX -DOMX_SKIP64BIT -isystem/opt/xbmc-bcm/buildroot/output/staging/usr/include -isystem/opt/xbmc-bcm/buildroot/output/staging/opt/vc/include -isystem/opt/xbmc-bcm/buildroot/output/host/usr/arm-unknown-linux-gnueabi/sysroot/usr/include -isystem/opt/xbmc-bcm/buildroot/output/staging/opt/vc/include/interface/vcos/pthreads -isystem/opt/xbmc-bcm/buildroot/output/staging/usr/include/freetype2" \ LDFLAGS="" \ ./configure \ --extra-cflags="-mfpu=vfp -mfloat-abi=hard -mno-apcs-stack-check -mstructure-size-boundary=32 -mno-sched-prolog" \ --enable-cross-compile \ --enable-shared \ --disable-static \ --arch=arm \ --cpu=arm1176jzf-s \ --target-os=linux \ --disable-muxers \ --enable-muxer=spdif \ --enable-muxer=adts \ --disable-encoders \ --enable-encoder=ac3 \ --enable-encoder=aac \ --disable-decoder=mpeg_xvmc \ --disable-devices \ --disable-ffprobe \ --disable-ffplay \ --disable-ffserver \ --disable-ffmpeg \ --enable-shared \ --disable-doc \ --enable-postproc \ --enable-gpl \ --enable-protocol=http \ --enable-pthreads \ --disable-runtime-cpudetect \ --enable-pic \ --disable-armv5te \ --disable-neon \ --enable-armv6t2 \ --enable-armv6 \ --enable-armvfp \ --enable-hardcoded-tables \ --disable-runtime-cpudetect \ --disable-debug \ --cross-prefix=arm-unknown-linux-gnueabi- arm-unknown-linux-gnueabi-gcc is unable to create an executable file. C compiler test failed.

If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "config.log" produced by configure as this will help solving the problem.

pasky commented 11 years ago

@gch99, are you able to compile other versions of omxplayer fine? There should be no changes in the build process in my version.

gch99 commented 11 years ago

First time I tried, @bendenoz put up binaries that worked great on my xbian, so I did not need to cross-compile.

pasky commented 11 years ago

I see. You can try binaries from

http://pasky.or.cz/dev/omxplayer/omxplayer-loop-multifile-bin.tar.gz

(unpack that in your home directory, cd omxplayer-dist/usr/bin, ./omxplayer ...)

Please note that this branch does not include the latest updates by @bendenoz (a little over a week old) so it might have some extra issues with playback, maybe. I'm waiting for some sort of feedback from omxplayer maintainer to my pull request before I will update my branch again.

gch99 commented 11 years ago

Thanks pasky, I'll download them. I'm still trying to set up a development environment for the Rasp Pi, ... getting closer :) My latest error in compiling is: arm-rpi-linux-gnueabi-g++ --sysroot=/home/gch/x-tools/arm-rpi-linux-gnueabi/output/host/usr/arm-rpi-linux-gnueabi/sysroot -isystem/include -pipe -mfloat-abi=hard -mcpu=arm1176jzf-s -fomit-frame-pointer -mabi=aapcs-linux -mtune=arm1176jzf-s -mfpu=vfp -Wno-psabi -mno-apcs-stack-check -O3 -mstructure-size-boundary=32 -mno-sched-prolog -std=c++0x -DSTANDALONE -DSTDC_CONSTANT_MACROS -DSTDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CMAKE_CONFIG -DVIDEOCORE4 -U_FORTIFY_SOURCE -Wall -DHAVE_OMXLIB -DUSE_EXTERNAL_FFMPEG -DHAVE_LIBAVCODEC_AVCODEC_H -DHAVE_LIBAVUTIL_OPT_H -DHAVE_LIBAVUTIL_MEM_H -DHAVE_LIBAVUTIL_AVUTIL_H -DHAVE_LIBAVFORMAT_AVFORMAT_H -DHAVE_LIBAVFILTER_AVFILTER_H -DHAVE_LIBSWRESAMPLE_SWRESAMPLE_H -DOMX -DOMX_SKIP64BIT -ftree-vectorize -DUSE_EXTERNAL_OMX -DTARGET_RASPBERRY_PI -DUSE_EXTERNAL_LIBBCM_HOST -isystem/home/gch/x-tools/arm-rpi-linux-gnueabi/usr/include -isystem/home/gch/x-tools/arm-rpi-linux-gnueabi/opt/vc/include -isystem/home/gch/x-tools/arm-rpi-linux-gnueabi/output/host/usr/arm-rpi-linux-gnueabi/sysroot/usr/include -isystem/home/gch/x-tools/arm-rpi-linux-gnueabi/opt/vc/include/interface/vcos/pthreads -isystem/home/gch/x-tools/arm-rpi-linux-gnueabi/usr/include/freetype2 -I./ -Ilinux -Iffmpeg_compiled/usr/local/include/ -I /home/gch/x-tools/arm-rpi-linux-gnueabi/arm-rpi-linux-gnueabi/sysroot/usr/include -I/usr/include -I /mnt/gchendry/rasbpi/git/omxplayer/ffmpeg -I/mnt/gchendry/rasbpi/wheezy/opt/vc/include -I /mnt/gchendry/rasbpi/wheezy/opt/vc/include/interface/vcos/pthreads/ -I /mnt/gchendry/rasbpi/wheezy/opt/vc/include/interface/vmcs_host/linux/ -I /usr/include/freetype2/ -c OMXPlayerSubtitles.cpp -o OMXPlayerSubtitles.o -Wno-deprecated-declarations

In file included from OMXPlayerSubtitles.cpp:19:0: OMXPlayerSubtitles.h:39:22: error: expected ';' at end of member declaration OMXPlayerSubtitles.h:39:24: error: 'BOOST_NOEXCEPT' does not name a type

Any ideas?

hinxx commented 11 years ago

@gch99

Since you are on your host PC, you are probably lacking the c++ boost development packages for cross compiling for arm.

gch99 commented 11 years ago

Thank hinxx.

I have the below already installed, all up-to-date. I'm I missing something?

boost.i686 1.46.0-3.fc15
boost-date-time.i686 1.46.0-3.fc15
boost-devel.i686 1.46.0-3.fc15
boost-filesystem.i686 1.46.0-3.fc15
boost-graph.i686 1.46.0-3.fc15
boost-iostreams.i686 1.46.0-3.fc15
boost-program-options.i686 boost-python.i686 1.46.0-3.fc15
boost-random.i686 1.46.0-3.fc15
boost-regex.i686 1.46.0-3.fc15
boost-serialization.i686 boost-signals.i686 1.46.0-3.fc15
boost-system.i686 1.46.0-3.fc15
boost-test.i686 1.46.0-3.fc15
boost-thread.i686 1.46.0-3.fc15
boost-wave.i686 1.46.0-3.fc15