Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: FLAC to mono mp3/vorbis

  1. #1
    Join Date
    Jun 2007
    Beans
    14,793

    FLAC to mono mp3/vorbis

    I have a situation where I can only listen through one earbud of my mp3 player (Sansa Clip). Obviously, stereo files don't work well for that.

    So I have .flac files that I want to re-encode in mono lossy format (preferably vorbis, but mp3 works). I tried ffmpeg (2.2.1) to encode to vorbis mono, but the Clip played them with horrible static sound even though they played fine on my home stereo.

    This is the script I'm using (not worried about tags right now).
    Code:
    #!/bin/sh
    
    for f in *.flac; do
      # give output correct extension
      #OUTF="${a[@]/%flac/mp3}"
    
      # get the tags
      #ARTIST=$(metaflac "$f" --show-tag=ARTIST | sed s/.*=//g)
      #TITLE=$(metaflac "$f" --show-tag=TITLE | sed s/.*=//g)
      #ALBUM=$(metaflac "$f" --show-tag=ALBUM | sed s/.*=//g)
      flac -c -d "$f" | lame -m m --preset extreme --noreplaygain - "$f"mono.mp3
    done
    I'll update this more when I have time tonight. I just wanted to see if anyone has done something similar.

  2. #2
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FLAC to mono mp3/vorbis

    Please show your ffmpeg command and the complete ffmpeg console output.
    Does oggenc also produce static in the Sansa Clip?
    Is your script using lame working as expected?

  3. #3
    Join Date
    Jul 2009
    Location
    Hippiesoldierstan Norwich
    Beans
    2,326
    Distro
    Lubuntu 22.04 Jammy Jellyfish

    sox FLAC to mono mp3/vorbis

    or Temüjin you can use this

    for mp3

    Code:
    for f in *.flac; do sox "$f" -C 192 -c 1 "${f%.flac}.mp3" ;done

    -c for channel number -C for bitrate

    for ogg [-C here goes 1-10]

    Code:
    for f in *.flac; do sox "$f" -C 8 -c 1 "${f%.flac}.ogg" ;done


    if not yet installed sox


    sudo apt-get install sox libsox-fmt-all

    Last edited by shantiq; January 15th, 2014 at 05:56 PM.
    Linux is Latin for off-the-beaten-track
    what I like MOST about our Ubuntu ... The Community ie 50 brains are better than one
    Playing with Slackware too now ...
    ShanArt

  4. #4
    Join Date
    Jun 2007
    Beans
    14,793

    Re: FLAC to mono mp3/vorbis

    @Outdoorsman: thanks for the idea about oggenc. It was much simpler than ffmpeg because it preserves tags and automatically renames the file.
    Code:
    oggenc --downmix -q 5 file.flac
    I'm going to test the files on my mp3 player tonight. I'll let you know...

    @shantiq: I'll keep sox in mind for easier mp3 processing if the oggenc files play static too.

  5. #5
    Join Date
    Jun 2007
    Beans
    14,793

    Re: sox FLAC to mono mp3/vorbis

    Oh, and Outdoorsman, I was using a fairly simple ffmpeg command, something like:
    Code:
    ffmpeg -i file -c 2 -ac libvorbis file.ogg
    I don't have the exact error it kept spitting out, but for almost every file, it said something like: "stream 0:0 has 100 buffers waiting. Something may be wrong."

  6. #6
    Join Date
    Jun 2007
    Beans
    14,793

    Re: FLAC to mono mp3/vorbis

    Okay, so I just gave it a quick test and the oggenc files also play with static. I guess my Clip doesn't like mono vorbis files for some reason.. (stereo vorbis plays well).

  7. #7
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FLAC to mono mp3/vorbis

    Quote Originally Posted by Temüjin View Post
    @Outdoorsman: thanks for the idea about oggenc. It was much simpler than ffmpeg because it preserves tags and automatically renames the file.
    ffmpeg should preserve metadata (I'm not sure about the fake "ffmpeg" or avconv in the repository).

    Quote Originally Posted by Temüjin View Post
    Okay, so I just gave it a quick test and the oggenc files also play with static. I guess my Clip doesn't like mono vorbis files for some reason.. (stereo vorbis plays well).
    What version of Ubuntu are you using, or more specifically, what version of libvorbis are you using?

    Quote Originally Posted by Temüjin View Post
    Okay, so I just gave it a quick test and the oggenc files also play with static. I guess my Clip doesn't like mono vorbis files for some reason.. (stereo vorbis plays well).
    Another option would be to create a stereo file but with both channels in uhh... both channels. If that makes sense.

    Code:
    ffmpeg -i input -af "pan=stereo:c0<c0+c1:c1<c0+c1" -acodec libvorbis -qscale:a 4 -vcodec copy output.ogg
    Libav does not support the pan audio filter, so you'll have to use a real ffmpeg from FFmpeg (isn't it great that Ubuntu switched?). You can follow a step-by-step guide to compile ffmpeg or simply download a Linux build of ffmpeg. For the lazy/efficient:

    Code:
    wget http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.$(date +"%F").tar.gz
    tar xzvf ffmpeg.static.32bit.$(date +"%F").tar.gz
    ./ffmpeg -i input ...
    Last edited by FakeOutdoorsman; January 15th, 2014 at 07:41 PM.

  8. #8
    Join Date
    Jun 2007
    Beans
    14,793

    Re: FLAC to mono mp3/vorbis

    I'm actually using Debian sid(uction)
    ffmpeg (not libav) 2.1.2 (from debmultimedia repo)
    libvorbis 1.3.2-1.3
    vorbis-tools 1.4.0

    ffmpeg should preserve metadata
    Actually, I guess it did for the .oggs.
    It didn't autocomplete tags for mp3's, but I'll worry about tagging spcriptfu later. I just have the player shuffle through the whole library anyway (it's all upbeat working music and I don't have time to select specific artists/albums while I'm working).

  9. #9
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FLAC to mono mp3/vorbis

    Attached are a mono and a mixed stereo sample (from a friend's band) from ffmpeg using libvorbis 1.3.3. If the mono works maybe a bug was fixed in libvorbis (but I doubt libvorbis is at fault), but if not then I think it is safe to blame the Sansa Clip.
    Attached Files Attached Files
    Last edited by FakeOutdoorsman; January 15th, 2014 at 08:29 PM.

  10. #10
    Join Date
    Jun 2007
    Beans
    14,793

    Re: FLAC to mono mp3/vorbis

    Thanks for the samples! The clip played your mono file just fine. There have only been a few commits to libvorbis for 1.3.3 and I don't see anything that looks even remotely related to my issue.

    I'm thinking it may have something to do with my libflac? Investigation continues...

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •