ScreenManager transition to a Screen with a playing Video

238 views
Skip to first unread message

Pablo Ochendrowitsch

unread,
Aug 25, 2015, 7:01:06 PM8/25/15
to Kivy users support
Hi ... im implementing a sclrollable multi video screen.
Depending on user input and net messages the screeen will change from one video to other

When the ScreenManager transition is Slide it works, but if i select FadeTransition or any ShaderTransition i have 2 type of error (depending on the video format (WhaaaT)

with an mp4 o mkv video it fails with a cryptic 

Fatal Python error: (pygame parachute) Segmentation Fault
Abortado

if the video is a avi file (mjpg codec) fails at shader compile

File "/home/losky/desa/gym/lights-python/socketserver.py", line 612, in process_request_thread
     self.finish_request(request, client_address)
   File "/home/losky/desa/gym/lights-python/socketserver.py", line 344, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File "/home/losky/desa/gym/lights-python/socketserver.py", line 668, in __init__
     self.handle()
   File "/home/losky/desa/gym/lights-python/conexion.py", line 16, in handle
     self.procesar(data)
   File "/home/losky/desa/gym/lights-python/conexion.py", line 26, in procesar
     listener.procesar(data.upper())
   File "/home/losky/desa/gym/lights-python/puesto.py", line 44, in procesar
     self.ui.nuevo_estado("publicidades")
   File "/home/losky/desa/gym/lights-python/pantallas.py", line 35, in nuevo_estado
     self.current = pantalla.name
   File "kivy/properties.pyx", line 345, in kivy.properties.Property.__set__ (kivy/properties.c:3654)
   File "kivy/properties.pyx", line 377, in kivy.properties.Property.set (kivy/properties.c:4169)
   File "kivy/properties.pyx", line 431, in kivy.properties.Property.dispatch (kivy/properties.c:4823)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 852, in on_current
[DEBUG  ] [VideoGstplayer] Load <videos/alegria.avi>
     self.transition.start(self)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 325, in start
     self.add_screen(self.screen_in)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 441, in add_screen
     self.fbo_in = self.make_screen_fbo(self.screen_in)
   File "/usr/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 417, in make_screen_fbo
     fbo = Fbo(size=screen.size)
   File "kivy/graphics/fbo.pyx", line 139, in kivy.graphics.fbo.Fbo.__init__ (kivy/graphics/fbo.c:2640)
   File "kivy/graphics/instructions.pyx", line 723, in kivy.graphics.instructions.RenderContext.__init__ (kivy/graphics/instructions.c:9991)
   File "kivy/graphics/shader.pyx", line 175, in kivy.graphics.shader.Shader.__init__ (kivy/graphics/shader.c:3464)
   File "kivy/graphics/shader.pyx", line 594, in kivy.graphics.shader.Shader.vs.__set__ (kivy/graphics/shader.c:8999)
   File "kivy/graphics/shader.pyx", line 468, in kivy.graphics.shader.Shader.build_vertex (kivy/graphics/shader.c:7063)
   File "kivy/graphics/shader.pyx", line 488, in kivy.graphics.shader.Shader.link_program (kivy/graphics/shader.c:7310)
   File "kivy/graphics/shader.pyx", line 533, in kivy.graphics.shader.Shader.get_program_log (kivy/graphics/shader.c:7883)
 ValueError: size must be zero or positive


i reeealy don't know where to start working on this problem.
in any case i would prefer to resolve the problem in the mp4, mkv case

Any clues ?

Thanks in advance
Losky

Andrei Sima

unread,
Aug 27, 2015, 4:21:04 AM8/27/15
to kivy-...@googlegroups.com
Hi,

I have tried to put 3 videos in different screens and FadeTransition passed as an property to the ScreenManager.
On my configuration it works.(attached code).

I do have a warning:

[INFO   ] [Shader      ] program: <WARNING: Output of vertex shader 'frag_color' not read by fragment shader>


This warning i think is related to the shader transition (FadeTransition) that i do not have deep knowledge of @present moment

But the app is  working.

What i guess that is happening on your side is that the video that you try to display are not quite let`s say 'Kivy ready' video

Let`s get into video a bit here. It is tricky so bear with me.

A video file usually has 2 or 3 components (this is how i think of video):

1 CONTAINER
2 ENCODED VIDEO OBJECT
3  ENCODED AUDIO OBJECT (can be or not be present -> the container do not has a audio track or is zeroed, depending of the needs you have -> i do not get into detail because it will be very messy, some players do break if they do not have an audio track to read from some just ignore the lack of audio track). I will not touch this in the post


Container... think of it as a box where you can put some kind of video objects, not all of them - we get there later
Encoded video object as it says this is the video object encoded with some codec.

Example


and supports following video codecs for the video object (below are not all of them):

JPEG, H264, AppleProRes (various encoding types 4444, 442 HQ, etc), animation (it is RAW information not compressed) if i remember correctly it can contain also FLV, but i am not sure of that.

Now if i want to put different video encoded object that is not supported by the mov container usually the app that is doing that for me either will raise and error or will not have this option at all.


So even if you see as a human a file named MOV, you can not tell what encoding has and if the player / app will manage to play that file.
You actually need to get the file info (property) and see what encoding was used there. *not all operating system display that by default (attached from MacOS info).
Here you see that the file is an mp4 (MPEG-4 video), with video encoding H264 (https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC)
and audio encoded AAC 

For example on a regular machine you will never be able to play a MOV with AppleProRes 4444 HQ encoding. It has to much information per second (bitrate) for a regular computer to handle. You will need a monster machine to process that (multiprocessing, multicore, monster video card/s, and on rendering parallel computing is a must (network rendering) if you need the file in a decent amount of time and sometimes within your lifetime :) ).

Now let us get to more specific talking.

As for 5-6 years since the boom of HTML5 and Youtube, the Web Video tends to standard to H.264 encoding, which i quite like because is easy to manage and to set up (for me from Adobe After Effects). Also some video stations (HD ones) broadcast H.264 video streams.

This kind of video encoding will work on almost any modern device. If youtube is working on that machine then the codec will be OK.

I do try not to get deep into video problem but you need to understand what codecs are good for your app and what codecs are not.

I guess on your side that you have a codec related problem.
This can be one of the following or all or some

1 Codec is not Kivy compatible
2 Bitrate is to high
3 Your codecs have issues.
4 The video object was no properly encoded for your needs

An the list can go on, but this i what i can think of right now.

As a solution... try to re encode your videos in H264 format, with youtube settings (a google search can help you better than i can in a post)

And above is just the tip of the iceberg related to videos. I used to video edit / video content create in the past and sometimes the encoding process can be a pain in the but due to codec restrictions, client request, app request, the machine that will play that video, etc.

I used to create content for 
Youtube search: Stratosphere Dome
And it took me about 1 month to setup a proper pipeline from 3d render to final video.

Hope it helps.

P.S. I can not upload the video folder (148 MB)


____________________
Andrei Sima
0723.223.883

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Screen Shot 2015-08-27 at 10.42.58.png
main.py
videoscreenmanager.kv

Pablo Ochendrowitsch

unread,
Aug 28, 2015, 6:12:23 PM8/28/15
to Kivy users support
I had investigated more on the type of problem and the result was that had nothing to do with shaders
It was a threading problem, the solution was to use de @mainthread decorator on the method that trigers the transitions

Now im in front of new problems trying to make the app run on a Raspberry Pi... but with proper encoded videos (buck bunny) for testing

Thanks for your answer
Losky

Andrei Sima

unread,
Aug 31, 2015, 3:00:11 AM8/31/15
to kivy-...@googlegroups.com
Kivy multithreading must run only from the main thread. Doing another way might work but you have no guarantee on that. You did not posted the code so i had to guess.

For the Raspi issue... i will try it myself, but i have lubuntu on my RasPi2 and the result might be different in my case, as i read that you are using Raspbian. I will post the result  on this on the designated thread.
 

____________________
Andrei Sima
0723.223.883

Pablo Ochendrowitsch

unread,
Aug 31, 2015, 1:48:27 PM8/31/15
to Kivy users support
i think that this is the most relevant part of the code

class PantallaPublicidades(Screen):
    fuente = ObjectProperty(None)

class MyScreenManager(ScreenManager):
    @mainthread
    def nuevo_estado(self, estado):
        pantalla = self.new_pantalla_publicidades()
        self.add_widget(pantalla)
        self.current = pantalla.name

    def new_pantalla_publicidades(self):
        publicidades = PantallaPublicidades()
        publicidades.fuente = "buck_bunny.mp4"
        publicidades.name = str(time.time())
        return publicidades
    
And in the .kv file

<MyScreenManager>:
    transition: FadeTransition()
    PantallaPublicidades:
    InitScreen:

<PantallaPublicidades>:
    name: 'publicidades'    
    Video:
        source: self.parent.fuente 
        state: 'play'
        options: {'allow_stretch': True}


When de app starts it presents de initScreen. When the network connects to a server, the "nuevo_estado" method is called.
It creates a new PantallaPublicidades and makes it visible


Losky
Reply all
Reply to author
Forward
0 new messages