home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.11k stars 29.16k forks source link

If casting is enabled on TV, streaming apps drop frames #55435

Closed pdawg17 closed 2 years ago

pdawg17 commented 2 years ago

The problem

If I have casting enabled on my Sony oled tv, streaming apps drop frames (stutter every 10-15 seconds). If I turn off HA, the issue is resolved. The other solution is to disable casting in the tv settings. I have also disabled the tv on HA but it does not solve the issue. I saw someone else report this on Reddit with an LG oled.

https://www.reddit.com/r/homeassistant/comments/pbvlut/tv_stutter_by_homeassistant/

What is version of Home Assistant Core has the issue?

core-2021.8.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Google Cast

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cast/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

cast documentation cast source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (cast) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

QuadNL commented 2 years ago

Same issue here! After months and a TV and new firewall later i found the same yesterday as you did. Disabling casting integration in HA solved this annoying issue, and on a Dutch forum (tweakers.net) a few others have the same too. Its pretty annoying if you watch Netflix and every few seconds there is a framedrop.

I think there are many others who have the same problem as what we have, but finding this ultimate cause was a pretty hard (and expensive) one.

emontnemery commented 2 years ago

@QuadNL, @pdawg17 This could be because of the polling done by pychromecast. With the cast integration disabled in Home Assistant, can you verify the followings triggers the stuttering, and that the stuttering goes away when you terminate the discovery_example script?

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test
cd pychromecast_test/
git checkout 9.2.1
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 pkg-resources==0.0.0 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py
pdawg17 commented 2 years ago

@QuadNL, @pdawg17 This could be because of the polling done by pychromecast. With the cast integration disabled in Home Assistant, can you verify the followings triggers the stuttering, and that the stuttering goes away when you terminate the discovery_example script?

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test
cd pychromecast_test/
git checkout 9.2.1
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 pkg-resources==0.0.0 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py

Yes confirmed. Many dropped frames when running the script then when I stop the script, zero dropped frames...thanks for looking into this...

emontnemery commented 2 years ago

OK, can you share the output of the script until it has discovered your TV?

pdawg17 commented 2 years ago

OK, can you share the output of the script until it has discovered your TV?

Oh btw pkg-resources would not install. It says "Could not find a version that satisfies the requirement; no matching distribution found"

Is that needed for output info?

emontnemery commented 2 years ago

No it's not needed, I just mean the prints like these:

$ python3 examples/discovery_example.py
Found cast device with UUID 8bbb9a81-2b17-907d-afb2-8e74dc4b4428
Currently known cast devices:
  8bbb9a81-2b17-907d-afb2-8e74dc4b4428 CastInfo(services={ServiceInfo(type='mdns', data='Chromecast-Audio-8bbb9a812b17907dafb28e74dc4b4428._googlecast._tcp.local.')}, uuid=UUID('8bbb9a81-2b17-907d-afb2-8e74dc4b4428'), model_name='Chromecast Audio', friendly_name='Bed room', host='192.168.0.177', port=8009)
Found cast device with UUID 1a5bab99-1df4-45c2-8f93-d7887b973f08
Currently known cast devices:
  8bbb9a81-2b17-907d-afb2-8e74dc4b4428 CastInfo(services={ServiceInfo(type='mdns', data='Chromecast-Audio-8bbb9a812b17907dafb28e74dc4b4428._googlecast._tcp.local.')}, uuid=UUID('8bbb9a81-2b17-907d-afb2-8e74dc4b4428'), model_name='Chromecast Audio', friendly_name='Bed room', host='192.168.0.177', port=8009)
  1a5bab99-1df4-45c2-8f93-d7887b973f08 CastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-1a5bab991df445c28f93d7887b973f08-1._googlecast._tcp.local.')}, uuid=UUID('1a5bab99-1df4-45c2-8f93-d7887b973f08'), model_name='Google Cast Group', friendly_name='Test group', host='192.168.0.177', port=42519)
Found cast device with UUID 657e8e9d-261e-42e7-9fc5-36748ad083c5
pdawg17 commented 2 years ago

No it's not needed, I just mean the prints like these:

$ python3 examples/discovery_example.py
Found cast device with UUID 8bbb9a81-2b17-907d-afb2-8e74dc4b4428
Currently known cast devices:
  8bbb9a81-2b17-907d-afb2-8e74dc4b4428 CastInfo(services={ServiceInfo(type='mdns', data='Chromecast-Audio-8bbb9a812b17907dafb28e74dc4b4428._googlecast._tcp.local.')}, uuid=UUID('8bbb9a81-2b17-907d-afb2-8e74dc4b4428'), model_name='Chromecast Audio', friendly_name='Bed room', host='192.168.0.177', port=8009)
Found cast device with UUID 1a5bab99-1df4-45c2-8f93-d7887b973f08
Currently known cast devices:
  8bbb9a81-2b17-907d-afb2-8e74dc4b4428 CastInfo(services={ServiceInfo(type='mdns', data='Chromecast-Audio-8bbb9a812b17907dafb28e74dc4b4428._googlecast._tcp.local.')}, uuid=UUID('8bbb9a81-2b17-907d-afb2-8e74dc4b4428'), model_name='Chromecast Audio', friendly_name='Bed room', host='192.168.0.177', port=8009)
  1a5bab99-1df4-45c2-8f93-d7887b973f08 CastInfo(services={ServiceInfo(type='mdns', data='Google-Cast-Group-1a5bab991df445c28f93d7887b973f08-1._googlecast._tcp.local.')}, uuid=UUID('1a5bab99-1df4-45c2-8f93-d7887b973f08'), model_name='Google Cast Group', friendly_name='Test group', host='192.168.0.177', port=42519)
Found cast device with UUID 657e8e9d-261e-42e7-9fc5-36748ad083c5

First device found was the TV so here is the snippet. Let me know if you want the whole output.

Found cast device with UUID 0185ad64-567b-6f2e-d7c7-601c38ab8014
Currently known cast devices:
  0185ad64-567b-6f2e-d7c7-601c38ab8014 CastInfo(services={ServiceInfo(type='mdns', data='BRAVIA-4K-VH2-0185ad64567b6f2ed7c7601c38ab8014._googlecast._tcp.local.')}, uuid=UUID('0185ad64-567b-6f2e-d7c7-601c38ab8014'), model_name='BRAVIA 4K VH2', friendly_name='Sony', host='10.0.0.20', port=8009)
emontnemery commented 2 years ago

Can you verify this version doesn't trigger any stuttering:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_no_poll_bravia
cd pychromecast_test_no_poll_bravia/
git checkout 3581377c4fa24757bf1571c84c6d8be2341fc025
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 pkg-resources==0.0.0 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug
QuadNL commented 2 years ago

I will try tonight.


From: Erik Montnemery @.> Sent: Wednesday, October 13, 2021 11:46:45 AM To: home-assistant/core @.> Cc: Elbert Beverdam @.>; Mention @.> Subject: Re: [home-assistant/core] If casting is enabled on TV, streaming apps drop frames (#55435)

Can you verify this version doesn't trigger any stuttering:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_no_poll_bravia cd pychromecast_test_no_poll_bravia/ git checkout 3581377c4fa24757bf1571c84c6d8be2341fc025 python3 -m venv venv source venv/bin/activate pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 pkg-resources==0.0.0 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4 export PYTHONPATH="." python3 examples/discovery_example.py --show-debug

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/55435#issuecomment-942122441, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP2P2ST5JTEEN67XK3YZHOTUGVIQLANCNFSM5DBD645A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

pdawg17 commented 2 years ago

python3 examples/discovery_example.py --show-debug

No stuttering with this version!

DEBUG:asyncio:Using selector: EpollSelector DEBUG:pychromecast.discovery:HostBrowser thread started DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., BRAVIA-4K-VH2-0185ad64567b6f2ed7c7601c38ab8014._googlecast._tcp.local. DEBUG:pychromecast.discovery:Addded host 10.0.0.20 Found cast device with UUID 0185ad64-567b-6f2e-d7c7-601c38ab8014 Currently known cast devices: 0185ad64-567b-6f2e-d7c7-601c38ab8014 CastInfo(services={ServiceInfo(type='mdns', data='BRAVIA-4K-VH2-0185ad64567b6f2ed7c7601c38ab8014._googlecast._tcp.local.')}, uuid=UUID('0185ad64-567b-6f2e-d7c7-601c38ab8014'), model_name='BRAVIA 4K VH2', friendly_name='Sony', host='10.0.0.20', port=8009)

QuadNL commented 2 years ago

I tried both, first script gave me stutter when running. I have the same problem too with the second script untill stopped, so for me it's not resolved.

(venv) @.***:/pychromecast_test_no_poll_bravia# python3 examples/discovery_example.py --show-debug DEBUG:asyncio:Using selector: EpollSelector DEBUG:pychromecast.discovery:HostBrowser thread started DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local. DEBUG:pychromecast.discovery:Addded host 192.168.10.140 Found cast device with UUID a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b Currently known cast devices: a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009) DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local. DEBUG:pychromecast.discovery:Addded host 192.168.10.138 Found cast device with UUID 095eded6-3eab-273f-e6fe-cfbd1aee91f5 Currently known cast devices: a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009) 095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.')}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009) DEBUG:pychromecast.discovery:Host 192.168.10.140:8009 (a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b) up, adding or updating host based service Updated cast device with UUID a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b Currently known cast devices: a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='host', data=('192.168.10.140', 8009)), ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009) 095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.')}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009) DEBUG:pychromecast.discovery:Host 192.168.10.138:8009 (095eded6-3eab-273f-e6fe-cfbd1aee91f5) up, adding or updating host based service Updated cast device with UUID 095eded6-3eab-273f-e6fe-cfbd1aee91f5 Currently known cast devices: a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='host', data=('192.168.10.140', 8009)), ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009) 095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.10.138', 8009))}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009)


Van: pdawg17 @.> Verzonden: woensdag 13 oktober 2021 19:11 Aan: home-assistant/core @.> CC: Elbert Beverdam @.>; Mention @.> Onderwerp: Re: [home-assistant/core] If casting is enabled on TV, streaming apps drop frames (#55435)

python3 examples/discovery_example.py --show-debug

No stuttering with this version!

DEBUG:asyncio:Using selector: EpollSelector DEBUG:pychromecast.discovery:HostBrowser thread started DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., BRAVIA-4K-VH2-0185ad64567b6f2ed7c7601c38ab8014._googlecast._tcp.local. DEBUG:pychromecast.discovery:Addded host 10.0.0.20 Found cast device with UUID 0185ad64-567b-6f2e-d7c7-601c38ab8014 Currently known cast devices: 0185ad64-567b-6f2e-d7c7-601c38ab8014 CastInfo(services={ServiceInfo(type='mdns', data='BRAVIA-4K-VH2-0185ad64567b6f2ed7c7601c38ab8014._googlecast._tcp.local.')}, uuid=UUID('0185ad64-567b-6f2e-d7c7-601c38ab8014'), model_name='BRAVIA 4K VH2', friendly_name='Sony', host='10.0.0.20', port=8009) DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., google-nest-hub-7702ebe9ec31e79740420093cffa43f5._googlecast._tcp.local.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/55435#issuecomment-942536304, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP2P2SWW7WDIJ2RZ4V25XS3UGW4TXANCNFSM5DBD645A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

emontnemery commented 2 years ago

@QuadNL Your TV is not a Sony but a Philips one?

QuadNL commented 2 years ago

Correct, Philips 50PUS8505 with Android TV v9.


From: Erik Montnemery @.> Sent: Wednesday, October 13, 2021 11:08:07 PM To: home-assistant/core @.> Cc: Elbert Beverdam @.>; Mention @.> Subject: Re: [home-assistant/core] If casting is enabled on TV, streaming apps drop frames (#55435)

@QuadNLhttps://github.com/QuadNL Your TV is not a Sony but a Philips one?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/55435#issuecomment-942721850, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP2P2SQHVMRHBKACTX3OARTUGXYLPANCNFSM5DBD645A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

emontnemery commented 2 years ago

OK, so this issue is not limited to Sony TV's then, but more widespread among Android TVs. It's somewhat incredible that opening a https-connection to the TV every few seconds causes stuttering of the video.

@QuadNL, can you try this version instead:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts
cd pychromecast_test_only_poll_audio_casts/
git checkout 5359cbc59ed8ff8fdaa94b8d5caf5e5e40019091
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug
QuadNL commented 2 years ago

This version causes stuttering too.

emontnemery commented 2 years ago

OK, can you try this and paste the output of the script, let it run for 30s or so please.

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts_debug
cd pychromecast_test_only_poll_audio_casts_debug/
git checkout 34d978d4df3e1e754d4e7a26adaa65bde03f4038
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug
emontnemery commented 2 years ago

New version:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts_debug_2
cd pychromecast_test_only_poll_audio_casts_debug_2/
git checkout 1c14b4f5701ea0fd18c0f0947e962fd177dfc327
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug
QuadNL commented 2 years ago

New version:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts_debug_2
cd pychromecast_test_only_poll_audio_casts_debug_2/
git checkout 1c14b4f5701ea0fd18c0f0947e962fd177dfc327
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug

WIth this version i notice the drop at the moment this entry showed up: 095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.10.138', 8009))}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009)

After this he only poll my Nest Mini.

(venv) root@dsmr:/pychromecast_test_only_poll_audio_casts_debug_2# python3 examples/discovery_example.py --show-debug
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:pychromecast.discovery:HostBrowser thread started
DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.
DEBUG:pychromecast.discovery:Addded host 192.168.10.140
Found cast device with UUID a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b
Currently known cast devices:
  a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009)
DEBUG:pychromecast.discovery:add_service _googlecast._tcp.local., TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.
DEBUG:pychromecast.discovery:Addded host 192.168.10.138
Found cast device with UUID 095eded6-3eab-273f-e6fe-cfbd1aee91f5
Currently known cast devices:
  a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.')}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009)
  095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.')}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009)
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:Host 192.168.10.140:8009 (a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b) up, adding or updating host based service
Updated cast device with UUID a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b
Currently known cast devices:
  a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.10.140', 8009))}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009)
  095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.')}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009)
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.138
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='TV Woonkamer', model_name='TPM191E', manufacturer='Philips', uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), cast_type='cast')
DEBUG:pychromecast.discovery:Host 192.168.10.138:8009 (095eded6-3eab-273f-e6fe-cfbd1aee91f5) up, adding or updating host based service
Updated cast device with UUID 095eded6-3eab-273f-e6fe-cfbd1aee91f5
Currently known cast devices:
  a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b CastInfo(services={ServiceInfo(type='mdns', data='Google-Nest-Mini-a3ee24d2b0d85acbad5dec3ae365de3b._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.10.140', 8009))}, uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), model_name='Google Nest Mini', friendly_name='Nest', host='192.168.10.140', port=8009)
  095eded6-3eab-273f-e6fe-cfbd1aee91f5 CastInfo(services={ServiceInfo(type='mdns', data='TPM191E-095eded63eab273fe6fecfbd1aee91f5._googlecast._tcp.local.'), ServiceInfo(type='host', data=('192.168.10.138', 8009))}, uuid=UUID('095eded6-3eab-273f-e6fe-cfbd1aee91f5'), model_name='TPM191E', friendly_name='TV Woonkamer', host='192.168.10.138', port=8009)
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
DEBUG:pychromecast.discovery:no_polling flag not set for 192.168.10.140
DEBUG:pychromecast.discovery:got device_status DeviceStatus(friendly_name='Nest', model_name='Google Nest Mini', manufacturer='Google Inc.', uuid=UUID('a3ee24d2-b0d8-5acb-ad5d-ec3ae365de3b'), cast_type='audio')
DEBUG:pychromecast.discovery:no_polling flag set for 192.168.10.138
^CDEBUG:pychromecast.discovery:HostBrowser thread done
(venv) root@dsmr:~/pychromecast_test_only_poll_audio_casts_debug_2#
pdawg17 commented 2 years ago

OK, so this issue is not limited to Sony TV's then, but more widespread among Android TVs. It's somewhat incredible that opening a https-connection to the TV every few seconds causes stuttering of the video.

@QuadNL, can you try this version instead:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts
cd pychromecast_test_only_poll_audio_casts/
git checkout 5359cbc59ed8ff8fdaa94b8d5caf5e5e40019091
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug

Don't know if it helps at all but my Sony is on Android 10.

emontnemery commented 2 years ago

Thank you both for the patience with testing! I don't think we can avoid the initial frame drop, it should at least only happen once when Home Assistant starts.

Please try this version as well though, it will avoid querying the TV for some audio-only related stuff:

git clone https://github.com/home-assistant-libs/pychromecast.git pychromecast_test_only_poll_audio_casts_debug_3
cd pychromecast_test_only_poll_audio_casts_debug_3/
git checkout 9b05eb14521326eef7a94ec6fe466751682a1112
python3 -m venv venv
source venv/bin/activate
pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4
export PYTHONPATH="."
python3 examples/discovery_example.py --show-debug
QuadNL commented 2 years ago

Tried the version above, so far so good. Initially when TV is discoverd it's receiving a stutter at the streaming video.

pdawg17 commented 2 years ago

pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4

And just to confirm, I tried the latest one you posted for QuadNL and it also works fine for me! Just that 1 dropped frame when it starts and then smooth from there! Thanks for your hard work on this!

QuadNL commented 2 years ago

pip3 install casttube==0.2.1 certifi==2021.5.30 charset-normalizer==2.0.5 idna==3.2 ifaddr==0.1.7 protobuf==3.18.0 requests==2.26.0 urllib3==1.26.6 zeroconf==0.36.4

And just to confirm, I tried the latest one you posted for QuadNL and it also works fine for me! Just that 1 dropped frame when it starts and then smooth from there! Thanks for your hard work on this!

Well, I bought a new Philips TV and Unifi Dream Machine because of this issue. So it's an expensive bug for me. ;)