udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Video Processing

Fri Jul 11, 2014 3:47 pm

I'm new with this and I want to do is receive UDP video stream and modify the video and display through TV (HDMI) and I have to do this using python. I'm thinking of using openCV and receive stream and modify the frames and I have no idea about how to rebuild the video without saving the video or is it possible to display frames directly. Also openCV does not support for audio so FFMPEG is the only one thing came to my mind.

I appreciate that if someone can point out the steps, suggestions or any other alternatives.

Thank you.

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Video Processing

Fri Jul 11, 2014 4:26 pm

It may depend on exactly what you mean by "modify the frames" but my immediate reaction is that the words "video", "python" and "Raspberry Pi" don't belong in the same sentence. (Speed reasons!)

Can you explain a bit more?

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Sat Jul 12, 2014 4:15 am

I'm trying to do is add .jpeg frames or .gif frames to UDP video stream and display through TV.
Is there any way to play two or more files/UDP video streams at same time and display on TV using omxplayer with different resolution.
Attachments
Untitled.png
Untitled.png (3.14 KiB) Viewed 3959 times

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Sat Jul 12, 2014 5:39 am

Yes, you can run more than one instance of omxplayer and define the screen area with the --win option. But none of the videos should have 1080p. I managed to run four instances at the same time, one 720p and three SD videos.

To control multiple instances via dbus use --dbus_name and different names for the streams.

You even can overlay the videos using different layers (--layer option).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Mon Jul 14, 2014 6:12 am

Thank you for your information. Is there any tutorials that I can find more details about this.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Mon Jul 14, 2014 7:10 am

I'm afraid there is no tutorial. The best source of information is:
https://github.com/popcornmix/omxplayer
(scroll to the bottom of the page).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Mon Jul 14, 2014 9:16 am

Thank you.

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Wed Jul 16, 2014 6:29 am

command1='omxplayer --win "0 0 1920 880" -o hdmi -d --layer 10 DD.mp4'
command2='omxplayer --win "0 880 1920 1080" -o hdmi -d --layer 20 CC.mp4'

sp.Popen(command1,shell=True)
sp.Popen(command2,shell=True)

Using above codes I can open two omxplayers like in above picture. But when playing videos they are frozen in both players and audio is playing. Some times screen turns black and nothing displayed only audio is playing. These CC/DD.mp4 are not HD videos. Is this because of speed and memory of raspberry pi or the method I'm using is wrong. I can't figure this out please help.

Thanks.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Wed Jul 16, 2014 7:40 am

Get the latest omxplayer.

Try overclocking the GPU ( i use gpu_freq=400).

Put a small delay between both calls. When you start omxplayer, the ARM processor goes to 100% for a short while;I assume this is caused by ffmpeg doing some kind of analysis of the video. It drops to 10 - 30 % afterwards. Starting two at the same time sometimes causes problems.

Try using different different dbus names for both videos:
--dbus_name org.mpris.MediaPlayer2.omxplayer1
--dbus_name org.mpris.MediaPlayer2.omxplayer2
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Wed Jul 16, 2014 11:23 am

Thanks for the reply.

I used "sudo apt-get install omxplayer" and it says omxplayer is already newest version.
build date : sat 22 march 2014 20:58:15 +0000
version : 39e6342 [master]

Also I changed the code like this
command1='omxplayer --win "0 0 1920 880" -o hdmi -d --dbus_name org.mpris.MediaPlayer2.omxplayer1 --layer 5 DD.mp4'
command2='omxplayer --win "0 880 1920 1080" -o hdmi -d --dbus_name org.mpris.MediaPlayer2.omxplayer2 --layer 3 CC.mp4'

sp.Popen(command1,shell=True)
time.sleep(5)
sp.Popen(command2,shell=True)

arm_freg=900
gpu_freq=400
core_freq=250
sdram_freq=450
over_voltage=2

still same problem need help
Thanks.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Wed Jul 16, 2014 12:37 pm

Get the newest omxplayer from:

http://omxplayer.sconde.net/

Try from the command line first, one video at a time.

I always use subprocess.Popen with a list and without setting shell=True.

If you set the the gpu_freq, you are setting the core_freq at the same time, so setting it again may not work at all. To set any of the GPU frequencies you must also set:
force_turbo=1
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Wed Jul 16, 2014 2:02 pm

I entered the following commands

wget http://omxplayer.sconde.net/builds/omxp ... _armhf.deb
dpkg -i omxplayer_0.3.5~git20140624~0be4eec_armhf.deb

In second command it gives me error message saying
files list file for package `libxext6:armhf contain' contains empty file name

what am I missing here please help.

Thanks.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Wed Jul 16, 2014 2:07 pm

did you forget sudo?
sudo dpkg ...
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Wed Jul 16, 2014 2:38 pm

Sorry about that and thanks for the help but same error message. I tried in root user also, but same.
I'm using 2013-09-25-wheezy-raspbian image but updated, do I need download latest image.

Thanks.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Wed Jul 16, 2014 2:52 pm

run
sudo apgt-get update
sudo apt-get ugrade
sudo rpi-update

and reboot.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Thu Jul 17, 2014 6:56 am

I downloaded the latest image (2014-06-20-wheezy-raspbian) and then,
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

completed.

Then installed latest omxplayer from http://omxplayer.sconde.net/
sudo apt-get install libpcre3 fonts-freefont-ttf
sudo apt-get install fbset
sudo wget http://omxplayer.sconde.net/builds/omxp ... _armhf.deb
sudo dpkg -i omxplayer_0.3.5~git20140624~0be4eec_armhf.deb

done.

build date : The 24 jun 2014 19:41:57 +0000
version : 0be4eec [master]

Then add these values to /boot/config.txt
force_turbo=1
gpu_freq=400

I changed my python code to
command1='omxplayer', '--win', '0 0 1920 880', '-o', 'hdmi', '-d', '--dbus_name', 'org.mpris.MediaPlayer2.omxplayer1', '--layer', '5', 'DD.mp4'
command2='omxplayer', '--win', '0 880 1920 1080', '-o', 'hdmi', '-d', '--dbus_name', 'org.mpris.MediaPlayer2.omxplayer2', '--layer', '6', 'CC.mp4'


sp.Popen(command1)
time.sleep(5)
sp.Popen(command2)

I still got the problem is there any thing wrong in these steps please help.

Thanks.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Thu Jul 17, 2014 7:11 am

I suppose you simply forgot the square brackets here (or Python would be complaining).

Try both commands from the command line, e. g. through a ssh connection, one at a time. Does the video play? If not, use the -g option to get a log file.

you might also test the videos first without any options, like
omxplayer DD.mp4
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Thu Jul 17, 2014 8:27 am

command1='omxplayer', '--win', '0 0 1920 880', '-o', 'hdmi', '-d', '--dbus_name', 'org.mpris.MediaPlayer2.omxplayer1', '--layer', '5', 'DD.mp4'
command1=['omxplayer', '--win', '0 0 1920 880', '-o', 'hdmi', '-d', '--dbus_name', 'org.mpris.MediaPlayer2.omxplayer1', '--layer', '5', 'DD.mp4']

When i use [ ] python generates error message.

omxplayer CC.mp4
omxplayer DD.mp4
works nicely.

I tried two commands in two ssh connections. When I enter the first command
omxplayer --win "0 0 1920 880" -o hdmi -d --dbus_name org.mpris.MediaPlayer2.omxplayer1 --layer 5 DD.mp4
works fine. But when I enter second command to other ssh connection
omxplayer --win "0 880 1920 1080" -o hdmi -d --dbus_name org.mpris.MediaPlayer2.omxplayer2 --layer 6 CC.mp4
both videos frozen. Some times both audio is playing and some times audio and video both frozen.

both commands are working fine for playing one video at a time.

Then I execute two commands with -g option and I got two log files but I don't know how to find the problem so I attach them. I have no idea to solve this please help.

Thanks.
Attachments
omxplayer.rar
(56.54 KiB) Downloaded 67 times

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Thu Jul 17, 2014 9:44 am

How much memory did you give to the GPU?
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Thu Jul 17, 2014 9:50 am

I set it to 400 by using gpu_mem=400 still not working.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Thu Jul 17, 2014 10:07 am

udara wrote:I set it to 400 by using gpu_mem=400 still not working.
That's too much (will be missing on the processor side), 128 MB are enough.

At the moment I'm at a loss; I know that I have successfully played up to four videos at the same time (repeatable) with a similar setup. You might try my solution (omxplayerGUI, part of Minimal Kiosk Browser). Simply open one video after the other from the browsers "Open" button. They'll be played inside a window; just to make sure that it works as it does on my side and with my beta testers.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Thu Jul 17, 2014 10:15 am

How can I get your solution.
Thanks.

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Thu Jul 17, 2014 10:30 am

Is there any way to do these things with using HTML5, omxplayer and python.

Thanks,

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Video Processing

Thu Jul 17, 2014 10:59 am

udara wrote:How can I get your solution.
Thanks.
http://www.raspberrypi.org/forums/viewtopic.php?t=40860
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

udara
Posts: 50
Joined: Fri Jul 11, 2014 3:27 pm

Re: Video Processing

Fri Jul 18, 2014 2:31 pm

Thanks for your solution "gkreidl".
I'm using Raspbian in my Raspberry Pi, If I use OpenELEC or RaspBMC is there any chance to work using my code?
Thanks.

Return to “Beginners”