kivy / kivy

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS
https://kivy.org
MIT License
17.61k stars 3.06k forks source link

Failure to play h264 video stream using VideoGstplayer #4768

Open derekbrokeit opened 7 years ago

derekbrokeit commented 7 years ago

I am bringing this issue from stackoverflow because I found the issue-tracker.

I have a c++ program that uses live555 in a winapi kernel event-loop that passes images from a camera to libopenh264 and then served as an RTSP stream using ffmpeg. The stream can be viewed fine using VLC. The event-loop also records to an avi container.

I wanted to setup a remote-viewing client using kivy using the simple kvlang below:

BoxLayout:
    orientation: "vertical"
    Video:
        source: "rtsp://ip.address:8554/stream"
        play: True

The window does not display a Video object, and the logging output has the following errors

[ERROR             ] [Image       ] Error reading file rtsp://ip.address:8554/stream
# ...
[ERROR             ] [VideoGstplayer] Could not open resource for reading and writing.

When I change the stream encoding to MJPEG, the video player displays the live video without errors (except a single error under Image). Furthermore, when I change source to the file-path of the h264 encoded avi file that is recorded, it plays without errors. Is there a configuration that can alert the VideoGstplayer of the expected encoding? Alternatively, is there a problem with my stream setup that the provided kivy player cannot read it properly? Perhaps I am missing a gstreamer dll, but the message does not alert me to anything such as that.

I have a working version of openh264, so I am wondering if the gstreamer implementation (inside the wheel) needs to be compiled with additional libraries in order to use h264. Although, I am left wondering why it can play recorded h264 video and not a stream. Could this be a problem with gop-size?

This was all performed on windows using the basic installation instructions for installing python-dependencies. kivy version being used is 1.9.1. Thank you for any help, I am new to kivy.

derekbrokeit commented 7 years ago

Just to add another data point. I tried this using a purely python implementation (examples\widgets\videoplayer.py) and found the same results. Although, in this case, using the h264 stream actually crashed the program. On the bright side, an MJPEG stream plays after a few seconds.

Side Note: It is also somewhat surprising to see the additional widgets (stop/play, audio, loading) when running this from the python version without a kvlang implementation. Is there a reason for the difference between kvlang and python Video player implementations?

FeralBytes commented 7 years ago

@derekbrokeit Please provide full logs of both implementations; also please provide full source code implementations. Thank you.

Zen-CODE commented 7 years ago

@derekbrokeit. The difference may be the using the 'Video' vs. 'VideoPlayer' widgets? As for the h264 issue, sorry, beyond my ken :-)

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

tshirtman commented 5 years ago

just tried to make an example of displaying an rtsp stream using gstplayer, and it indeed doesn't work.

from kivy.app import App
from kivy.lang import Builder

KV = '''
Video:
    source: 'rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream'
    state: 'play'
'''

class StreamApp(App):
    def build(self):
        return Builder.load_string(KV)

if __name__ == '__main__':
    StreamApp().run()
[INFO   ] [Logger      ] Record log in /home/gabriel/.kivy/logs/kivy_19-05-25_2.txt
[INFO   ] [Kivy        ] v1.11.0.dev0, git-0f39c0d, 20190508
[INFO   ] [Kivy        ] Installed at "/home/gabriel/dev/kivy/kivy/__init__.py"
[INFO   ] [Python      ] v3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0]
[INFO   ] [Python      ] Interpreter at "/home/gabriel/.virtualenvs/kivy36/bin/python"
[INFO   ] [Factory     ] 184 symbols loaded
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[INFO   ] [ImageLoaderFFPy] Using ffpyplayer 4.0.1
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif 
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG  ] [App         ] Loading kv <./stream.kv>
[DEBUG  ] [App         ] kv <./stream.kv> not found
[INFO   ] [VideoGstplayer] Using Gstreamer 1.14.1.0
[INFO   ] [Video       ] Provider: gstplayer
[DEBUG  ] [Window      ] Ignored <egl_rpi> (import error)
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'3.0 Mesa 18.2.8'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel Open Source Technology Center'>
[INFO   ] [GL          ] OpenGL renderer <b'Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2) '>
[INFO   ] [GL          ] OpenGL parsed version: 3, 0
[INFO   ] [GL          ] Shading version <b'1.30'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[DEBUG  ] [Shader      ] Fragment compiled successfully
[DEBUG  ] [Shader      ] Vertex compiled successfully
[DEBUG  ] [ImageSDL2   ] Load </home/gabriel/dev/kivy/kivy/data/glsl/default.png>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[ERROR  ] [Image       ] Error reading file rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream
[DEBUG  ] [Base        ] Create provider from mouse
[DEBUG  ] [Base        ] Create provider from probesysfs,match=LGDisplay
[DEBUG  ] [ProbeSysfs  ] using probesysfs!
[DEBUG  ] [ProbeSysfs  ] found device: SynPS/2 Synaptics TouchPad at /dev/input/event5
[DEBUG  ] [ProbeSysfs  ] found device: Melfas LGDisplay Incell Touch at /dev/input/event6
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event6
[INFO   ] [MTD         ] Read event from </dev/input/event6>
[INFO   ] [Base        ] Start application main loop
[DEBUG  ] [VideoGstplayer] Load <rtsp://freja.hiof.no:1935/rtplive/_definst_/hessdalen03.stream>
[INFO   ] [MTD         ] </dev/input/event6> range position X is 0 - 4095
[INFO   ] [MTD         ] </dev/input/event6> range position Y is 0 - 4095
[INFO   ] [MTD         ] </dev/input/event6> range touch major is 0 - 0
[INFO   ] [MTD         ] </dev/input/event6> range touch minor is 0 - 0
[INFO   ] [MTD         ] </dev/input/event6> range pressure is 0 - 255
[INFO   ] [MTD         ] </dev/input/event6> axes invertion: X is 0, Y is 0
[INFO   ] [MTD         ] </dev/input/event6> rotation set to 0
[ERROR  ] [VideoGstplayer] b'Could not get/set settings from/on resource.'
[ERROR  ] [VideoGstplayer] b'GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.'
[ERROR  ] [VideoGstplayer] b'Could not get/set settings from/on resource.'
[ERROR  ] [VideoGstplayer] b'GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.'
[WARNING] [VideoGstplayer] b'Could not read from resource.'
[INFO   ] [WindowSDL   ] exiting mainloop and closing.
[INFO   ] [Base        ] Leaving application in progress...

(the stream currently displays fine in vlc, though couldn't find the proper command to display it in gst-play yet)

edit: similar result with ffpyplayer

[INFO   ] [MTD         ] </dev/input/event6> axes invertion: X is 0, Y is 0
[INFO   ] [MTD         ] </dev/input/event6> rotation set to 0
[WARNING] [ffpyplayer  ] [tcp @ 0x7f692c003760] Connection to tcp://freja.hiof.no:1935?timeout=0 failed (Connection refused), trying next address
[INFO   ] [Base        ] Leaving application in progress...
[INFO   ] [WindowSDL   ] exiting mainloop and closing.
anphxyz commented 5 years ago

Hi @tshirtman, I have a question. Can Kivy support VLC resource?

drakorg commented 4 years ago

Hi, has there been any advance with this issue about playing rtsp streams in kivy via VideoGstplayer or any other component?

Julian-O commented 11 months ago

Tried to repro on Windows. Failed to find a public RTSP stream to test on! All the examples I found were long dead.