InfoHeap
Tech tutorials, tips, tools and more
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

ffmpeg tutorials

  • Command line - scale a video using ffmpeg
  • Convert mp3 to ogg on Mac using ffmpeg
  • Install ffmpeg on Ubuntu Linux
  • Mac - how to convert mp4 to webm
 
  • Home
  • > Tutorials
  • > Linux/Unix Command Line
  • > ffmpeg

Convert mp3 to ogg on Mac using ffmpeg

By admin on Sep 25, 2015

Sometimes we need to convert mp3 files to ogg files. Ogg is an open format and produces fairly small size files. Here are the instructions to use ffmpeg on Mac to convert mp3 files to ogg format files.

Install ffmpeg on Mac

We’ll use brew to install ffmpeg on mac:

$ brew install ffmpeg

In case you get error with brew link lame you may have to use the following:

$ brew link --overwrite lame

Convert mp3 to ogg

Use the following command to convert foo.mp3 to foo.ogg

$ ffmpeg -y -i foo.mp3  -strict -2 -acodec vorbis -ac 2 -aq 50 foo.ogg

Batch convert multiple mp3 files to ogg

In case you want to convert multiple mp3 files present in a directory, you can use the following bash script. Save the following code to file convert_m3_to_ogg.sh

#!/bin/bash
for i in *.mp3; do
  j=$(echo -n $i | sed -e 's/.mp3/.ogg/g')
  echo "converting $i  to  $j"
  ffmpeg -y -i "$i"  -strict -2 -acodec vorbis -ac 2 -aq 50 "$j"
done

Now cd to the desired directory run the following:

$ chmod a+x ./convert_m3_to_ogg.sh
$ ./convert_m3_to_ogg.sh

This will create one .ogg file for each .mp3 file in same directory. Make sure you take a backup of your directory before running the script to be on safer side.

Suggested posts:

  1. Mac – how to convert mp4 to webm
  2. Install ffmpeg on Ubuntu Linux
  3. Bulk convert jpeg files to png using sips on mac
  4. Command line – scale a video using ffmpeg
  5. Iterate over specific file extension in a dir in shell script
  6. How to install Imagemagick on Mac
  7. How to crop an image using imagemagick convert
  8. ReactJS – convert jsx to javascript using babel cli
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged ffmpeg, Linux/Unix Command Line, Mac, Tutorials

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries

Copyright © 2023 InfoHeap.

Powered by WordPress