-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vorbis & Opus support #769
Conversation
I had completely forgotten I had even made that PR... I suppose I should close it in favor of this. |
@@ -92,6 +94,8 @@ def test_encoder_not_found_error(self): | |||
("mp3", "mp3"), | |||
("opus", "opus"), | |||
("flac", "flac"), | |||
("ogg", "ogg"), | |||
("opus", "opus"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need another entry for opus
here. A previous one is already defined few lines above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't event see it.
Was there already a support for Opus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, kinda. YouTube offers two audiostreams. One with the opus codec and the other with m4a codec. These input formats also need to be recognized by the encoder (along with the possible output formats), which is why the entry already exists. But now with your PR, we'll also be able to output to opus irrespective of whether the input format is or not opus, which is a good thing.
Hello and thanks a lot for the PR! This looks pretty good as is but I'll check it in detail after some time, just in case. |
Dunno why the Travis build isn't running though. |
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
The release dates mentioned follow the format `DD-MM-YYYY`. | |||
|
|||
## [Unreleased] | |||
- Add support for Vorbis & Opus output formats. ([@Sigill](https://github.com/Sigill)) (#769) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to go under Added
subsection (you'll have to create it) for consistency (like past releases).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
5eee174
to
71b9742
Compare
if metadata["year"]: | ||
audiofile["year"] = metadata["year"] | ||
provider = metadata["provider"] | ||
audiofile["comment"] = metadata["external_urls"][provider] | ||
if metadata["lyrics"]: | ||
audiofile["lyrics"] = metadata["lyrics"] | ||
|
||
def _embed_mpb_picture(self, audiofile, metadata, cached_albumart, encoding): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make cached_albumart
default to None
here too like with other methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think it is better this way.
Since _embed_mpb_picture
is an internal method, supposed to be called from one with a default value, it does not look necessary to add the default value.
This syntax is also consistent with _embed_basic_metadata
, where the input parameters (audiofile
, metadata
, cached_albumart
) stay separated from the extra encoding
parameter, which plays a different "role".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I think that makes sense given this is an internal method. Alrighty, let's leave it as it is then!
elif encoding == "ogg" or encoding == "opus": | ||
# From the Mutagen docs (https://mutagen.readthedocs.io/en/latest/user/vcomment.html) | ||
image_data = image.write() | ||
encoded_data = base64.b64encode(image_data) | ||
vcomment_value = encoded_data.decode("ascii") | ||
audiofile["metadata_block_picture"] = [vcomment_value] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this really works? I tried downloading both in ogg and opus formats but the media seemed to contain no albumart when I checked with mpv or FFmpeg (though other metadata like title, artist, etc. seems to exist).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it works, yes.
I just downloaded the same playlist in flac, ogg and opus, and in all formats, all the tracks had an albumart that VLC, FFMpeg & Easytag are able to display.
Are you sure that what you downloaded contains an albumart in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that what you downloaded contains an albumart in the first place?
Yup, I'm pretty sure:
$ spotdl -s https://open.spotify.com/track/4Sfa7hdVkqlM8UW5LsSY3F -o opus
That shouldn't matter though as all tracks will atleast always use the albumart from YouTube if the corresponding albumart is not found on Spotfiy, which means the albumart should be present in every case (as long as --no-metadata
isn't passed).
I'll check around to see what's up here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like my FFmpeg is having trouble (mpv probably fails too because it uses FFmpeg) reading the ablumart metadata. The albumart shows up fine on my Android with Pulsar app. 👍
71b9742
to
419e80e
Compare
Do you prefer the option be named ogg or vorbis? |
I see but let's keep it as ogg so that it is more about the file extension rather than the encoding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks again for the great contribution @Sigill!
@ritiek you're trying to view ogg/opus album art with ffmpeg, ffmpeg doesn't have support for that. It's a ffmpeg issue. Other media players can show ogg/opus album art. |
My ffmpeg is able to report albumarts for ogg & opus.
Oh, my bad, I though there was the single spot that @ritiek mentioned, but there are two other duplicates. I'll fix that. I saw the comments on the previous PR about re-encoding. I think I agree with @ritiek (I'm not an audio expert, though, feel free to correct me), when doing opus -> opus, there's no benefit from re-encoding. Same goes from upsampling.
|
@Sigill has already addressed this:
I see. I didn't pay much attention to the changes in your PR back then. I didn't realize that there was a difference between the sampling rate between the audio codecs provided by YouTube. You seem to have also posted a log of If you like you can make a new PR for the sampling rate concerns.
That was an oversight on my behalf as well.
Yea, he's really bad. |
It shows just in command line as a vorbis comment (metadata_block_picture), that is ascii (b64 encoded image).
That is what I'm saying too. By default re-encoding should be avoided as much as possible to not to lose quality.
here it is sampling 44kHz AAC stream to 48kHz mp3, same with FLAC in line 19. FLAC supports 44kHz.
I thought that you would change that in refactoring, It is just small change. If you are not sure, I will be happy to make a PR.
Nah, you just said you missed my comment log. I think you're just too busy. |
Alright, I'll be glad to merge it. By the way, do we really need to explicitly specify the output sample rate to FFmpeg? Shouldn't FFmpeg automatically be able to determine the output sample rate from sample rate in the input audio? I just tried and FFmpeg seems to keep the sample rate for the output audio same as in the input audio. Is this supposed be the right way? |
Yes ffmpeg keeps sample rate same, if codec supports it. Otherwise it will automatically change to supported sampling rate. |
Sounds good to me. |
Just a gentle ping guys. Are you up on making PRs?
If you're busy atm, let me know so I'll do it myself. |
I'm AFK for the weekend, feel free to give it a go.
Le ven. 26 juin 2020 à 12:52, Ritiek Malhotra <notifications@github.com> a
écrit :
… Just a gentle ping guys. Are you up on making PRs?
Why is still double entry of opus exists in PR, and you merged it already.
Oh, my bad, I though there was the single spot that @ritiek
<https://github.com/ritiek> mentioned, but there are two other
duplicates. I'll fix that.
@Sigill <https://github.com/Sigill>
If you are not sure, I will be happy to make a PR.
@mrkumar009 <https://github.com/mrkumar009>
If you're busy atm, let me know so I'll do it myself.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/ritiek/spotify-downloader/pull/769#issuecomment-650116917>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAR4YMIAMGMQFAGHSYSSPE3RYR4XFANCNFSM4ODR2CJA>
.
|
FFmpeg implicitly outputs media at the desired sample rate. So, there is no need to explicitly specify a sample rate. This also eliminates the possibility where the original sample rate may differ drastically from the output sample rate. Also refer to #769.
FFmpeg implicitly outputs media at the desired sample rate. So, there is no need to explicitly specify a sample rate. This also eliminates the possibility where the original sample rate may differ drastically from the output sample rate. Also refer to #769.
PR ritiek/spotify-downloader#292 by @BeeeWall already attempted to bring support for Vorbis and Opus as output formats, but some recent refactoring caused it to not be easily rebaseable.
I therefore restarted from scratch.