jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

[SOLVED] Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Dec 30, 2019 2:59 am

Hello,
I'm a newbie at Raspberry and Omxplayer's world;
and I'm not good at English,
but I'll try my best to describe my question.

I build a tiny website by Django and Python,
and I want to use this website to control my Raspberry Pi (4B) to play 2 or more video at the same time.

My test code as below:

Code: Select all

try:
    player = OMXPlayer(file_path[:-9] + 'static/video.mp4',
                       args=['--loop', '--win', '0 0 960 1080', '--no-osd'],
                       dbus_name='org.mpris.MediaPlayer2.omxplayer0')
    player.set_volume(0)
    player.set_aspect_mode('letterbox')
    
    player2 = OMXPlayer(file_path[:-9] + 'static/video2.mp4',
                        args=['--loop', '--win', '960 0 1920 1080', '--no-osd'],
                        dbus_name='org.mpris.MediaPlayer2.omxplayer1')
    player2.set_volume(0)
    player2.set_aspect_mode('letterbox')
    
except Exception as e:
    print (e)
I always use mp4 file,
if video is 720p, this code could play 2 video at the same time normally.
But when I change 1 video to 1080p,
the 1080p video cannot play and get the Exception as below:

Code: Select all

org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying
I had tried to use Terminal to call Omxplayer play 1080p video,
it played normally.

Thank you for reading this topic and your reply!
Last edited by jakeasa123 on Tue Jan 07, 2020 1:54 am, edited 3 times in total.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7884
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Dec 30, 2019 7:02 am

Increase gpu_mem in config.txt, either manually or via raspiconfig.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Tue Dec 31, 2019 4:17 am

6by9 wrote:
Mon Dec 30, 2019 7:02 am
Increase gpu_mem in config.txt, either manually or via raspiconfig.
Thanks to your reply!

I tried to increase gpu_mem as you said from 76 to 256 and 512,
but I meet new question.

After I increase to 256 and click Play button,
Pi world play first 720p video normally,
after first video player,
second 1080p video will play in a snap,
then screen closed quickly and Pi stop sending HDMI signal.

I thought it probably is gpu_mem not enough,
so increase it to 512,
but it didn't solve question.

Thank you for reading this reply and your reply!

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Thu Jan 02, 2020 3:51 am

jakeasa123 wrote:
Tue Dec 31, 2019 4:17 am
6by9 wrote:
Mon Dec 30, 2019 7:02 am
Increase gpu_mem in config.txt, either manually or via raspiconfig.
Thanks to your reply!

I tried to increase gpu_mem as you said from 76 to 256 and 512,
but I meet new question.

After I increase to 256 and click Play button,
Pi world play first 720p video normally,
after first video player,
second 1080p video will play in a snap,
then screen closed quickly and Pi stop sending HDMI signal.

I thought it probably is gpu_mem not enough,
so increase it to 512,
but it didn't solve question.

Thank you for reading this reply and your reply!
I found the solution to this question.

After I increased gpu_mem as 6by9 said,
I found if there had a gap between 2 video,
could play 2 video at the same time normally.

And I read this topic https://www.raspberrypi.org/forums/view ... p?t=131413,
so I change code by add --layer args as below:

Code: Select all

try:
    player = OMXPlayer(file_path[:-9] + 'static/video.mp4',
                       args=['--loop', '--win', '0 0 960 1080', '--no-osd', '--layer', '1'],
                       dbus_name='org.mpris.MediaPlayer2.omxplayer0')
    player.set_volume(0)
    # player.set_aspect_mode('letterbox')

    player2 = OMXPlayer(file_path[:-9] + 'static/video2.mp4',
                        args=['--loop', '--win', '960 0 1920 1080', '--no-osd', '--layer', '2'],
                        dbus_name='org.mpris.MediaPlayer2.omxplayer1')
    player2.set_volume(0)
    # player2.set_aspect_mode('letterbox')

except Exception as e:
    print(e)
It played normally now.

Thank you!

aBUGSworstnightmare
Posts: 1610
Joined: Tue Jun 30, 2015 1:35 pm

Re: [Solved] Cannot play 2 or more 1080p video by Omxplayer and Python

Thu Jan 02, 2020 7:36 am

https://m.youtube.com/watch?v=trY4hLSOpjw
In the vudeo four FHD videos are played with OMXplayer in window mode.

Make sure to leave a gap between the windows.

Note: I figured out that not all monitors (!) are able to do this! On one of my older 19in monitors playback failed because the TFT timing was incorrectly implemented in the monitors A/D board

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Thu Jan 02, 2020 10:04 am

I thought I meet a new question...

I try to add video player to 4,
so I edit win position as below:
video 1: 0 0 960 540
video 2: 960 0 1920 540
I expected video 1 could play at left top side and video 2 at right top side,
and bottom for video 3 and 4.

But after play first video player,
second video will play in a snap,
then screen closed quickly and Pi stop sending HDMI signal.

I try to add a gap as aBUGSworstnightmare said,
so win position now are:
video 1: 0 0 960 540
video 2: 1000 0 1920 540
and my test code as bolow:

Code: Select all

player = OMXPlayer(file_path[:-9] + 'static/video.mp4',
                   args=['--loop', '--win', '0 0 960 541', '--no-osd', '--layer', '1'],
                   dbus_name='org.mpris.MediaPlayer2.omxplayer0')
player.set_volume(0)
# player.set_aspect_mode('letterbox')

player2 = OMXPlayer(file_path[:-9] + 'static/video2.mp4',
                    args=['--loop', '--win', '1000 0 1920 540', '--no-osd', '--layer', '2'],
                    dbus_name='org.mpris.MediaPlayer2.omxplayer1')
player2.set_volume(0)
# player2.set_aspect_mode('letterbox')
* I haven't added the video 3 and 4 code yet.

I had try 2 pairs of position.

The first one is "0, 0, 960, 1080" to video 1 and "960, 0, 1920, 540" to video 2,
it played normally.

The second one is "0, 0, 960, 540" to video 1 and "960, 0, 1920, 1080" to video 2,
it played normally, too.

Thanks to your reading and your reply!

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Jan 06, 2020 1:53 am

I had tried some combination to test that could played normally or not.

1st combination with 2 OMXPlayer:
- P1 Position: 0 0 960 540
- P2 Postion: 961 541 1920 1080
- Play normally

2nd combination with 2 OMXPlayer:
- P1 Position: 0 0 960 540
- P2 Postion: 960 540 1920 1080
- Play normally

3rd combination with 4 OMXPlayer:
- P1 Position: 0 0 480 270
- P2 Postion: 480 270 960 540
- P3 Postion: 960 540 1440 810
- P4 Postion: 1440 810 1920 1080
- Play normally but lost some fps

4th combination with 4 OMXPlayer:
- P1 Position: 0 0 480 270
- P2 Postion: 480 270 960 540
- P3 Postion: 960 0 1440 270
- P4 Postion: 1440 270 1920 540
- Play failed when P3 start

5th combination with 3 OMXPlayer:
- P1 Position: 0 0 480 270
- P2 Postion: 720 0 1200 270
- P3 Postion: 1440 0 1920 270
- Play failed when P2 start

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

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Jan 06, 2020 8:41 am

The RPi H264 GPU codec is limited to one 1080p video. If you want to run multiple videos on the screen at the same time you have to reduce the resolution of the videos.
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

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Jan 06, 2020 9:27 am

gkreidl wrote:
Mon Jan 06, 2020 8:41 am
The RPi H264 GPU codec is limited to one 1080p video. If you want to run multiple videos on the screen at the same time you have to reduce the resolution of the videos.
Hello,
thanks to your reply!

But I had a question about the limit.
I use "ffmpeg -i" to check my all video (1 to 4),
them are 1920x1080 video.

Why them could play at the same time in some position setting?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7884
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Mon Jan 06, 2020 11:50 am

You're looking at 2 different things.

1) The codec block was originally specified for one 1080p30 decode (H264 level 4.0). Improvements in performance and a minor overclock allow for decode of most 1080p60 streams. If you choose to try decoding more than 1080p60, whether in one stream or multiple, then it won't decode in realtime.
Whilst the H264 block hasn't been significantly upgraded on Pi4, but the drop in process node to 28nm does allow it to run a bit faster (sorry, I don't have exact numbers).

2) The HVS (Hardware Video Scalar) is responsible for composing the scene to be output over the HDMI port. All the images have to be read from SDRAM to generate each line of the display. If you are downscaling, or have multiple overlapping layers, then it ends up having to read multiple input lines to generate one output line. This is all done "online", therefore when you hit the limit of how much data it can read in per line period, FIFOs underflow and you get incomplete output. That will often lead to the monitor losing sync.

Having a gap between windows is unlikely to make any significant difference. The HVS still has to read the whole line(s) of the source image to produce the one output line.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jakeasa123
Posts: 9
Joined: Tue Nov 26, 2019 3:43 am

Re: Cannot play 2 or more 1080p video by Omxplayer and Python

Tue Jan 07, 2020 1:53 am

6by9 wrote:
Mon Jan 06, 2020 11:50 am
You're looking at 2 different things.

1) The codec block was originally specified for one 1080p30 decode (H264 level 4.0). Improvements in performance and a minor overclock allow for decode of most 1080p60 streams. If you choose to try decoding more than 1080p60, whether in one stream or multiple, then it won't decode in realtime.
Whilst the H264 block hasn't been significantly upgraded on Pi4, but the drop in process node to 28nm does allow it to run a bit faster (sorry, I don't have exact numbers).

2) The HVS (Hardware Video Scalar) is responsible for composing the scene to be output over the HDMI port. All the images have to be read from SDRAM to generate each line of the display. If you are downscaling, or have multiple overlapping layers, then it ends up having to read multiple input lines to generate one output line. This is all done "online", therefore when you hit the limit of how much data it can read in per line period, FIFOs underflow and you get incomplete output. That will often lead to the monitor losing sync.

Having a gap between windows is unlikely to make any significant difference. The HVS still has to read the whole line(s) of the source image to produce the one output line.
Appreciate to your detail explanation and kind introduction.

I couldn't fully understand to all noun in your reply right now,
but I'll learning more about them.

Thank you again for your clear and kind reply. :D

Return to “Troubleshooting”