Add support for almost-seamless playback of multiple streams (optionally, in a loop)
Hi! The code in pasky/omxplayer branch multiplestreams adds support for:
(i) Loop option (similar to another fork)
(ii) Multiple filenames on the command line
While running omxplayer in a shell loop causes gaps of about 2s between videos and dark screen with bunch of text in the meantime, with this patch the last frame of previous video is frozen for about 200ms (unless there is other load) before next video starts. The next video in the queue is opened and scanned by ffmpeg on the background while the current video is playing.
This is probably not ready for prime-time yet; at the very least, we should make some effort to gracefully handle (likely just by reinitializing OMX state) transitions between streams with different parameters.
Also, the current code contains not-so-few gotos and other ugly things. This is the main purpose of this pull request at this point, I would like to propose significant refactoring of the current main() function so that the above mentioned can be implemented much more sanely and maintainably. Basically, my idea is to create class OMXPlayer that will handle playback of a single file. Then, the main() function would just parse parameters (setting OMXPlayer attributes appropriately), take care of setting up OMXReader, call the OMXPlayer loop function, interpret keystrokes. All the stream-handling, feeding and synchronizing logic would be in the OMXPlayer class.
Does that sound sane? Would you accept a pull request containing such changes? Or would you prefer a different approach?
Hi Paski, the seamless loop (of a unique file) is exactly what I need. So, thanks for your awesome collaboration. My question is how to generate the bin file from your code? Any link with instructions?
Hi!
On Tue, Apr 02, 2013 at 06:23:31PM -0700, Manoel Lemos wrote:
Hi Paski, the seamless loop (of a unique file) is exactly what I need. So, thanks for your awesome collaboration. My question is how to generate the bin file from your code? Any link with instructions?
Set up a crosscompile environment (sorry, too complex to elaborate, there should be plenty of howtos; I use crosstools-ng), adjust Makefile.include to point at it and then simply follow compilation instructions bundled with omxplayer.
You can also try compiling it on your RPi. It will likely take several hours and you may run out of memory in case of some files - if that happens, you will need to set up a swap.
Petr "Pasky" Baudis
I compiled omxplayer on my pi, only took about 40 mins, I was pleasantly surprised.
I don't expect that your patch would push that out to several hours ;)
Hmm, I admit that I was trying that on the 256M version and gave up after it got into memory trouble about 30min. after the start. The rest was a conservative extrapolation. :)
Hi @triffid , how do you do that? Can you and/or @pasky also send me the binaries for omxplayer with seamless loop enabled? I'm having a really hard time to setup the crosscompile environment on my iMac with Mountain Lion.
And also, can you send me some links with instructions on how to compile it on the RasPi and also on my mac machine?
@mlemos on the pi just do make ffmpeg; make like it says in README.md
no idea about the mac, everything I've ever tried to do on a mac has been hours of frustration so I avoid them at all costs now.
Manos, you can download the binaries from http://pasky.or.cz/dev/omxplayer/omxplayer-loop-multifile-bin.tar.gz
Hi @pasky , thansk for the bin. But one last "dumb" question. How do I make it loop a single movie file?
Pass omxplayer the -L parameter.
Hey @pasky, thansk a lot man!!! It's working just fine here. Do you know if the amount of GPU RAM affects the vide playback experience?
Hi @pasky, looping with -L works a treat!!! I really appreciate your efforts with this feature. May I ask what is the syntax to play multiple files via the command line?
Hi! Glad you enjoy it. :) Simply list multiple files on the command line. Note that all the files must be encoded the same way, i.e. identical resolution, fps, etc.
Hi @pasky, thanks for the reply :)
I've tried: omxplayer 01.mp4 02.mp4 -o hdmi
and also to ensure it's the same res, fps, etc.: omxplayer 01.mp4 01.mp4 -o hdmi
Both stop at the first video. Is that the correct syntax?
Hi, are you sure you are using the latest version I posted? This was an issue with the original, old version from February; the new version from beginning of April should work...
I repeated the installation of the binary you posted, and it works now, I must have done something wrong. Thanks very much for the note about the videos needing to be the same encoding, that would have driven me crazy! Time to do some re-encoding...
Do you know of any clever way of storing the filenames in a playlist and having them load into the command using some sort of bash trickery?
Hi! If you have the filenames in a text file, one per line, try
cat playlist.txt | xargs omxplayer -o hdmi
as long as there are no spaces in the filenames, omxplayer $(<list.pls)
If you might have spaces in filenames, we need a hair more complexity: ( IFS=$'\n'; omxplayer $(<list.pls); )
Hi @pasky , it is working just fine for me for small videos. But for larger ones, it stops in the end of the first play (no loop). And it is not a huge video, the file is just 90MB.
Here is what I get on the output:
pi@raspberrypi /mnt/usbdisk1 $ omxplayer -L edit3-the-artist.mov thread nextreader 0x302470 (0) file : edit3-the-artist.mov result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 738 thread opened 0x302470 (0) openok 1 Video codec omx-h264 width 1280 height 720 profile 77 fps 29.970030 Subtitle count: 0, state: off, index: 1, delay: 0 thread nextreader 0x80c1e0 (0) file : edit3-the-artist.mov result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 738 thread opened 0x80c1e0 (0) openok 1
I waited a lot but nothing happened after that.
Another thing... do you know why videos being played from the usb disk plays better than videos played from the SD where the OS is installed?
Thanks @pasky and @triffid, your suggestions for work great for creating a pseudo playlist to play filenames with and without spaces in them.
@pasky, I wanted to understand more details to what exactly the files need to have in similar for them to play. I've run about 20 videos through a Handbrake script to reencode them uniformly, however whenever I return after stepping away, omxplayer has stopped. This may have something to do with @mlemos' query too?
Hi! I'm sorry it doesn't work well for you; it worked fine in my scenario. Unfortunately, I don't have enough free time to look into the issue, especially if I can't reproduce it.
@pasky thanks for your great work. Your binaries don't work for me too, so I want to set up my own RPi environment. I tried this RPi_Linaro_GCC_Compilation manual, but I had dozens of errors. Could you help me with some howtos of crosscompiling to RPi?
@pasky, no worries. I figured out the issue, the audio sample rate's were different, some at 44.1khz and some 48khz. Everything about the videos needs to be the same, including audio codec!
I found transcoding all vids through HandbrakeCLI useful for making this happen. Something like: HandBrakeCLI -e x264 -q 20 -r 25 -E faac -B 160 -6 dpl2 -R 44.1 -w 1920 -l 1080 -i filein.mp4 -o fileout.mp4
@pasky I have downloaded your binary dated April 2 2013, pasted into the /home directory, ran sudo tar -zxvf omxplayer-loop-multifile-bin.tar.gz, it unpacked, I then moved to the directory cd /omxplayer-dist/usr/bin, ran ./omxplayer file1.mp4 file2.mp4, and only one file runs then i get a have a nice day and it exits or stops.
I also tried ./omxplayer file1.mp4 file1.mp4, it plays the file 1 time and exits, same as above.
I could not get the command to take the -L option. Unless it was -l which is something else I suppose according to the documentation (start position, etc...)
What am I doing wrong? Any help would be greatly appreciated. Thanks
Hi! If you also have system-wide omxplayer installed, ./omxplayer wrapper script will execute that instead. You can either edit the script to remove /usr/bin/omxplayer.bin detection, or uninstall omxplayer system-wide. If that's not your case, I'm at a loss. :)
thanks @pasky, I did edit the script, now the loop function command is accepted.
The issue now is... I enter ./omxplayer -L file1.mp4 file2.mp4 at command line
it returns thread nextreader 0x1821430 (0) file : file1.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video s thread opened 0x1821430 (0) openok 1 Video codec omx-h264 width 1280 height 720 profile 100 fps 23.976025 Subtitle count: 0, state: off, index: 1, delay: 0 thread nextreader 0x1d62c10 (0) file : file2.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video s thread opened 0x1d62c10 (0) openok 1
meanwhile the file1.mp4 plays, but file2.mp4 never plays and it freezes. I have to end process to exit. Any suggestions. This appears to the issue that was happening from your February patch, i downloaded the patch from April. If anyone has suggestions i would greatly appreciate them. Thanks
I have just evaluated your branch. Starting with the Big Bucks Bunny h264 to a youtube MP4. The first play stutters very badly on the logo scene (also with your master branch). It stutters less with the current huceke master. I don't see any transition between the two video's at all, it hangs after the first.
This might be exactly what I'm looking for. However, being quite new in the Linux environment, I'm wondering how to install the new omxplayer replacing the one I already have in my Raspberry Pi?
Has anyone successfully compiled from source code natively on the R-Pi? I am running Raspbian and would love to be able to accomplish this.
When running make ffmpeg I get errors - unable to create the executable arm-unknown-linux-gnueabi-gcc. I do not know how to set up a cross compiler. I would need to make some changes to parameters that are output to the console for a project I am working on, but need to be able to compile. Anybody have a solution that they are able to provide? Thanks in advance.
I have compiled it on Arch Linux without any hassles even on 256MB Pi.
thanks for quick respnse @skinkie
You have cross compiled on Arch Linux? Have you compiled on pi itself with Raspbian?
I may be forced to cross compile, if so there is the headache of setting that up. Do you have the steps involved in this?
Thanks