If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

How can I open a VLC stream?

Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
Hi, I am trying to open a stream served by VLC on the same box as PMS. I feel like i have tried every combination that VLC is capable of but nothing is working.

I know VLC is streaming correctly since i can access the stream via safari (tho it just starts downloading as a file) and via VLC on another computer (however no sound, but im not concerning myself with that now)

VLC offers 4 kinds of streams:
HTTP
UDP
MMSH
RTP

surely plex ought to work with at least HTTP. I tried replicating what the EyeTV plugin is doing to open it's http stream which is: return Redirect('http://127.0.0.1:1234')

I have also tried this:
def MainMenu():
	dir = MediaContainer(title1="VLC Player")
	dir.Append(
		VideoItem(
			'mms://127.0.0.1:1234',
			title='Play Movie',
			subtitle="Click to open this stream!",
			summary="VLC"
			)
		)
	return dir


sometimes I can get an infinite "Opening stream box" and have to force quit plex. most of the time nothing at all happens.

the logs are usually void of anything, but some combinations of VLC options do get plex to show a 302 with 0 bytes in the log.

Long story short: does anybody have a clue how to stream from VLC to plex?
«13

Comments

  • mikedm139mikedm139 Plugin Developer Posts: 3,022Members, Plex Pass, Plex Ninja Plex Ninja
    The streaming capability will depend on more than just the protocol used. The file type and codecs can be important. When you access the http stream via a browser, what sort of file do you get?

    If you are having trouble with one or more channels, check here first.
    If you are asked to provide logs, which you will be if you are having plugin problems, the help center has details on where to find them.
    ***************************************************************************************************************************************
    Check out unofficial channels in the
    UnSupported AppStore
    Follow my efforts on Github and Twitter
    Donate

  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    I'm sure actually getting video to play in plex does require a compatible format and whatnot, but shouldnt it popup something about "unknown format" or some such? certainly shouldn't be locking up when i try to cancel the connection.

    If I try an HTTP stream with MPEG TS container plex seems to successfully open it, but it thinks the stream is 0 bytes. the log indicates HTTP 200 0 bytes transfered and using curl on the command line does in fact reveal the content-length header is 0, yet the file still downloads in safari and can be viewed from another VLC instance. Im certainly no HTTP/streaming expert, but I'm guessing the length is 0 because it is not known how long the stream is? So it seems that plex doesnt support streaming of live "endless" streams?

    I have also tried "Raw" and "ASF" encapsulation streamed over HTTP with no luck.

    I am not sure how i am supposed to verify what type of data is in the file safari was downloading, but I see no reason why it wouldnt be the raw data that VLC was streaming in whatever format/container it was using at the time.

    If i hexdump the partial download in terminal i can see that this particular instance has "mpgv" repeated throughout it and also "Unknown Video" those are the only human readable strings i saw the rest is pure binary data.
  • mikedm139mikedm139 Plugin Developer Posts: 3,022Members, Plex Pass, Plex Ninja Plex Ninja
    Sounds like HTTP Live Streaming which Plex does support. The trick is in telling PMS how to grab the stream. I don't know if the previous plugin framework (v2.0) supported HLS. It'd be better and you'll have more usable examples, if you switch to v2.1.

    URL Services are generally implemented for the v2.1 plugins but they are not entirely necessary. Something like this should work...

    def MainMenu():
    	oc = ObjectContainer(title1="VLC Player")
    	oc.add(VideoClipObject(title="Play",
    		items=[MediaObject(
    			parts = [PartObject(
    				key=HTTPLiveStreamURL("http://127.0.0.1:1234")
    				)]
    			)]
    		)
    	)
    


    The CityTV URL Service is an example of HLS urls being implemented although more complex than this case requires. I can't comment on the issue regarding content length. That's beyond my experience.

    If you are having trouble with one or more channels, check here first.
    If you are asked to provide logs, which you will be if you are having plugin problems, the help center has details on where to find them.
    ***************************************************************************************************************************************
    Check out unofficial channels in the
    UnSupported AppStore
    Follow my efforts on Github and Twitter
    Donate

  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    i didn't even know there was a 2.1. I just change the PlexFrameworkVersion in info.plist to 2.1 I assume.

    I'll give this a shot thanks!
  • mikedm139mikedm139 Plugin Developer Posts: 3,022Members, Plex Pass, Plex Ninja Plex Ninja
    Actually, there's no need to change the version key in the plist. The changes are primarily in the __init__.py. The docs at dev.plexapp.com elaborate more on the object types etc. There's some nice blog posts there from IanB! with pointers for channel development.

    If you are having trouble with one or more channels, check here first.
    If you are asked to provide logs, which you will be if you are having plugin problems, the help center has details on where to find them.
    ***************************************************************************************************************************************
    Check out unofficial channels in the
    UnSupported AppStore
    Follow my efforts on Github and Twitter
    Donate

  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    edited May 2012
    I'm certain this shouldnt be as hard as it is being. I see no reason why i shouldnt simply be able to specify a stream URL and have plex play it. (vlc and quicktime this is all that is required)

    trying to add a VideoClipObject requires either the URL attribute to be set or both the "key" and "rating_key" attributes. The problem being setting the URL to 'http://127.0.0.1:1234' does nothing at all. the docs say key should return a meta data object (which i tried), but that makes no sense because VideoClipObject itself is a meta data object.

    I'm sure this is super easy, but the documentation is a complete disaster IMO. nowhere in the docs does it list the items attribute you gave nor does it have anything regarding HTTPLiveStreamURL

    the MOST annoying part of this is having 3 different log files and NONE of they have anything of value in them. I select the play item in the list and plex does nothing and no messages are written anywhere.
  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    OK here is some hopefully helpful information to the next poor sap that tries to make a plex plugin:

    if you want ANY helpful log information or errors for playing video you CANNOT route your plugin as an application (ie /application/myPlugin) you must have it routed as a video channel. I thought that the route was only for what section the plugin appears under, but apparently there is more to it than that. Why this makes plex freeze and not log anything (seemingly at random) is beyond me, but making the route /video/myplugin made it things are actually logged and now i may still get an error when trying to open the stream, but at least plex is trying to open it now!
  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    edited May 2012
    ok as i suspected this is not difficult. the key was to register as a video channel and not an application (this should be stressed in the docs, but i didnt see it mentioned and only discovered this myself)

    here is basic code to do it:

    def MainMenu():
    	oc = ObjectContainer(title1="VLC Player")
    	
    	mo = MediaObject(parts=[PartObject(key=HTTPLiveStreamURL("http://127.0.0.1:1234"))])
    	
    	vco = VideoClipObject(title="Play local VLC stream", url='http://127.0.0.1:1234')
    	vco.add(mo)
    	oc.add(vco)
    	
    	return oc
    


    VLC settings i used:
    Stream: HTTP
    Encapsulation: MPEG TS ASF

    EDIT: switching from "MPEG TS" to "ASF" results in butter smooth playback even on the same machine

    no transcoding

    I dont know if these are the "best" options; there is tremendous video lag, but I am streaming and viewing on the same box right now.

    I would like to think plex would support some of the other streams too.

    Last but not least thank you Mikedm139 for the helpful hints.

    Edit2:

    If anybody is curious my primary motivation for this is to make a DVD playback plugin. Now that I have the streaming working I can work on the playback controls which VLC does (allegedly) provide over HTTP.

    I will of course release my work here for others to enjoy/improve starting with this shellscript coe im using to open VLC as a faceless daemon (sounds scary i know :P) and begin streaming the DVD inside the server

    #!/bin/bash
    
    cmd="/Applications/VLC.app/Contents/MacOS/VLC -I http -vvv --color dvdread:///dev/rdisk1#1:1- --sout '#standard{access=http,mux=asf,dst=localhost:1234}' --sout-all -d"
    eval "$cmd" > /dev/null
    
    echo 0
    exit
    
    
  • mikedm139mikedm139 Plugin Developer Posts: 3,022Members, Plex Pass, Plex Ninja Plex Ninja
    I'm sorry. Had I known you were trying to play video from an application plugin, I would have warned you that doesn't work :( That's a pet peave of mine with CouchPotato plugin.
    FWIW, I understand that those sorts of differentiations are not likely to be a permanent issue.

    If you are having trouble with one or more channels, check here first.
    If you are asked to provide logs, which you will be if you are having plugin problems, the help center has details on where to find them.
    ***************************************************************************************************************************************
    Check out unofficial channels in the
    UnSupported AppStore
    Follow my efforts on Github and Twitter
    Donate

  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    mikedm139 wrote:

    I'm sorry. Had I known you were trying to play video from an application plugin, I would have warned you that doesn't work :( That's a pet peave of mine with CouchPotato plugin.
    FWIW, I understand that those sorts of differentiations are not likely to be a permanent issue.


    Heh no worries. I do wish plex would have thrown an error when trying to do it rather than being obstinately silent tho...

    the important think is it works now.
  • shirkshirk Posts: 313Members, Plex Pass
    Out of curiosity - does vlc use relative or absolute urls in its hls playlists?
    I'm asking because I (and a hand full of other users) have faced nasty problems when trying to Redirect() to a hls playlist which contained relative content urls.

    The problem being Plex which simply ignored the base URL of the playlist and tryed to grab the relative parts from where the plugin did the Redirect() (e.g /video/xxx/tunto/part1.ts instead of http://1.2.3.4:1111/stream/part1.ts).

    And yes, I've tryed to wrap the URL / key resources in HTTPLiveStreamURL() and I've also tryed by implementing this it with a URLService.
    --
    Cheers,
    Shirk
  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    I honestly have no idea. as you can see from the above code i simply give plex the address and port. I do know that there is a 302, but I've never followed it or tried to examine the stream in any other way.

    definitely sounds like plex is dropping the ball for you. In all honesty i havent yet streamed more than 10 seconds of video from VLC so for all I know I am subject to the same issues you are having.
  • fillet54fillet54 Posts: 20Members ✭✭
    shirk wrote:

    Out of curiosity - does vlc use relative or absolute urls in its hls playlists?
    I'm asking because I (and a hand full of other users) have faced nasty problems when trying to Redirect() to a hls playlist which contained relative content urls.


    VLC can provide both relative and absolute paths in an HLS playlist. From Murderous Moppet's bash script though it doesn't appear that he is streaming via HLS but rather just HTTP and that's why he can provide Plex with just the host:port without the m3u8 playlist.

    I currently stream with VLC from a HDPVR to Plex using the same method as above and it has been working very nicely for about 6 months. The only thing different is that I use mpegts as the container since that is what the HDPVR provides and in my case the playback is smooth. I can now view and control my directv box directly from within Plex so there shouldn't be any issues doing the same for DVDs. The interface is a little clunky as I haven't found a way to use the remote as cleanly as i would like to and I am going to be looking at that this week. For example when you want to fast forward you would need to capture the plex fastforward and instead of fastforwarding the stream that plex is playing you want to send a fastforward command to the directv box or VLC. Im not sure if this is possible if you're not using a site configuration as i cannot find any documentation for it.

    My current idea is that I could use some external program to listen for certain key presses (ex play/pause/ff etc..) and then query the Plex client to see if it's currently playing the stream or not. If it is then route the command to whatever interface setup for controlling the stream or just route as a different keypress that plex will pick up.
  • mikedm139mikedm139 Plugin Developer Posts: 3,022Members, Plex Pass, Plex Ninja Plex Ninja
    fillet54 wrote:

    VLC can provide both relative and absolute paths in an HLS playlist. From Murderous Moppet's bash script though it doesn't appear that he is streaming via HLS but rather just HTTP and that's why he can provide Plex with just the host:port without the m3u8 playlist.

    I currently stream with VLC from a HDPVR to Plex using the same method as above and it has been working very nicely for about 6 months. The only thing different is that I use mpegts as the container since that is what the HDPVR provides and in my case the playback is smooth. I can now view and control my directv box directly from within Plex so there shouldn't be any issues doing the same for DVDs. The interface is a little clunky as I haven't found a way to use the remote as cleanly as i would like to and I am going to be looking at that this week. For example when you want to fast forward you would need to capture the plex fastforward and instead of fastforwarding the stream that plex is playing you want to send a fastforward command to the directv box or VLC. Im not sure if this is possible if you're not using a site configuration as i cannot find any documentation for it.

    My current idea is that I could use some external program to listen for certain key presses (ex play/pause/ff etc..) and then query the Plex client to see if it's currently playing the stream or not. If it is then route the command to whatever interface setup for controlling the stream or just route as a different keypress that plex will pick up.


    Thanks for chiming in. The only thing I can suggest regarding the remote/keymapping is that if you're using a Harmony (or perhaps other universal) remote, you may be able to add some custom keymapping for use during playback that would send commands to VLC/HDPVR. Of course that would only work with the desktop client(s) but, it might serve your purposes.

    If you are having trouble with one or more channels, check here first.
    If you are asked to provide logs, which you will be if you are having plugin problems, the help center has details on where to find them.
    ***************************************************************************************************************************************
    Check out unofficial channels in the
    UnSupported AppStore
    Follow my efforts on Github and Twitter
    Donate

  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    My current idea is that I could use some external program to listen for certain key presses (ex play/pause/ff etc..) and then query the Plex client to see if it's currently playing the stream or not. If it is then route the command to whatever interface setup for controlling the stream or just route as a different keypress that plex will pick up.


    Indeed this is the only way I have found to do things. I hope plex API adds native support for input hooks soon (i may end up forking the latest PMC and do it myself)

    If you are interested (and on a mac) I can provide you the code i have been using to hook the keyboard input for the eyetv plugin.
  • donaldjacksondonaldjackson Posts: 1Members, Plex Pass
    Is there any chance you can make this code available and some sort of steps on how to implement it in a plex media server? I am trying to achieve the same thing (stream custom URL in Plex) but I'm a bit of a n00b and don't have a clue where to start.

    Thanks in advance,
    D
  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass

    Is there any chance you can make this code available and some sort of steps on how to implement it in a plex media server? I am trying to achieve the same thing (stream custom URL in Plex) but I'm a bit of a n00b and don't have a clue where to start.

    Thanks in advance,
    D


    look at post #9. that is all the code you need to stream from a VLC server.
  • yixzonyixzon Posts: 7Members
    Hi, im new on this issue, im trying to stream live video through PLEX by VLC... But i dont understand where i suppose to change or write the code that u guys show on the post #9.. if some one can teach me how to do it, i`ll really appreciate. tHanks!
  • Murderous MoppetMurderous Moppet Posts: 362Members, Plex Pass Plex Pass
    you need to crate a new plex channel plugin

    easiest way to get a handle on it is probably to find an existing basic plugin and change the info.plist to your own values and then strip out the code except for __init__.py and then replace all the code in init.py with teh example in post #9 edited to reflect your VLC server.
  • yixzonyixzon Posts: 7Members

    you need to crate a new plex channel plugin

    easiest way to get a handle on it is probably to find an existing basic plugin and change the info.plist to your own values and then strip out the code except for __init__.py and then replace all the code in init.py with teh example in post #9 edited to reflect your VLC server.


    I was trying to open info.plist and it did´t open, even the computer do nothing :S, why this happend??
«13
Sign In or Register to comment.