Select MP4 audio streams only (experimental)
The filter used to select the stream with the highest bitrate, but this may result in a stream with a codec/container that is not supported by all podcast clients, such as WEBM. Select the (almost always available) highest stream using the MP4 container instead.
This commit is contained in:
parent
371b758962
commit
7f1120fd47
|
@ -308,7 +308,9 @@ async fn fetch_stream(
|
||||||
.streams()
|
.streams()
|
||||||
.await
|
.await
|
||||||
.ok()?
|
.ok()?
|
||||||
.filter(|v| v.is_audio())
|
// Select the well-supported, almost always available MP4 container format with
|
||||||
|
// only an audio stream and then the one with the highest bitrate.
|
||||||
|
.filter(|v| v.is_audio() && v.mime_type().contains("mp4"))
|
||||||
.max_by_key(|v| v.bitrate())?;
|
.max_by_key(|v| v.bitrate())?;
|
||||||
let content_length = stream.content_length().await.ok()?;
|
let content_length = stream.content_length().await.ok()?;
|
||||||
|
|
||||||
|
@ -337,7 +339,9 @@ async fn retrieve_redirect_url(client: &Client, video_id: &str) -> Result<String
|
||||||
let stream = video
|
let stream = video
|
||||||
.streams()
|
.streams()
|
||||||
.await?
|
.await?
|
||||||
.filter(|v| v.is_audio())
|
// Select the well-supported, almost always available MP4 container format with only an
|
||||||
|
// audio stream and then the one with the highest bitrate.
|
||||||
|
.filter(|v| v.is_audio() && v.mime_type().contains("mp4"))
|
||||||
.max_by_key(|v| v.bitrate())
|
.max_by_key(|v| v.bitrate())
|
||||||
.ok_or(Error::NoRedirectUrlFound)?;
|
.ok_or(Error::NoRedirectUrlFound)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue