TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
30.97k stars 3.01k forks source link

File extension for downloaded Opus audios should be .ogg for Android 9 and below #8046

Open frak0d opened 2 years ago

frak0d commented 2 years ago

Checklist

Affected version

0.22.1

Steps to reproduce the bug

  1. Open any Video
  2. Tap on Download Button
  3. Select Audio Download in opus codec (any bitrate)

Expected behavior

Opus files should be downloaded with the .ogg file extension on Android 9 and below, since the support for recognising the .opus file extension was added in Android 10.

Actual behavior

File is downloaded with the .opus file extension on all OS versions, which is not recognised by many apps, including Android's MediaScanner.

Affected Android/Custom ROM version

Android 5, 6, 7, 8 and 9.

TacoTheDank commented 2 years ago

I don't think this is necessarily an issue with Opus as it is with Android support over different OS versions.

It would be good to consider what we would want the new behavior to be if this were to be changed. Would we want the audio to be saved as .ogg for Android 9 or lower, and be saved as .opus for Android 10 and above?

frak0d commented 2 years ago

Just save with .ogg extension for all android versions because there is no such thing as a .opus file, opus is a codec. The file container is actually a ogg, so correct extension is .ogg

opusforlife2 commented 2 years ago

Just save with .ogg extension for all android versions because there is no such thing as a .opus file, opus is a codec. The file container is actually a ogg, so correct extension is .ogg

@Tanishq-Banyal Your information is incorrect. You're mixing containers and file extensions: https://en.wikipedia.org/wiki/Opus_(audio_format)#cite_note-MIME-and-FileExt-1

Following that link: https://wiki.xiph.org/MIME_Types_and_File_Extensions#.opus_-_audio.2Fogg

So the codec is Opus, and the container format is indeed Ogg, but the "official" file extension is .opus. 3 different things.

As a much clearer example, look at MP4: https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions:

While the only filename extension defined by the standard is .mp4, various filename extensions are commonly used to indicate intended content


Coming to your issue:

which is not recognised by many apps including Android System itself

This is the bug you've reported. But LineageOS added support for the .opus file extension in Android 9 (LOS 16), the version you've mentioned! See https://review.lineageos.org/q/opus+extension

I've been storing and playing .opus files myself since LOS 16. If you use a file explorer app that supports showing .opus files, then you can play them just fine. Try using FX File Explorer and Vanilla Music. Both showed and played the files for me.

opusforlife2 commented 2 years ago

Part 2 (the comment was getting too long):

Would we want the audio to be saved as .ogg for Android 9 or lower, and be saved as .opus for Android 10 and above?

@TacoTheDank Using the .ogg file extension will only work for Android 7, 8, and 9, because support for it was added in 7: https://en.wikipedia.org/wiki/Opus_(audio_format)#Operating_system_support

Reading that section further, if you want Android System to natively recognize and play Opus audios for Android 5 and 6, you will need the Matroska container with the Opus codec, which was the only combo supported for those versions. You could use the .mka file extension instead of .mkv to indicate audio content, but I don't know how many file explorers and audio players support that.


Extra info for the interested: Most audio players only care about the container format, not the file extension. That is more the domain of file explorer apps, to be able to identify file types and show them in the UI correctly. As proof, you can rename an Opus audio file downloaded from Newpipe to .opus, .ogg, and .oga, and it will play just fine each time (assuming your media player can recognise both: Opus the codec, and Ogg the container format. Try Poweramp, or Vanilla Music).

frak0d commented 2 years ago

My music player (musicolet) does recognise .opus as well as .ogg, just my system file explorer (Android Documents UI) doesn't recognise .opus.

I am not affected much by this as I have a script running in background that renames any .opus file to .ogg in Music folder whenever a new .opus file is detected.

opusforlife2 commented 2 years ago

Is your LOS 16 build older than the commits I linked to? That's the only reason I can think of why your system file explorer isn't recognising them.

I'm on LOS 17.1, and the system Files app shows the file type of .opus files as "OGA audio", and the MIME type as "audio/ogg".

frak0d commented 2 years ago

I'm on LOS 17.1, and the system Files app shows the file type of .opus files as "OGA audio", and the MIME type as "audio/ogg".

I am on LOS 16.0, and system files app shows mime type "application/octet-stream" ie. binary file

But as I said earlier :-

I am not affected much by this as I have a script running in background that renames any .opus file to .ogg in Music folder whenever a new .opus file is detected.

opusforlife2 commented 2 years ago

Okay. Then let's limit this issue to keeping .ogg for Android 9-, and .opus for Android 10+. This will be much easier than adding Matroska container support for Android 5 and 6.

TacoTheDank commented 2 years ago

@TacoTheDank Using the .ogg file extension will only work for Android 7, 8, and 9, because support for it was added in 7: https://en.wikipedia.org/wiki/Opus_(audio_format)#Operating_system_support

Yep I'm aware, I just shortened it in my statement and assumed that people visiting this issue would read as such in the linked Wikipedia article. Maybe I should have clarified, lol.

opusforlife2 commented 2 years ago

assumed that people visiting this issue would read

Now there's a super-optimistic person. xD

Atemu commented 2 years ago

Quoting rfc7845:

The RECOMMENDED filename extension for Ogg Opus files is '.opus'.

As this is only a recommendation, I'd prefer to stick to ogg because OGG is a somewhat common audio container format that people know and the most widely used file extension for it is ogg, no matter the inner codec.

I'm also doubtful that the crappy music players people love to use can handle the opus extension well (despite Android 10) while I'd expect most of them to be able to handle ogg.

What do you think of an audio format option to save files as webm that gets enabled by default when the initial run happens on Android <7?
Default with that option off would be ogg.


OT: @opusforlife2's username checks out ;D

opusforlife2 commented 2 years ago

I don't see why we should mislabel files because people use crappy/old music apps. Instead, this could nudge them toward using updated music apps that do recognise the .opus extension. Android 10 was released in 2019. Any competent music app developer should have added support for it after that point.

Atemu commented 2 years ago

Instead, this could nudge them toward using updated music apps that do recognise the .opus extension.

While the idealist in me agrees, the realist sees people that are confused about weird audio formats their favourite music player can't and blame NewPipe for it.

Any competent music app developer should have added support for it after that point.

This implies competence among said developers which I don't think exists universally.

opusforlife2 commented 2 years ago

I just searched, and we've never actually had anyone complain about not being able to play Opus files. (Disclaimer, there is one issue, but back then Newpipe's Opus support itself was broken.)

frak0d commented 2 years ago

just let the user choose file extension in download settings

opusforlife2 commented 2 years ago

We're always conservative about introducing additional options that need to be maintained. In this case, an option isn't needed at all, because the suggested defaults make sense:

.opus for 10+ and .ogg for 5-9.

opusforlife2 commented 2 years ago

What does that mean, exactly? The discussion is open to anyone who wants to add anything. Apart from that, we need a PR to implement this.

otonoton commented 1 month ago

there is no such thing as a .opus file

From https://datatracker.ietf.org/doc/html/rfc7845

The RECOMMENDED filename extension for Ogg Opus files is '.opus'.