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

Converting mp3 stream to ogg vorbis #2

Closed
tommedema opened this issue Jun 12, 2011 · 2 comments
Closed

Converting mp3 stream to ogg vorbis #2

tommedema opened this issue Jun 12, 2011 · 2 comments

Comments

@tommedema
Copy link
Contributor

I realize this may not be an issue specific to your project, it's more an issue of mine. If there is a better place to post this please tell me.

Anyway, I have created a simple test project using your library, called NodeFFmpegTest, as you can see here:
https://github.com/tommedema/NodeFFmpegTest/blob/master/main.js

The goal of this test is to provide a demo of converting an incoming audio stream (at the moment mp3) to a writable stream (currently ogg vorbis). This is a very common use case, for example to allow iPad users to listen to music in their browsers using HTML5's audio tag (it supports ogg vorbis, but not mp3).

Please look at the link above to see my simple code. The problem I face is that the input mp3 is about 5MB while by default, the output ogg vorbis file 28.8MB (yet it's supposed to be a highly optimized format for the web).

Strangely enough, the setAudioBitrate option does not seem to have any effect on file size. Could this be a bug? I've also tried setting the -ar option, which had the same result (or lack thereof).

Forcing mono sound (1 channel) instead of 2 did reduce the size to about 14MB, but this should not be necessary. This original MP3 is in stereo as well.

An audio frequency of 22050 did help, it reduced the size to 15.8MB, note that the MP3 apparently has a frequency of 44100Hz. As expected, a frequency of 11025 makes the sound quality horrible.

The -aq option (audio quality) appears to have no effect at all.

Have you experimented with such conversion? Any help would be greatly appreciated.

@tommedema
Copy link
Contributor Author

Wow, after installing libogg and libvorbis, then configuring with --disable-encoder=vorbis --enable-libvorbis and reinstalling ffmpeg as well as using .withAudioCodec('libvorbis'), audio quality is super-great and the file size went from 5MB to... 1.9MB. Insane. From 28MB to 2MB by using a different codec library, with exactly the same settings (44100Hz, 128Kbit/sec etc.).

Two slight worries though, maybe you can help here:

  1. I'm getting [mp3 @ 0x1993400] max_analyze_duration 5000000 reached at 5015510 as part of the err output, yet conversion seems to go fine. The output file is complete as well (duration is the same).

  2. There err parameter always seems to be filled with a complete log, even if there is no error (the one of the writeToStream callback. Output looks like this:

    ffmpeg version git-N-30727-gd127d26, Copyright (c) 2000-2011 the FFmpeg developers built on Jun 12 2011 14:49:21 with gcc 4.4.5 configuration: --disable-encoder=vorbis --enable-libvorbis libavutil 51. 8. 0 / 51. 8. 0 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 3. 1 / 53. 3. 1 libavdevice 53. 1. 1 / 53. 1. 1 libavfilter 2. 15. 1 / 2. 15. 1 libswscale 0. 14. 1 / 0. 14. 1 [mp3 @ 0x1993400] max_analyze_duration 5000000 reached at 5015510 Input #0, mp3, from 'pipe:': Metadata: title : Karma Police album : The Best Of Radiohead track : 05/17 encoded_by : Exact Audio Copy (Secure mode) publisher : Capitol artist : Radiohead album_artist : Radiohead genre : Alternative composer : Radiohead date : 2008 Duration: 00:04:20.64, start: 0.000000, bitrate: N/A Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 186 kb/s Output #0, ogg, to 'pipe:1': Metadata: title : Karma Police album : The Best Of Radiohead TRACKNUMBER : 05/17 encoded_by : Exact Audio Copy (Secure mode) publisher : Capitol artist : Radiohead ALBUMARTIST : Radiohead genre : Alternative composer : Radiohead date : 2008 encoder : Lavf53.3.1 Stream #0.0: Audio: libvorbis, 44100 Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 size= 1904kB time=00:04:20.62 bitrate= 59.8kbits/s video:0kB audio:1882kB global headers:4kB muxing overhead 0.948059%

Could this be a bug?

@tommedema
Copy link
Contributor Author

Closing issue as the err issue has been described elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant