Generic FFMPEG implementation / stream other video sources



  • Getting alexa to play video thats not from a paid service is a pain. You have to open a web browser on the Show, then navigate to some streaming website.

    User’s like myself have content on our local network, and some even have a HD Homerun for streaming live TV over LAN.

    Anyways, I would love to setup a “fake” camera, named Discovery channel, that points to an HD homerun feed for the Discovery channel. Or a “fake” camera named Seinfeld that starts a randomized playlist of Seinfeld videos on my computer.

    With FFmpeg, someone with some scripting abilities could make this happen but I don’t know what format monocle might expect. I don’t think RTSP is possible with FFMPEG alone, but maybe it is possible with FFServer? Alternatively, I believe an RTSP stream from VLC, or emby/plex may be possible.

    Hopefully you see where I’m going with all of this. The live cameras are great, but arbitrary video from anywhere would be so sweeeet.



  • So I figured out how to get a rtsp server running via VLC where monocle successfully displays Live TV from my HD homerun. Unfortunately, this solution requires the VLC rtsp server running all the time. I really only want it to run when monocle receives the request, then I’d like it to stop when playback stops.

    I’m requesting that a beforeLiveStreamStart command line hook could be added, and also I’m not sure if the onLiveStreamEnd hook is possible. If it’s not, no big deal, I can just kill the rtsp server after an hour or so.

    I would also be willing to help by submitting a pull request if the source is on github.

    Anyways, for those who want to know, here’s how I created the rtsp transcoding server. FWIW, this method should work on unsupported IP cameras, and arbitrary video files if the beforeLiveStreamStart hook was added.

    vlc -vvv http://192.168.1.148:5004/auto/v721 --sout-avcodec-strict=-2 --sout '#transcode{venc=x264{preset=ultrafast},vcodec=h264,vb=1800,acodec=aac,ab=128,samplerate=48000}:rtp{sdp=rtsp://192.168.1.101:554/stream}'
    

    To explain the above, the http://192.168.1.148:5004/auto/v721 bit is my live TV HDHomerun address, that you could sub for an unsupported camera feed or a local video path, and the rtsp://192.168.1.101:554/stream bit is the local rtsp server address, where 192.168.1.101 is the local IP of the computer running VLC.

    Anyways, I’m looking forward to hearing from the devs about the possibilty of a pre-stream CLI hook 🙂

    Thanks!



  • So I wrote a simple script to tail the log and watch for the start/stop events and run my own rtsp server. But since the server isn’t running when I initiate the command, it fails 😞

    So, tailing logs won’t work. Is the monocle-proxy open sourced anywhere so I can alter it for my personal use?



  • @jed

    Hi ,

    Monocle Gateway is not currently open sourced. However, I’m willing to work with you to include some hooks or APIs that can allow you to “know” when a stream is requested and when it is disconnected. We will need to hash out some details on the best way to make this work. Currently the only way to know when a stream is no longer in use is by the TCP disconnect from the Alexa/FireTV devices. So this means someone may need to track how many connections are active/live before shutting down your RTSP server/stream.

    Thanks, Robert



  • @Monocle

    Hey Robert,

    Thanks so much for the reply. I don’t really need a stream end command as much as I would really need is a beforeStreamStarts command line option.

    If the software could call a CLI entry and pass the camera name to it, then wait for a return value before it connects to the rtsp stream, I can use that CLI entry to start my own rtsp server.

    I think doing so would open up a wealth of options for people to make their own video sources.

    Thanks again and I just sent a donation to the project, it’s really great



  • Hey Robert,

    Is this in the forecast at all? FWIW, I’m still very interested.

    Thanks



  • I run Blue Iris on my Windows PC, and would like to be able to specify the Blue Iris server as a pseudo-camera that aggregates all my individual camera streams with individual cameras identified as channels under the single BI URL. This is how the IP Camera Viewer app that runs on Android works. The difficulty in using this with Monocle is that BI only hosts http as an output, not rtsp. So it would be great if Monocle had a transcoder that allowed it to use http streams.



  • @jed

    Sorry for the delay, I have been out of the office for a few weeks.

    Let me look into the gateway code and see if there is a simple place to add support for a “beforeStream” type of interaction. Blocking (waiting for a response) may be tricky, because Alexa only allows for up to 6 seconds to respond (see https://developer.amazon.com/docs/device-apis/alexa-camerastreamcontroller.html)

    It’s something we can certainly experiment with. When would you be available to test something like this out?

    Thanks, Robert



  • Hey Robert

    I’m around this weekend. I dont think I need a blocking spawned process, i would just want to run by script right before yours is called.

    Thanks a bunch, this is going to be awesome.



  • @jed

    I would not be able to get anything working this weekend, but maybe over the coming week.

    What type of script would you be running? BASH, BATCH? etc?

    Thanks, Robert



  • Hey Robert,

    I’m running a windows server, so BATCH work. I may end up compiling an .exe so other people can use it too. I’m hoping that I don’t need a blocking process, but it’s hard for me to tell without testing. My fear is that the rtsp server won’t be running when monocle calls it and it would fail.

    Anyways, I’m ready to test whenever you would like, just give me a shout. Its going to be so awesome to be able to say “Alexa, show me cartoons” and have it stream video of my choosing, without paying another 3rd party provider.

    Thanks again!



  • @jed

    I have something to start testing with. I’ll PM you the details.

    Thanks, Robert


Log in to reply