Search code examples
linuxbashdialogmp3

Getting the output from LAME and FLAC to show in bash dialog


I'm writing a .ogg and .flac to .mp3 converter in dialog (ncurses) and I wonder if it's possible to get the output from flac and ogg123 to be shown inside of dialog? Right now I have a good interface, but when the converting starts it just prints to terminal.

This is the flac2mp3 function right now:

   function ConvertFromFlac {
       old_IFS=$IFS             
       IFS=$'\n'                
       for line in `cat ./flacsongs`        
       do
           flac -cd "$line" | lame -h - "$line.mp3" 
       done
       IFS=$old_IFS                 
   }

Solution

  • Try it this way

    ConvertFromFlac() {
        pipe=/tmp/$$.err
        mkfifo "$pipe"
        while IFS= read -r line ; do 
        do
            flac -cd "$line" 2>>"$pipe" | lame -h - "$line.mp3" 2>>"$pipe"
        done < ./flacsongs
    }
    

    And later if you want the output just read from $pipe. Don't forget to rm it when you're done.