Closed lwsrbrts closed 1 year ago
I am guessing you're playing this on a Nest Hub or something similar, I tried it on that device as well and got the same result. I am suspecting that it might have to do with the receiving end of the url. As in, the media player gets called with a correct url, but then something there fails. Do you maybe have other media players to test this on?
I have a recently purchased "Chromecast with Google TV" which gives interesting results. This one obviously has an interface for me to see what's happening.
Same service call, different target
service: media_extractor.play_media
data:
entity_id: media_player.office_tv
media_content_id: https://www.youtube.com/watch?v=Nv6F1VVh5D0
media_content_type: video/youtube
This is the result... the target seems to be playing because the progress bar is moving along, but there is no sound and it's completely silent (maxing out a Yamaha RX-V775 receiver which the Chromecast with Google TV is plugged in to and only getting absolute silence)
This is the logbook for the device which also shows it's playing but there's no sound.
I guess what's mostly different here is that the (old) Google Home device never gets past buffering
but at least the Google TV plays, just with no sound.
That's interesting, on my google home I can see the picture but it doesn't play.
I'll try to give it another debug round. For now, you can play youtube to cast enabled devices via play media, I use a service to play the latest video (from the youtube integration).
service: media_player.play_media
data:
media_content_id: " { \"app_name\": \"youtube\", \"media_id\": \"{{ state_attr('sensor.linus_tech_tips_latest_upload', 'video_id') }}\" }"
media_content_type: cast
enqueue: add
target:
device_id: 67147aa8fb8b528fbb91117dfca8c504
This would at least enable you to play youtube on your device, except not via the media extractor.
In this service, media_id should be set to Nv6F1VVh5D0
to get your situation
Thanks for the workaround suggestion. That service works great where there's a device that can start apps/show video, like a Chromecast with Google TV, Nest Hub or an nVidia SHIELD but unfortunately the devices I want to target are typically audio only devices like Google Chromecast Audio (discontinued by Google), a Nest Audio or a Google Home (just an audio device) and unfortunately that service call does nothing when I target them - basically no different to when I click the cast icon within the YouTube app, I can't target any of the audio only devices I have. What is interesting though is that I can still target my audio only devices if I press the Cast icon within the YouTube Music app.
My use case for Media Extractor is to just play the audio from YouTube videos (like Above and Beyond Group Therapy) to my Google Chromecast Audio devices which I have plugged in to Receivers and soundbars around my home. The devices are great for just audio listening. Since most of my audio systems do have HDMI inputs, I could technically replace all the Google Chromecast Audio devices with Chromecast with Google TV, but since Media Extractor/youtube_dl did that job wonderfully up until a few months ago, that wasn't necessary and they still work perfectly when I'm listening to podcasts with direct URLs.
The good old chromecast audio :), Still have one here.
I did not knew that you could do audio only before, this seems an interesting use case. I saw media extractor has the option for different kind of quality attributes, do you use some by any chance?
I'll have a look later
Thank you. Yes, I use a set of Scrape sensors to retrieve the latest podcast URL from a feed (so usually an MP3 or M4A) which I simply provide to a Google Cast group using the media_player.play_media
service. Where I was attempting to play something from YouTube, I'd instead use the media_extractor.play_media
service instead.
I use/used media extractor without any quality settings but I was aware there were options, so as you might imagine, I have tried some to see if they worked but without success.
As reported here https://github.com/home-assistant/core/issues/97389#issuecomment-1691632804 the problem is on the last link retrieved by the component that is not suitable for casting: manifest.googlevideo.com The solution posted is working fine for me.
As reported here #97389 (comment) the problem is on the last link retrieved by the component that is not suitable for casting: manifest.googlevideo.com The solution posted is working fine for me.
Sorry for my ignorance, where is the solution intended to go? Is it part of a script or does it go in code? If in code, I assume those of us with HA OS will need to wait for this fix to be implemented, presumably by @joostlek or another dev?
Adding unit tests to Media extractor is something on my to do list, as its hard to debug every time. I needed some more information but I got that, so I will work on it soon
I now added some code to filter out the manifest files
Awesome news, thank you for your work!
:(
Apologies @joostlek I'm not getting any success with playing the sound from a YouTube video/link in 2023.10.0b2 (having tried b0 and b1 also)
Here's the service call I'm using:
service: media_extractor.play_media
data:
media_content_id: https://www.youtube.com/watch?v=ZJReUusGA08
entity_id: media_player.office_home
media_content_type: video/youtube
Which results in only this in the logs:
2023-09-29 09:59:07.391 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] Extracting URL: https://www.youtube.com/watch?v=ZJReUusGA08
2023-09-29 09:59:07.391 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] ZJReUusGA08: Downloading webpage
2023-09-29 09:59:07.904 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] ZJReUusGA08: Downloading ios player API JSON
2023-09-29 09:59:08.054 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] ZJReUusGA08: Downloading android player API JSON
2023-09-29 09:59:08.147 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] ZJReUusGA08: Downloading player f7e1823a
2023-09-29 09:59:08.649 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] ZJReUusGA08: Downloading m3u8 information
Nothing else appears in the logs after the m3u8 information entry and no attempt is made to play anything.
Can you set media content type to VIDEO?
I'll add some more log messages to know what we are sending to the service call
Yes, I also tried that as per the documentation but got the same result unfortunately.
Right, it didn't help that you chose a video with a still image. When I opened the link it sent on my pc it actually started playing. But, without sound.
Yes, the video itself from the example service call I posted is just a still image but it is a 3 hour "mix". I have of course tried other videos but none will get to the point of playing. Some other examples I'd use below.
The latest Above & Beyond mix (2 hours) - has moving/changing video too: https://www.youtube.com/watch?v=jclSCYXEx3k
Nora En Pure mix (1 hour) - video only changes per track within the mix - https://www.youtube.com/watch?v=RYc9DU_7rRg
Le Youth - About Us (4.5 mins) - video - https://www.youtube.com/watch?v=0fdcoi-Da0w
2023-09-30 09:56:45.269 DEBUG (SyncWorker_4) [homeassistant.components.media_extractor] [youtube] Extracting URL: https://www.youtube.com/watch?v=jclSCYXEx3k
2023-09-30 09:56:45.269 DEBUG (SyncWorker_4) [homeassistant.components.media_extractor] [youtube] jclSCYXEx3k: Downloading webpage
2023-09-30 09:56:45.835 DEBUG (SyncWorker_4) [homeassistant.components.media_extractor] [youtube] jclSCYXEx3k: Downloading ios player API JSON
2023-09-30 09:56:45.981 DEBUG (SyncWorker_4) [homeassistant.components.media_extractor] [youtube] jclSCYXEx3k: Downloading android player API JSON
2023-09-30 09:56:46.075 DEBUG (SyncWorker_4) [homeassistant.components.media_extractor] [youtube] jclSCYXEx3k: Downloading m3u8 information
2023-09-30 10:01:46.473 DEBUG (SyncWorker_0) [homeassistant.components.media_extractor] [youtube] Extracting URL: https://www.youtube.com/watch?v=RYc9DU_7rRg
2023-09-30 10:01:46.473 DEBUG (SyncWorker_0) [homeassistant.components.media_extractor] [youtube] RYc9DU_7rRg: Downloading webpage
2023-09-30 10:01:47.091 DEBUG (SyncWorker_0) [homeassistant.components.media_extractor] [youtube] RYc9DU_7rRg: Downloading ios player API JSON
2023-09-30 10:01:47.222 DEBUG (SyncWorker_0) [homeassistant.components.media_extractor] [youtube] RYc9DU_7rRg: Downloading android player API JSON
2023-09-30 10:01:47.344 DEBUG (SyncWorker_0) [homeassistant.components.media_extractor] [youtube] RYc9DU_7rRg: Downloading m3u8 information
2023-09-30 10:03:49.551 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] Extracting URL: https://www.youtube.com/watch?v=0fdcoi-Da0w
2023-09-30 10:03:49.552 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading webpage
2023-09-30 10:03:50.128 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading ios player API JSON
2023-09-30 10:03:50.271 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading android player API JSON
2023-09-30 10:03:50.363 DEBUG (SyncWorker_6) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading m3u8 information
2023-09-30 10:07:15.914 DEBUG (SyncWorker_2) [homeassistant.components.media_extractor] [youtube] Extracting URL: https://www.youtube.com/watch?v=0fdcoi-Da0w
2023-09-30 10:07:15.915 DEBUG (SyncWorker_2) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading webpage
2023-09-30 10:07:16.533 DEBUG (SyncWorker_2) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading ios player API JSON
2023-09-30 10:07:16.673 DEBUG (SyncWorker_2) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading android player API JSON
2023-09-30 10:07:16.771 DEBUG (SyncWorker_2) [homeassistant.components.media_extractor] [youtube] 0fdcoi-Da0w: Downloading m3u8 information
Yes yes, I just played around some with it. My problem last time was that I had my device muted so I didn't recognise that it didn't have sound. I made a fix, will be in the b3.
The max resolution is now 720p as that's the only stream with both audio and video.
Oh and the debug now also posts the link it found
Gotcha. Thanks for clarifying. I have YouTube premium so I don't get bombarded with ads - obviously media extractor won't be using that so I assume YouTube has started limiting the bitrate(s) for non premium requests. Thanks for your work @joostlek - much appreciated.
Not really, above 720p, the streams are split into 2. So one for video one for audio.
Anyway, will you be testing b3?
As soon as it's available to me, absolutely.
I think it is now
Success!
service: media_extractor.play_media
data:
media_content_id: https://www.youtube.com/watch?v=jclSCYXEx3k
entity_id: media_player.office_home
media_content_type: video/youtube
I also tried it to a Chromecast Audio device medial_player.office_audio
and that worked too. It's also much quicker getting to the point of playing the audio than it was when it used youtube_dl
, so that's a bonus!
Thank you again!
Also, when you now debug media_extractor you can view what link it's sending. Also I am working on a separate service (since we now have service responses) to return the media info in a service call. This way you can do whatever you want with it, download it, stream it, whatever
The problem
A previous issue I raised was fixed by @joostlek and that merged change has resolved the issue for Soundcloud links, however, YouTube links are still affected in 2023.8.0b4.
Using this service call:
or this
Results in the attempt to play the resource failing due to a stall (seemingly in yt-dlp) downloading m3u8 information...
I have manually used the yt-dlp binary and provided the same link and that works as expected. I have tried altering my
configuration.yaml
file to specify a default, as well as leaving it without any specifics around thedefault_query
section but get the same result. In the example below, I have commented out thedefault_query
I tried.What version of Home Assistant Core has the issue?
2023.8.0b4
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
media_extractor
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
Previous issue link: https://github.com/home-assistant/core/issues/97389