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

Thread: About Linux command line

  1. #1
    Join Date
    Apr 2006
    Beans
    3,937

    About Linux command line

    Hi all,

    I combine multiple .wav files and then convert the output.wav to mp3 running;
    Code:
    $ sox *.wav output.wav | ffmpeg -i output.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3
    It works but generating an output.wav file. Please advise how to modify the command line without generating an output.wav file ? I only need output.mp3

    Thanks

    Regards

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: About Linux command line

    You could try it this way, but I have no idea if it will work or not.

    Code:
    sox *.wav | ffmpeg -i pipe:0 -vn -ar 44100 -ac 2 -b:a 192k output.mp3
    https://ffmpeg.org/ffmpeg-protocols.html#pipe
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    Join Date
    Apr 2007
    Beans
    3,114
    Distro
    Ubuntu

    Re: About Linux command line

    Something strange is being done here. You use the pipe symbol, so any terminal output of sox would go to ffmpeg, which, in turn, will read from standard input. Probably not an issue because ffmeg does not need user interaction. This construct, however, makes ffmpeg read the output.wav before it has been finalized by the first command. Apparently, however, "it works". Did you listen to the output file?

    Use ";" instead, or perhaps better, "&&" which will cause the next command to proceed only when the first finished succesfully. That may already be enough to make ffmpeg encode as suggested by the extension of the output file.

  4. #4
    Join Date
    Jul 2007
    Location
    Tāmaki Makau-rau, NZ
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: About Linux command line

    Thread moved to General Help as it's a support question.
    BACKUPS are unsexy — until you discover you should have done one yesterday.
    Spare your nerves and do one before you upgrade or install.

  5. #5
    Join Date
    Apr 2006
    Beans
    3,937

    Re: About Linux command line

    Hi all,

    Thanks for your advice.

    Following command line works for me;
    Code:
    $ sox *.wav output.wav ; ffmpeg -i ouput.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3 ; rm output.wav
    Regards

  6. #6
    Join Date
    Apr 2006
    Beans
    3,937

    Re: About Linux command line

    Hi all,

    Thanks for your advice.

    Following command line works for me;
    Code:
    $ sox *.wav output.wav ; ffmpeg -i ouput.wav -vn -ar 44100 -ac 2 -b:a 192k output.mp3 ; rm output.wav
    Regards

  7. #7
    Join Date
    Dec 2006
    Beans
    7,349

    Re: About Linux command line

    Quote Originally Posted by satimis View Post
    Please advise how to modify the command line without generating an output.wav file ? I only need output.mp3
    This can be accomplished reasonably elegantly as follows:

    Code:
    sox *.wav -t wav - | lame -V 2 - output.mp3
    I am not sure about the file ordering of the sox command though, perhaps this is not an issue with your input files?
    Last edited by andrew.46; August 28th, 2021 at 10:52 AM.
    You think that's air you're breathing now?

  8. #8
    Join Date
    Apr 2006
    Beans
    3,937

    Re: About Linux command line

    Quote Originally Posted by andrew.46 View Post
    This can be accomplished reasonably elegantly as follows:

    Code:
    sox *.wav -t wav - | lame -V 2 - output.mp3
    I am not sure about the file ordering of the sox command though, perhaps this is not an issue with your input files?
    Hi,

    Thanks for you advice which works for me here without generating output.wav file.

    However I expect to learn how to fix file ordering.

    Example:
    File_1.wav File_2.wav File_3.wav File_4.wav File_5.wav File_6.wav
    File_7.wav File_8.wav File_9.wav File_10.wav File_11.wav File_12.wav etc.

    Can any folk on the forum help? Thanks

    Regards

  9. #9
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,827
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: About Linux command line

    The command line with *.wav uses shell globbing to get a list of filenames. The shell (bash) replaces the string *.wav with a list of all filenames in the current directory matching that pattern, alphabetically ordered, which is then passed to sox. And as 2 comes after 1, file_2.wav comes after file_10.wav. You can put all filenames on the command line yourself, in any order you like, but I think the easy solution is to rename the files so that those with lower numbers have a leading 0: file_01.wav ... file_09.wav file_10.wav etc.

    Alternatively, use shell string expansion. file_{1..15}.wav will expand to file_1.wav file_2.wav ... file_15.wav.

  10. #10
    Join Date
    Apr 2006
    Beans
    3,937

    Re: About Linux command line

    Quote Originally Posted by Impavidus View Post
    The command line with *.wav uses shell globbing to get a list of filenames. The shell (bash) replaces the string *.wav with a list of all filenames in the current directory matching that pattern, alphabetically ordered, which is then passed to sox. And as 2 comes after 1, file_2.wav comes after file_10.wav. You can put all filenames on the command line yourself, in any order you like, but I think the easy solution is to rename the files so that those with lower numbers have a leading 0: file_01.wav ... file_09.wav file_10.wav etc.

    Alternatively, use shell string expansion. file_{1..15}.wav will expand to file_1.wav file_2.wav ... file_15.wav.
    Thanks for your advice.

    Performed following tests

    $ ls
    Code:
    Track12.wav  Track3.wav  Track6.wav  Track9.wav
    Track10.wav            Track1.wav   Track4.wav  Track7.wav
    Track11.wav            Track2.wav   Track5.wav  Track8.wav
    1)
    $ sox 'file_{Track1 Track2 Track3 Track4 Track5 Track6 Track7 Track8 Track9 Track10 Track11 Track12}.wav' -t wav - | lame -V 2 - output.mp3
    Code:
    sox FAIL formats: can't open input file `file_{Track1 Track2 Track3 Track4 Track5 Track6 Track7 Track8 Track9 Track10 Track11 Track12}.wav': No such file or directory
    Warning: unsupported audio format
    Can't init infile '-'
    2)
    $ sox file_{Track1 Track2 Track3 Track4 Track5 Track6 Track7 Track8 Track9 Track10 Track11 Track12}.wav -t wav - | lame -V 2 - output.mp3
    Code:
    sox FAIL formats: can't open input file `Track12}.wav': No such file or directory
    Warning: unsupported audio format
    Can't init infile '-'
    3)
    $ sox Track_{1 2 3 4 5 6 7 8 9 10 11 12}.wav -t wav - | lame -V 2 - output.mp3
    Code:
    sox FAIL formats: can't open input file `12}.wav': No such file or directory
    Warning: unsupported audio format
    Can't init infile '-'
    Still fail

    Regards

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
  •