Video feed not playing when media is streaming on TV
Opened this issue · 14 comments
Hi. I have encountered an issue where the live webrtc feed from my camera does not stream on my television when there is a media source playing on it. So when I'm watching Netflix, the live feed does not play and just displays a media player. But when I'm on the home menu on the TV, the live feed initializes and plays the feed from my camera. I have a Sony Bravia 4K TV and would like any information on how to solve this issue.
Thanks.
I believe this is caused by conflicting audio. Are you able to attempt disabling audio in your camera source stream?
I only 'solved' this issue through hardware - I use an external media player (Shield) for everything and run pipup 'by itself' on the Sony TV. I also found best luck with mjpeg pipup video content with no audio.
I did try that. Then I realized that the audio from my camera source had been disabled from the get go. Hence that is not the issue in my case. I understand that using external hardware like Shield or Firestick might solve this, but I don't view that as a "solution" to be honest. Although it is an investment, buying that hardware just to have video streaming functionality from my doorbell is a bit unrealistic. Surely there has to be some sort of a workaround for this?
I use "solved" in quotes intentionally as I agree it's not a solution as much as a workaround, and unpredictable at that.
I'm traveling so no access to my setup to confirm what can work or not. Can you attempt sending .mjpeg, or even something like .gif to pipup as opposed to true video content? Again, I do recall having best luck with mjpeg sources.
I'll note I'm using my own modified version of pipup (in my repos), but don't believe there are differences vs this version that would impact this functionality.
I can poke at my Bravia-specific application, TopBar and see if theres any potential for anything to leverage from there - I'll move that code into the repo when I look
From here we can see if @desertblade or others have any thoughts or experience against this issue.
I don't use webView, was slow to load and not very reliable for me on FireTV. Mjpeg worked the best for me using Frigate.
Some theories:
- 2 video streams cannot be played at the same time.
- Mixed Content issue (https and http, or video running in Netflix app)
- Permissions or no interrupt allowed.
Tests:
- I would be interested to know if mjpeg or images pop up works.
- In theory you can use a link from - https://filesamples.com/samples/video/mjpeg
Direct Link: https://filesamples.com/samples/video/mjpeg/sample_960x540.mjpeg
- In theory you can use a link from - https://filesamples.com/samples/video/mjpeg
- Does PipUp work in Netflix app while not playing videos?
- Does this happen in other apps like HBO or Youtube?
I am not an Android dev so I am not 100% positive. Probably wouldn't hurt to do a pass on this, it has been awhile since there was an update.
- I tried using a HTTPS link that I accomplished using a Cloudflare tunnel and domain. It still doesn't show when the Netflix application is open.
- How do I enable interrupt in the Notification? I know that notifications using the "Notifications for Android TV" app can be configured to interrupt television streaming using the flag
interrupt: 1
. Is there something similar for Pipup? - Sending image notifications work absolutely fine i.e., outside the app on the home screen, inside the app without streaming, and while streaming. I tested this with a HTTP link.
- So the inference is that only image notifications work all the time, while video notifications are limited to only when the TV is on the home screen and not streaming.
- I have absolutely no idea what mjpeg is and don't know where or how to start. I have a Hikvision IP camera that streams only video (disabled the audio after @my-ugly-code told me to try it out). I can't seem to find a setting on the camera to modify the stream settings to mjpeg. Please tell me what to do.
- @my-ugly-code I could try sending a video content like
.gif
but that does not really help my case as I'm trying to stream live from my camera? Or is there something I don't know here? - I have the same problem with YouTube and Amazon Prime Video too, so I don't think it is a Netflix issue.
- Here are a couple of pictures that I thought might help our case.
The first image shows the video feed from my camera not loading while streaming media on my TV. This is Amazon Prime Video.
Now for this second image, I sent the notification to my TV when it wasn't streaming. Then while the notification was still on, I tried opening the YouTube app in an attempt to get it to stream, but to no avail. I was met with a playback error from the YT app.
@RapidCompiler That's some good testing! From this testing it sounds like only 1 stream can play at a time.
Are you using h.265 on your Hikvision camera? There might be a hardware decode limit for h.265. Changing to h.264 might help since it is supported more broadly.
I need to look into the interrupt. I think I tested something around this, but found the pausing of the main video annoying and stopped. This is an oldish code base, so probably needs a good once over.
Looking through appops permissions, this one jumped out at me. Might be worth setting to see if it changes anything. This is a 'newer' permission as of Android 8 (circa 2017). I might need to do a new build with this permission, currently its not in the manifest.
./adb shell appops set nl.rogro82.pipup PICTURE_IN_PICTURE allow
Not sure how you are executing the popup, but maybe adding a ADB command to pause video before calling PiPup might work. From https://gist.github.com/Pulimet/5013acf2cd5b28e55036c82c91bd56d8, looks like this is the right command:
adb shell input keyevent 85
You could try the video json. It is full screen and in theory should work.
{ "video": { "uri": "address_to_your_video"}}
Do you know what version of Android your TV is running? I doubt it matters, just curious.
@my-ugly-code Thanks for being around! If you have any ideas or working on a fork we can merge it up. Its been over a year since I did anything with this code base, and I only patched a couple things. Might want to rewrite this app using PICTURE_IN_PICTURE instead of a system alert.
@RapidCompiler mjpeg is motion jpeg, it's an extension of jpeg container/format. In this approach, you'd be displaying multiple images vs a video feed, but video players handle this. It appears Hikvision may support the mjpeg output format, at least to some degree, based on a quick scan: https://www.hikvision.com/content/dam/hikvision/en/support/how-to/how-to-document/network-cameras/How-to-Get-IPC-MJPEG-Stream-via-HTTP-Commands.pdf
@desertblade No problem! I dug into your version to find http/js enablement for my fork of the original repo. Tbh, I was just happy to see some conversation around this. The main addition I made in my fork was to kill all padding/margins of the overlay view, and fix transparent background - in this manor I was able to overlay any html content full-screen, and also 'slide out' music ID content from the screen edges (not yet published). I've even used this for facial recognition (face-api.js) and labeling in realtime against non-HDCP content, but fell away from my project :) it happens. I think each fork supports its own needs, unless you wanted to add a param for margins in a setup screen of the apk, but most just use either version as-is, depending on needs. Not a fan of boxing anyone into my taste or needs. You're welcome to check out my repos, PiPupTransparent and also WebsUp which relies on PiPupTransparent.
I think outside of what you all mentioned already , it could (or may not) be worth exploring framerate/fps conflicts for the display - I know my Bravia (same line @RapidCompiler is using) TV can be picky about framerate surprises/changes. Admittedly just tossing out ideas. As I mentioned RC, I solved the issue by running PiPUp on my Bravia, then running all other content through a Shield TV connected to it - somehow that reliably separates the streams, but even then do not recall if I went to mjpeg streaming to avoid the video vs. video scenario.
@my-ugly-code Sorry for the delayed response. The PNW had a really bad storm a few weeks ago and am now catching back up on hobbies.
I think you hit the nail on the head, that each fork supports a particular use case. I looked at FireTV/Android notifications and they only support images, which is why PiUp probably first came to be. As far as I can tell most devices can only play one stream at a time, many people report "My main video paused" not just with PiUp but with other video in video applications. Probably why the original devs stopped updating many of the notification apps.
I want to look into Picture in Picture that I believe AndroidTV/FireTv now supports.
Researching some tonight and I found this: https://github.com/gugutab/TvOverlay
Its pretty good and supports RTSP streams, and it doesn't pause the main video on my FireTv.
Closing.
TVOverlay is pretty good, but in my use case I am still using PiPup. The reality is I am not sure how much longer the existing codebases and permissions will continue to work on AndroidTV.
did you guys end up resolving this , i cant get it to work on multiple tvs at once either
Hey I have a very similar TV and I was able to get it to work on mine. Click here for a very detailed explanation on this and let me know if you get stuck somewhere. The only problem I've encountered now is that I'm unable to play the live feed from my camera on my TV when a media source is playing (example Netflix). Make sure you install the APK from desertblade's repository. The forum should have more details on this.
I have the very same issue,!!, for months and monthsa i went crazy (because i stream my live feeds to MULTIPLE tvs across the house at once, and everynight the same thing, when the kids went to bed, i would set it all up and every tv, would stream, .. but then in the morning, it wouldnt appear on one tv, but would appear on another, then ...not the other etc etc, for the longest time i thought it had something to do with network access for to the rtsp stream, only to finally figure out.. its any bloody streaming service in the background will stop it running!!!< grr extremely frustrating!,
also i now use TVoverlay, much nicer interface and more clever and pretty then pipUP, without the ADB setup/disconnect hassles. https://github.com/gugutab/TvOverlay/tree/main
but this also suffers the same issue,
also both solutions occasionally dont render the stream from time to time without any apparent reason.
going crazy over hear in AUS!
I have not found a solution to this, without doing a full rewrite using Picture-in-Picture, and even then I am not sure it will work. As far as I can tell some devices allow multiple streams while others don't. For my use case I went with MJPEG streams from Frigate, because I also found that RTSP initialization can be slow and timeout in the pop-up window. I don't think RTSP is the best protocol for short term connections to video streams.
I 100% agree TVOverlay is a better solve. I just modified a busted apk to work with current generation Android.
Came here to say that pip with MPEG stream on hikvision camera works on my Sony Bravia TV. Media plays without interruption and the camera feed too. I did notice some frame loss (not always though) on the media app (netflix for eg), could be my old TV. Had to setup my POE camera substeam to MPEG with 30fps frame rate and 1024 bit rate. Then add it via MPEG steam integration of HA. Called those popup scripts using MPEG entity with webrtc create link scripts. It is working at least for now (knock on wood).