Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for almost-seamless playback of multiple streams (optionally, in a loop) #127

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

pasky
Copy link

@pasky pasky commented Mar 2, 2013

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?

pasky and others added 21 commits January 24, 2013 19:56
This has not been throughly tested and should definitely
be considered a hack but is doing what I need.
There is some unknown resource leak occuring otherwise.
@mlemos
Copy link

mlemos commented Apr 3, 2013

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?

@pasky
Copy link
Author

pasky commented Apr 3, 2013

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

@triffid
Copy link

triffid commented Apr 3, 2013

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 ;)

@pasky
Copy link
Author

pasky commented Apr 3, 2013

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. :)

@mlemos
Copy link

mlemos commented Apr 7, 2013

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?

@triffid
Copy link

triffid commented Apr 7, 2013

@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.

@pasky
Copy link
Author

pasky commented Apr 7, 2013

Manos, you can download the binaries from
http://pasky.or.cz/dev/omxplayer/omxplayer-loop-multifile-bin.tar.gz

@mlemos
Copy link

mlemos commented Apr 7, 2013

Hi @pasky , thansk for the bin. But one last "dumb" question. How do I make it loop a single movie file?

@pasky
Copy link
Author

pasky commented Apr 7, 2013

Pass omxplayer the -L parameter.

@mlemos
Copy link

mlemos commented Apr 7, 2013

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?

@kelvin22
Copy link

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?

@pasky
Copy link
Author

pasky commented Apr 28, 2013

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.

@kelvin22
Copy link

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?

@pasky
Copy link
Author

pasky commented Apr 28, 2013

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...

@kelvin22
Copy link

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?

@pasky
Copy link
Author

pasky commented Apr 28, 2013

Hi! If you have the filenames in a text file, one per line, try

cat playlist.txt | xargs omxplayer -o hdmi

@triffid
Copy link

triffid commented May 1, 2013

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); )

@mlemos
Copy link

mlemos commented May 2, 2013

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?

@kelvin22
Copy link

kelvin22 commented May 8, 2013

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?

@pasky
Copy link
Author

pasky commented May 8, 2013

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.

@kramar42
Copy link

kramar42 commented May 9, 2013

@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?

@kelvin22
Copy link

kelvin22 commented May 9, 2013

@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

@scollins15
Copy link

@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

@pasky
Copy link
Author

pasky commented May 23, 2013

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. :)

@scollins15
Copy link

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

@skinkie
Copy link

skinkie commented May 29, 2013

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.

@paolovacirca
Copy link

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?

@scollins15
Copy link

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.

@skinkie
Copy link

skinkie commented Jul 3, 2013

I have compiled it on Arch Linux without any hassles even on 256MB Pi.

@scollins15
Copy link

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

@skinkie
Copy link

skinkie commented Jul 3, 2013

My Pi runs Arch Linux.

@scollins15
Copy link

@skinkie Ok,
Now I have been able to get make ffmpeg to complete on a Ubuntu machine, with some minor redirections in the makefile. I am now stuck on the make. It has an error command not found. Are there know changes that need to be addressed for me to be able to get this step to complete?

@zopyx
Copy link

zopyx commented Aug 14, 2013

Has anyone a binary for PI, Debian distro?

@paolovacirca
Copy link

It worked excellent before, but now, since I did a rpi-update, the video freezes on the last frame and plays no more.

@tlemmonsCV
Copy link

I am having the same problem as MrOaiki. Any ideas or fixes?
Any video I play with the -L to loop seems to play though and freeze on or near final frame. The console output is below.

thread nextreader 0x1bdd760 (0)
file : ./videos/5002.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 25
thread opened 0x1bdd760 (0) openok 1
Video codec omx-h264 width 1920 height 1080 profile 100 fps 30.000000
Subtitle count: 0, state: off, index: 1, delay: 0
thread nextreader 0x20bd810 (0)
file : ./videos/5002.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 25
thread opened 0x20bd810 (0) openok 1

-Edit (add)
Actually I ran it again without the -L and it still froze on last image. I have updated with rpi-update earlier today if that makes a difference like it did for MrOaiki

@paolovacirca
Copy link

I solved it by re-installing omxplayer. I simply removed the folder and all subfolders and copied a fresh version.

28 jan 2014 kl. 23:48 skrev Tom Lemmons [email protected]:

I am having the same problem as MrOaiki. Any ideas or fixes?

Any video I play with the -L to loop seems to play though and freeze on or near final frame. The console output is below.

thread nextreader 0x1bdd760 (0)
file : ./videos/5002.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 25
thread opened 0x1bdd760 (0) openok 1
Video codec omx-h264 width 1920 height 1080 profile 100 fps 30.000000
Subtitle count: 0, state: off, index: 1, delay: 0
thread nextreader 0x20bd810 (0)
file : ./videos/5002.mp4 result 1 format mov,mp4,m4a,3gp,3g2,mj2 audio streams 0 video streams 1 chapters 0 subtitles 0 length 25
thread opened 0x20bd810 (0) openok 1


Reply to this email directly or view it on GitHub.

@chipNET84
Copy link

Hi @pasky, thank you for great work.
I try out the binary you listed above. But when I use this binary, the video is not played such smooth as with the regular omxplayer from package manager (apt-get install omxplayer). Is the hardware acceleration for raspberry pi not supported in the used libs?

@chipNET84
Copy link

I also testet to checkout the "multiplestream" branch from https://github.com/pasky/omxplayer.git and compile it. After finish it, I have the same not smooth playback result.
What are the differences between the libs from package manager and the self compiled one? Do I need some optimization flags durring compilation to work with raspberry?
I compare the revisions ob the generated libs, e.g. libavcodec.so.54.56.100, the one from package manager is newer with libavcodec.so.55.xx.xxx
How could I improve the playback on raspberry pi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.