blog/markdown/Play-all-media-everywhere.md

80 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

2024-08-18 22:30:31 +02:00
[//]: # (title: Play all media, everywhere)
[//]: # (description: Use Platypush to watch YouTube, Facebook and more on your favourite media player.)
[//]: # (image: https://platypush-static.s3.nl-ams.scw.cloud/images/media-ui-1.png)
[//]: # (author: Fabio Manganiello <fabio@platypush.tech>)
[//]: # (published: 2024-08-18)
Platypush 1.2.3 [is
out](https://git.platypush.tech/platypush/platypush/src/branch/master/CHANGELOG.md#1-2-3),
and the main focus of this release is on the #media side.
In particular, Platypush now supports streaming/playing/downloading any media
compatible with youtube-dl / yt-dlp, even if the upstream audio/video files are
split - yay!
This means that it's again compatible with #YouTube URLs (the integration broke
recently after YouTube migrated all of its media to split video+audio tracks),
and a lot of other sources that have been using this practice for a while -
Facebook, Instagram, X, TikTok etc.
It means that you can play anything that yt-dlp can digest to any supported
media plugin - VLC, mpv, mplayer, gstreamer, Kodi or Chromecast/Miracast.
Note however that mileage may vary depending on the player.
Things work fine out of the box if you use `media.mpv`. MPV comes with native
youtube-dl support, and the right stuff will be used to play the video smoothly
if youtube-dl or yt-dlp are present on the system.
[`media.vlc`](https://docs.platypush.tech/platypush/plugins/media.mpv.html) and
[`media.gstreamer`](https://docs.platypush.tech/platypush/plugins/media.gstreamer.html)
now provide two different play modes for YouTube-compatible content: _play on
the fly_ and _play with cache_. In play-on-the-fly mode (default) audio and
video content will be mixed on the fly over ffmpeg and piped to the player
process. This means shorter load times, it's a good fit for live streams and
large files, but it also means potentially lower media quality, high chances of
media jitters in case of gaps in the stream being transcoded, and reduced
ability to seek through the media. In play-with-cache mode the transcoded
content will be cached to disk instead. It means waiting a bit longer for the
video to load, and higher disk usage in case of large streams, but also a more
robust and smooth playback experience.
![Screenshot of the media playlist UI, showing a context menu with the existing
"Play" option and the new "Play (With Cache)"
option](https://platypush-static.s3.nl-ams.scw.cloud/screenshots/media-ui-screenshot-1.png)
However I'm investigating a way to pass both an audio and a video URLs to
GStreamer (it doesn't seem to be easily feasible with VLC), so the player can
do its own tuned mixed playback without me having to reinvent the wheel. If I
can sort it out, and manage to avoid big audio offsets in the playback process,
then this could be the default mode for GStreamer.
[`media.mplayer`](https://docs.platypush.tech/platypush/plugins/media.mplayer.html)
only supports play-with-cache mode. The plugin already uses the player's stdin
to communicate commands, and AFAIK MPlayer doesn't support sending both
commands and media bytes to the player. Same goes for
[`media.kodi`](https://docs.platypush.tech/platypush/plugins/media.kodi.html).
[`media.chromecast`](https://docs.platypush.tech/platypush/plugins/media.chromecast.html)
mileage may vary depending on the model of Chromecast. I haven't had much luck
playing audio+video simultaneously when Platypush streams YouTube content to
1st-gen Chromecasts because the new video codecs used by YouTube videos
apparently aren't available on those devices. I've had mixed results by forcing
the container to transcode the video track to H264 (and that is also the new
default configuration for `ytdl_args` for the `media.chromecast` integration),
but there's still a 50/50 chance that the Chromecast will only play the audio.
I've had better luck with more recent Chromecast models though. And I believe
that things should work just fine if you use any modern
Miracast/DLNA-compatible device/dongle. Given the deprecation status of the
Chromecast, and the dubious compatibility with whatever the Google TV folks are
planning next, I'm not even sure if it's worth investing further energies in
for the Chromecast compatibility. `media.chromecast` now also provides a
`use_ytdl` configuration flag - it's set to true by default, but you can
disable if you want to stream YouTube/Facebook/TikTok etc. URLs to your
Chromecast bypassing the Platypush streaming service. This means higher chances
that the content will play fine, but it also means that it'll be played by
whatever compatible app (if available) runs on your Chromecast (i.e.
ads/tracking/account limitations/geo limitations etc.).
Stay tuned!