{"id":163,"date":"2014-02-24T23:31:58","date_gmt":"2014-02-25T07:31:58","guid":{"rendered":"http:\/\/nramkumar.org\/tech\/?p=163"},"modified":"2014-02-24T23:31:58","modified_gmt":"2014-02-25T07:31:58","slug":"using-ffmpeg-to-convert-wma-to-mp3","status":"publish","type":"post","link":"https:\/\/nramkumar.org\/tech\/blog\/2014\/02\/24\/using-ffmpeg-to-convert-wma-to-mp3\/","title":{"rendered":"Using ffmpeg to convert WMA to MP3"},"content":{"rendered":"<p>As part of the reorganization of my home server, I am consolidating all my music files into the home server. I quickly realized that in a misguided fit of irrationality, I had gone through a phase in the past where most of my library was in the WMA format. The problem with WMA format is that not all non-Windows devices support it which meant transcoding. MP3 of course is the defacto standard for audio. I decided to convert all the WMA files in my collection to MP3. I wanted to do this on my Home Server itself that was hosting the collection so my regular machines weren&#8217;t occupied with the conversion and being kept awake. After searching a bit for tools that would help convert, I realized that the swiss knife of encoders ffmpeg could do what I wanted. I downloaded the static ffmpeg build from <a title=\"ffmpeg\" href=\"http:\/\/johnvansickle.com\/ffmpeg\/\" target=\"_blank\">here<\/a> and wrote this little script to do the conversion &#8211; the only tricky part was that ffmpeg reads from stdin.<\/p>\n<pre>find \"\/storage\/Music\" -name \"*.wma\" -exec \/bin\/bash -c '\r\nffmpeg=\/usr\/local\/bin\/ffmpeg\r\nfor file; do\r\n    dirname=$(dirname \"$file\")\r\n    filename=$(basename \"$file\")\r\n    filename=${filename%%.wma}\r\n    outfile=\"$dirname\/$filename.mp3\"\r\n    $ffmpeg -i \"$file\" -q:a 3 -y \"$outfile\" -- &lt; \/dev\/null\r\n    # You may want to remove the wma file here - I moved it to my boneyard\r\n    dirname=${dirname##\/storage\/Music\/}\r\n    outdirname=\"\/storage\/Boneyard\/Music\/$dirname\"\r\n    [ -d \"$outdirname\" ] || mkdir -p \"$outdirname\"\r\n    mv \"$file\" \"$outdirname\"\r\ndone\r\n' {} +<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As part of the reorganization of my home server, I am consolidating all my music files into the home server. I quickly realized that in a misguided fit of irrationality, I had gone through a phase in the past where most of my library was in the WMA format. The problem with WMA format is&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,41,6],"tags":[51,50,49,52,48],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-linux","category-nas","category-ubuntu","tag-bash","tag-ffmpeg","tag-mp3","tag-script","tag-wma"],"_links":{"self":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":1,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":164,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/163\/revisions\/164"}],"wp:attachment":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}