desertblade / PiPup

Enhanced notifications for Android TV
65 stars 5 forks source link

Video feed not playing when media is streaming on TV #1

Open RapidCompiler opened 7 months ago

RapidCompiler commented 7 months ago

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.

my-ugly-code commented 7 months ago

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.

RapidCompiler commented 7 months ago

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?

my-ugly-code commented 7 months ago

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.

desertblade commented 7 months ago

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:

Tests:

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.

RapidCompiler commented 7 months ago
desertblade commented 7 months ago

@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.

my-ugly-code commented 7 months ago

@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.

desertblade commented 7 months ago

@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.

desertblade commented 7 months ago

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.

desertblade commented 6 months ago

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.

trendstyle commented 5 months ago

did you guys end up resolving this , i cant get it to work on multiple tvs at once either

trendstyle commented 5 months ago

@desert

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!

desertblade commented 5 months ago

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.