Skip to content
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

Some ogg/opus files are not recognized as "audio files" #5840

Closed
strannik-j opened this issue Mar 25, 2019 · 9 comments · Fixed by #8930
Closed

Some ogg/opus files are not recognized as "audio files" #5840

strannik-j opened this issue Mar 25, 2019 · 9 comments · Fixed by #8930

Comments

@strannik-j
Copy link

Steps to reproduce

  1. Send ogg or opus audio file more than 10 Mb size to chat.
  2. Check what category that file recieved.
  3. Check if file was placed inside player playlist or played as singular file.

Expected behaviour

File placed in "audio files" category as well as added to playlist.

Actual behaviour

Some audio files are categorized as just files.

Configuration

Operating system: Manjaro Linux x64

Version of Telegram Desktop: 1.6.2

Used theme: Default

Example of file that was categorized as just "file":
test.ogg
test.opus

@rackelhahn69
Copy link

I've got the same problem for mp3 files as well. The problem has been persisting for quite a while. Sometimes it works on my laptop, but not on my desktop even though both are running the most up-to-date version of Manjaro x64 and telegram-desktop from the community repository. I think there is a package/are packages missing...

@Nachtalb
Copy link

Nachtalb commented Apr 18, 2019

There are hundreds of audio codecs available. To support every single one is not easy. And eg. ogg is a container and not a codec/stream. The ogg file which you provided contains a video and an audio stream. The video stream is corrupted though.

I have removed the video stream from your file and voila it works as an audio file in Telegram.

image
The second one is the fixed one.

Your original test.ogg

$ ffmpeg -i test.ogg -hide_banner
[ogg @ 0x55accd891880] 8192 bytes of comment header remain
[ogg @ 0x55accd891880] invalid pts -104
Input #0, ogg, from 'test.ogg':
  Duration: 00:08:24.27, start: 0.000000, bitrate: 215 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 224 kb/s
    Metadata:
      ARTIST          : Ария
      ALBUM           : Мания Величия
      track           : 03
      TITLE           : Волонтёр
      GENRE           : Heavy Metal
      DATE            : 1985
    Stream #0:1: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 300x300 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
    Metadata:
      comment         : Cover (front)
      title           : Обложка.jpg

Removing the video stream:

$ ffmpeg -i test.ogg -vn -c:a copy test3.ogg

The fixed ogg

$ ffmpeg -i test3.ogg -hide_banner
Input #0, ogg, from 'test3.ogg':
  Duration: 00:08:24.27, start: 0.000000, bitrate: 213 kb/s
    Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 224 kb/s
    Metadata:
      ARTIST          : Ария
      ALBUM           : Мания Величия
      track           : 03
      TITLE           : Волонтёр
      GENRE           : Heavy Metal
      DATE            : 1985
      ENCODER         : Lavf57.83.100

About your second file. I guess it is just not a supported codec by Telegram. If you look at fileinfo.com eg. It already says:

The Opus codec is used for Voice over IP (VoIP), video conferencing, in-game chat. The Opus format was standardized by the IETF and is maintained by Xiph.Org.

Since the Opus codec is primarily used for streaming, files with the ".opus" extension that are encoded with the Opus codec are not common.
~ https://fileinfo.com/extension/opus

And so I don't even know why it should be used to listen to music. Usually, you do not want to use codecs which are for communication because most of the time they are very lossy and so do not have good quality for video. Imagine being on the phone with a friend, most of the time the sound of his/her voice sounds noticeably different than in real life. And now imagine using this quality for music. XD I don't think you would want that.

@Nachtalb
Copy link

https://mega.nz/#F!EoklhC6B!PXWNAWY0aeLTxHh8D6Jpkw
Here are the files for you to test by yourself.

@ixearth
Copy link

ixearth commented Apr 28, 2019

yes that test.ogg is corrupted. I can't play it with mpv and ffprobe give me errors. (IDK why it works for you probably because of ffmpeg version or whatever it doesn't matter)

[ogg @ 0x7f3c648a61c0] 8192 bytes of comment header remain
[ogg @ 0x7f3c648a61c0] Header processing failed: Invalid data found when processing input
test.ogg: Invalid data found when processing input

But I tried a ogg vorbis and ogg opus with cover art (.ogg), telegram-desktop (v1.6.7) also don't recognize it as audio.
Currently telegram-desktop seems does not recognize .opus as audio file at all.

According to RFC7845

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

lots of applications are still using .ogg for Ogg Opus files probably due to historical reasons.

@Nachtalb

And so I don't even know why it should be used to listen to music.

  1. Most of music on YouTube are in opus format, you usually get a opus file in webm container when you youtube-dl -f bestaudio. For some music I can only find on YouTube, I download it by using youtube-dl and use ffmpeg to add title (to including the youtube link) with -c:a copy, I use .opus as extension cuz it's just one opus audio stream.
  2. For some lossless music I download from various source for free, bought from online music store, I usually encode it in opus format with a target rate of 160 kbit/s.
  3. opus seems also widely used for soundtrack in games? am not sure about this cuz I rarely play games.
  4. opus is an amazing audio codec, it's not only suit for VoIP but also perfect for listening to music.
    I have original.flac (4:50, with cover art 700x700) transcode to mp3 with ffmpeg, and opusenc to opus.
original.flac     35M
mp3_320k.mp3      12M
mp3_abr_320k.mp3  11M
mp3_v0.mp3       8.9M
mp3_v3.mp3       6.0M
opus_160k.opus   5.7M
opus_128k.opus   4.6M

By looking at spectrum of these audio files, you will notice that MP3 320k (CBR) which is adopted by most of online music stores are actually cut 20kHz+, while opus VBR always cut 20kHz+ and still remain a few. MP3 VBR keeps more on 20kHz+, but 20kHz+ is not important, you can't heard the differences anyway.
and for blow 20kHz, the quality
opus 160k > opus 128k > mp3 320k > mp3 v0
while opus 160k just about half size of mp3 320k.

Opus Recommended Settings | xiph.org

Music Storage
Opus at 128 KB/s (VBR) is pretty much transparent

opus 160kbit/s was considered as a very high quality encode.

for people who store lossless music and upload to Telegram, they may encode by themselve and result in find out how great opus is and use it.

I have some music I store in lossless format but convert to opus with correct metadata and cover art and listing on my smartphone, and sometimes I upload it to telegram and listen to it.
Currently I need to convert to opus on computer, adb push to my phone, and upload it from telegram-android (have to keep the resolution of covert art lower than 900x900 or it will be upload as file instead of music).
or remove the album art and rename to .ogg so that I can send via telegram-desktop, but it's a ugly approach for sharing opus music.

It could be much convenient some people who use opus for listing to music like me if telegram-desktop have better support for Ogg Opus file (.opus, and cover art in .ogg).
#1754
#1754 (comment)
#1754 (comment)
#1754 (comment)
#1754 (comment)

@Nachtalb
Copy link

@ixearth
Thanks for the info on the opus format. Didn't know about the wide usage of it and just looked at the fileinfo.com entry. 👍

@strannik-j
Copy link
Author

strannik-j commented Apr 30, 2019

@Nachtalb About video stream in the test file.ogg: I just added the cover of 300*300 px with EasyTag, and older versions of telegram-desktop was perceived a file as audio. How do I add covers to audio now? By the way, the mobile version perceives a file correctly and shows a cover.

@ixearth
Copy link

ixearth commented Apr 30, 2019

@strannik-j you can add album art as a video stream and use .ogg as container by using ffmpeg, remember to use -c:a copy to avoid re-encode. but this probably not the correct way to embed an image as cover art to an audio file.
opus-tools can't import-picture for opus, while metaflac support to do so.
opusenc (from opus-tools) only can be used for convert lossless audio format to opus, optionally add covert art. actually you can convert opus to lossless format with cover added, and convert to opus by using opusenc (or add cover art in this step), but this could reduce the audio quality due to re-encoding.

I don't recommend to add cover art to opus. for music you can't get at lossless quality, you can just edit the metadata (title, artist names etc) or maybe just file name. and use music player to fetch album art from other source while playing. There are lots of music players support fetch cover art from online sources.

Telegram Desktop does not show any cover art, Telegram for Android/iOS fetch cover art from iTunes store (by read metadata or file name). I don't think it display the cover art in metadata.

Generally I just convert flac which included cover art to opus by using opusenc, and the cover art will be remain there.

@Aokromes
Copy link
Collaborator

Aokromes commented Jul 2, 2019

#1754

@github-actions
Copy link

github-actions bot commented Mar 6, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants