ffmpeg and libmp3lame produces bad audio quality?

6,206

This is the command line you want:

ffmpeg -i ~/test.flv -acodec libmp3lame -qscale 8 test.avi

Using the video you suggested as example i have almost the same quality in vlc as original (original has aac encoding).

You were specifying a way too high bitrate (2Mb/sec, 192kb/sec is far enough), i don't think it had any collateral effect on your command line though.

The difference is made by -qscale 8 which let ffmpeg output a VBR mp3 instead of a CBR stream.

Share:
6,206

Related videos on Youtube

Bevor
Author by

Bevor

Updated on September 17, 2022

Comments

  • Bevor
    Bevor almost 2 years


    when I get a flash video from YouTube, why is the quality of the audio much worse than the origin video on YouTube? When I downloaded the flash movie, I convert it to avi like this:

       ffmpeg -i ~/"$2.flv" -sameq -acodec libmp3lame -vol 200 -ar 44100 -aq 300 -ab 2097152 ~/"$2.avi"
    

    I already set -aq (audio quality) to 300, but no difference to 100 or 200. Moreover 100 is the max. value in my opinion. -ar (frequecy) 44100 should be ok too and the bitrate in bit/s (-ab) should be 256kb/s (2097152 / 1024 / 8). I am not sure what is the right bitrate for a good quality but I think 256kb/s should be fine. Or did I calculate it wrong?

    What could be the problem?

    • Peter.O
      Peter.O over 13 years
      Is the avi audio worse that the one you download? or is it only worse than the one you play/watch in the browser.. (maybe you are downloading a video with lower quality than the one you watch in the browser)... I ran your command for several of my .flv clips and the sound was fine... What is the audio format of the downloaded file? Does it sound bad, or is it just out of sync? .. and what is the source bitrate? There is no value in upping the bitrate more than the origial quality.. it will only lose quality by re-encoding it.
    • Pavan Kumar
      Pavan Kumar over 13 years
      did you try to just copy the audio stream to the destination video? ffmpeg [...] -acodec copy [...] . To check if the input flv file has mp3 audio, ffmpeg -i. also, you can express bitrate in the 192k format if you prefer
    • Bevor
      Bevor over 13 years
      @fred.bear. Actually one never knows what is the source bitrate or what is the audio format of the downloaded file. I just download it within a bash script using youtube-dl and the upper shown encoding. The sound is not out of sync but just bad. When I watch it in the browser on YouTube it sounds much better.
    • Bevor
      Bevor over 13 years
      @guido. ...-acodec copy was a good proposal. The sound is as good as at the source but now I have another problem. I can't forward the avi anymore. Actually I can forward it but when I forward in mplayer to any position, the sound begins from new. That means that I can't forward the sound, so it is out of sync.
    • Bevor
      Bevor over 13 years
      add: Obviously I don't have this weird problem in totem video player. An mplayer problem? Btw: Can you please post it as answer.
    • Bevor
      Bevor over 13 years
      add2: Obviously the -acodec copy makes something bad. Because when I just write ffmpeg -i ~/"$2.flv" -sameq ~/"$2.avi" is is possible to forward the movie and the audio stream will be forwarded too. But in this case the sound is very bad. So what could I do. -acodec copy produces a bad timecode, framestart or whatever, -acodec libmp3lame produces a worse audio quality and no attributes produces the worst sound quality.
    • Bevor
      Bevor over 13 years
      I made some tests with different flvs right now. When I use -acodec copy, the video runs 5 or 6 times faster than usual, only the sound is normal. So it is extremly out of sync. I wonder why this depends on copying the audio stream?
    • Pavan Kumar
      Pavan Kumar over 13 years
      @Bevor does mplayer complain about missing index or something while not allowing to seek in video? mplayer -idx [...] could fix that (before attempting something to repair the index of the avi stream). The other problems you talk about could be because the original flv stream ha audio encoded in some other format than mp3 (thus, -acodec copy is not a good thing). Can me point to one of the failing videos? i start wondering whether it's your ffmpeg installation that has problems.
    • Bevor
      Bevor over 13 years
      This is a good example: youtube.com/watch?v=9w1PYLJEpxk&feature=related. Download it with this script (if you have a working installation of youtube-dl installed) #!/bin/bash if [ $# -ge 2 ]; then echo "Downloading $1..." youtube-dl "$1" -o ~/"$2.flv" echo "Converting $1 to $2.avi..." ffmpeg -i ~/"$2.flv" -sameq -acodec libmp3lame -vol 150 -ar 44100 -aq 100 -ab 2097152 ~/"$2.avi" else echo "Usage: ytdownloader YOUTUBE-URL TARGET-FILENAME" fi The audio quality of the downloaded file is much worse.
  • Bevor
    Bevor over 13 years
    Thanks for your reply. I used ffmpeg -i ~/"$2.flv" -acodec libmp3lame -qscale 8 -ab 196608 ~/"$2.avi" now and it sounds almost as good as the original.