Pete993
Posts: 5
Joined: Fri Dec 28, 2012 10:22 pm

OMXPlayer Black Screen

Fri Dec 28, 2012 10:39 pm

Hello there. I'm not entirely sure if this is the best place to put this, but here's my question. I'm fairly new to Linux, although I am quite familiar with both Windows and Mac OS. Anyway, whenever I use OMXPlayer to play any media (music or video) it seems to work fine. However, when the file is done playing and OMXPlayer quits, the screen becomes entirely black. It seems to be some kind of refreshing issue because when I move the mouse around or move existing windows around, it updates and the blackness goes away wherever I move things. This isn't a huge functional issue, but it's really annoying to have to "fix" the screen like this whenever I play any media. As I said, I'm new to Linux, so any advice would be appreciated. I think I saw somewhere a command you can give to the terminal that refreshes the screen, but I'd rather it do this automatically. I haven't be able to find any topics about this elsewhere.

Here's the basic info I can think to give:
Raspberry Pi Model B
Vanilla Raspbian “wheezy” OS (From this site)
HDMI output

I'm not sure what else would be useful. Let me know what other information you need and I'll be happy to get it.

gomako
Posts: 5
Joined: Sun Jul 01, 2012 8:49 pm

Re: OMXPlayer Black Screen

Sun Dec 30, 2012 10:07 pm

I have a sort of similar problem.

I have a usb flash drive and usb wifi dongle in the pi, leaving no room for a keyboard, which is fine, as I ssh into the pi from my mac. I leave the pi on all the time, and I think there's a powersaving mode which turns off the hdmi signal. So when I ssh in and play a file, nothing shows on the screen, but if I plug in a keyboard and hit a key, the screen wakes up and I can see fine.

I am looking for a command that will wake the hdmi, but am having trouble finding one!

Maybe that is what is happening with you? Does it happen when you start omxplayer, then quit out after a few seconds?

Pete993
Posts: 5
Joined: Fri Dec 28, 2012 10:22 pm

Re: OMXPlayer Black Screen

Wed Jan 02, 2013 12:55 am

gomako wrote:I have a sort of similar problem.

I have a usb flash drive and usb wifi dongle in the pi, leaving no room for a keyboard, which is fine, as I ssh into the pi from my mac. I leave the pi on all the time, and I think there's a powersaving mode which turns off the hdmi signal. So when I ssh in and play a file, nothing shows on the screen, but if I plug in a keyboard and hit a key, the screen wakes up and I can see fine.

I am looking for a command that will wake the hdmi, but am having trouble finding one!

Maybe that is what is happening with you? Does it happen when you start omxplayer, then quit out after a few seconds?
Well, for me, everything plays just fine. The problem I'm having is somewhat difficult to explain. When I run OMXPlayer to play any media file (audio or video) it runs and plays the file. However, when the file is finished playing (or if I exit it early) and OMXPlayer closes, the screen goes black, regardless of how long the file was playing for.

When I say the screen goes black, what I mean is my monitor is displaying the color black. The mouse is still visible, in whatever position it was in before I started playing the file, along with a small box around the mouse showing what was behind it. If I move the mouse around, the screen slowly removes the blackness wherever the mouse is moved, and previously removed blackness doesn't stay. If I grab a window and move it around, the entire window will become visible, and anywhere I move the window to will also become visible. To be able to see the screen entirely again, I have to either maximize an open window, or move it or the mouse around the screen until I've covered every inch of it to remove the blackness.

I know that explanation is kind of wordy, but I don't know how else to describe it. The screen isn't "going to sleep" as a power-saving function. It's literally just not updating the individual pieces of it until I make it do so. Incidentally, I am using a standard USB mouse and keyboard, and I'm using an ethernet connection, not Wi-Fi. This problem seems to occur when playing media on either the SD card or a USB flash drive.

boj
Posts: 1
Joined: Thu Dec 06, 2012 3:23 pm

Re: OMXPlayer Black Screen

Fri Feb 08, 2013 9:53 pm

Hi,
today I encountered to the same problem. I was not able to google anything about root cause or a fix neither workaround. Finally I've discovered utility xrefresh and this annoying situation is better now.

Anyway, I would appreciate any information to have the stuff the same as before I started playing with upgrades today - the current version of omxplayer and firmware are as below:

Code: Select all

$ vcgencmd version
Feb  7 2013 16:46:17 
Copyright (c) 2012 Broadcom
version 367974 (release)

$ apt-cache show omxplayer 
Package: omxplayer
Version: 0.2.4~subtitles~git20130128~f60f9019
...
Jiri

gomako
Posts: 5
Joined: Sun Jul 01, 2012 8:49 pm

Re: OMXPlayer Black Screen

Sat Mar 02, 2013 12:26 am

edit* I realised that this question was pretty much in the wrong place, OP was talking about another problem and I hijacked the thread whining about something totally different! :roll: but I've posted this solution to my own problem in case anyone ends up here the same way I did!

I found an answer that worked for me in this post -> http://www.raspberrypi.org/phpBB3/viewt ... 1&p=148323

Code: Select all

fbset -xres 1920 -yres 1080 -depth 16
I made an alias like this:

Code: Select all

alias wkup='fbset -xres 1920 -yres 1080 -depth 16'
and added it to ~/.bash_aliases so I could type 'wkup' into my blank screen and it would magically bring it back to life. I tried messing about with setterm and all sorts, but this is what finally worked for me. I have added 'setterm -powersave off' to some startup file that I can't remember, so I don't know if that has an effect as well.

I don't use omxplayer through xterm, so the xrefresh stuff didn't seem to work.

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: OMXPlayer Black Screen

Sat Mar 02, 2013 7:29 am

See http://elinux.org/Omxplayer where it has a section handily entitled "Black screen after playback" and the solution is ...
Or you can use a small bash script for video playback to do this every time:

Code: Select all

#/bin/bash
omxplayer "$@"
xrefresh -display :0
where "$@" is bash-ise for "$1", "$2", "$3" ... "$N" i.e the arguments passed to the above 'small script' are passed to the omxplayer instance it will invoke.

gomako
Posts: 5
Joined: Sun Jul 01, 2012 8:49 pm

Re: OMXPlayer Black Screen

Sun Mar 03, 2013 9:14 pm

Does xrefresh only work in a terminal started from the gui, or does it work on the command line you get when you first power up the pi? I'm new to Linux, so I'm keen to learn this sort of stuff.

I did see the omxplayer page, but it wouldn't work for me. I am not running startx when I boot up, just running things from the command line.

mushprin21
Posts: 13
Joined: Sun Mar 17, 2013 6:03 pm

Re: OMXPlayer Black Screen

Sun Mar 17, 2013 9:15 pm

[quote] happened to me too. I got over it thought. Is it a gpu fault[/quote]
The "hottest" computer you will ever find!
hahaha...

jehamann
Posts: 35
Joined: Sun Jun 16, 2013 11:36 pm
Contact: AOL

Re: OMXPlayer Black Screen

Wed Jul 24, 2013 1:03 am

Do you guys know how to get the sound to work on the raspberry pi? There no sound when I play games and I downloaded the omxplayer but as soon as it runs the entire screen goes black, Can anybody help?

DrNick
Posts: 16
Joined: Thu Oct 23, 2014 7:10 pm

Re: OMXPlayer Black Screen

Sat Oct 25, 2014 6:29 pm

Can anyone expand on how to use the script mentioned above. Preferably with some step wise help.
I am having the black screen issue but don't know how to use the fix mentioned above?
I posted here.
http://www.raspberrypi.org/forums/viewt ... 86#p631186

And I installed kweb as suggested by someone there but I am still having the same issue and have to exit everything to get out of omxplayer.
Thanks from a beginner..

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: OMXPlayer Black Screen

Sun Oct 26, 2014 10:11 am

Open a text editor of your choice and type in the lines of the commands you wish to run.

The first line, aka as hash-bang, indicates the shell interpreter in which those commands will run. Note it is incorrect in the cut 'n' paste job entered, it should be (with a ! included):

Code: Select all

#!/bin/bash
The bang being !.

This can be any shell/language you like, the example is the Bourne Again Shell bash. It could equally be perl, tcl, python or .. in a long list. The full path to the required shell is needed and can be determined for your particular system, prior to entering the text editor, with

Code: Select all

which bash
or 'which perl' ... or whatever.

Make sure the script and this location agree. The lines after the '#bang' are lines of text acceptable to the shell you've just defined so, in this example, they must be valid bash.

Save the file. You might call it omxplayer.sh. Then exit the text editor. You should then see the file if you use the 'ls' command, assuming you are in the directory where you saved the script.

The type

Code: Select all

chmod u+x omxplayer.sh
or whatever you called the script. This allows you to run the script as a 'command' as in:

Code: Select all

./omxplayer.sh
Without this you would have to type

Code: Select all

bash ./omxplayer.sh
i.e. run an instance of bash , sourcing your script into it. And you also would have to 'cd' (change directory) to where the script had been saved. This is cumbersome.

If you locate your script in a directory that is in the PATH of your login shell the you won't need to navigate to the directory, and you will be able to drop the './' bit too and simply type:

Code: Select all

omxplayer.sh
A common location is ~/bin i.e the bin sub-folder of your user directory. You can type

Code: Select all

echo $PATH
to determine locations that have already been included in your user PATH. Google, or search this forum, to see how to add entries to your PATH, in a manner that will survive log-outs, re-boots etc.

The location also can be seen which:

Code: Select all

which omxplayer.sh
which will show the full location i.e which directory in the PATH-list the script is located. Bear in mind the 'which' command scans the PATH-list and returns the first one found, so its not the way to find arbitrary bits of code, tucked away in crooks and crannies.

The script makes the assumption that omxplayer itself is in a location that can be found i.e. its in the PATH. Type

Code: Select all

 which omxplayer
to ensure this is the case; if which fails the script will fail. It may also fail for other users if their PATHs are different. A common method is to put the full path name to commands run within the script to ensure that it does not have an external dependency upon the users environment.

Hope this helps.

Dave

DrNick
Posts: 16
Joined: Thu Oct 23, 2014 7:10 pm

Re: OMXPlayer Black Screen

Sun Oct 26, 2014 9:01 pm

Thanks. Will give it a go when I next get a chance and feedback

DrNick
Posts: 16
Joined: Thu Oct 23, 2014 7:10 pm

Re: OMXPlayer Black Screen

Wed Oct 29, 2014 9:59 pm

Hi again. Thanks for the step by step guide. That worked a treat and i was able to use this script as a custom command line from file manager to view movies.
However, upon omxplayer command "q" I still don't return to the desktop. I get a black screen.
I can log on to pi with either SSH or Remote Desktop and it responds etc but I can't see the desktop till I reboot.

My script "omxplayerBash.sh" looks like this.

Code: Select all

#! bin/bash
xterm -fullscreen -fg white -bg black -e omxplayer -o hdmi -r "$1"
xrefresh -display :0
I then added a custom command line shown below.

Code: Select all

omxplayerBash.sh %f
Video plays fine but when I quit I get a black screen..
I can log on to pi with either SSH or Remote Desktop and it responds etc but I can't see the desktop till I reboot.

If I modify the script to

Code: Select all

#! bin/bash
xterm -fg white -bg black -e omxplayer -o hdmi "$1"
xrefresh -display :0
I can get it back by right clicking omxplayer in the task bar a selecting "close"

Anyone know how to do this from script?

Thanks.

DrNick
Posts: 16
Joined: Thu Oct 23, 2014 7:10 pm

Re: OMXPlayer Black Screen

Thu Oct 30, 2014 9:50 pm

Hi again...
It seems I have fixed my issue and it now all works perfectly..
It appears that I did not have enough memory set aside for the GPU. I set it to 32MB a while ago as I used my pi mainly for streaming.
I noticed that before the video started in omxplayer a message came up in xterm stating I needed 64MB.
I changed it and the 'q' button does indeed quit and return to desktop.
In the end I opted for the following script to start it up.

Code: Select all

#! bin/bash
xterm -p-fg white -bg black -e omxplayer -o hdmi -r "$1"
xrefresh -display :0
A happy camper... And my daughter will be now too as several of her DVDs are scratched and won't play but I have versions now playable in TV via RaspPi and omxplayer.
Thanks for the help.

Return to “Beginners”