4

Somewhat related to this question: Convert audio files to mp3 using ffmpeg

I want to execute a command in one line using piping in BASH.

What I am trying to do is this:

echo "Hello" | somecommand | ffmpeg -i _____ -f mp2 output.mp3 

Where the _____ is the output of somecommand. Is there any way to achieve this?

1
  • ffmpeg supports libflite which can make audio from text files. Commented Sep 11, 2015 at 14:35

2 Answers 2

9

Try using xargs

echo "Hello" | somecommand | xargs ffmpeg -f mp2 output.mp3 -i

or

echo "Hello" | somecommand | xargs -i ffmpeg -i {} -f mp2 output.mp3
Sign up to request clarification or add additional context in comments.

2 Comments

xargs -i is my new best friend!
xargs -i is deprecated, use xargs -I{}
4

You can use command substitution here in the middle argument:

ffmpeg -i "$(echo 'Hello' | somecommand)" -f mp2 output.mp3 

8 Comments

somecommand actually represents the text2wave function, so how would I get the output .wav file from that and pass it into ffmpeg?
Yes same line syntax is what I've shown. It will be: ffmpeg -i "$(echo 'Hello' | text2wave)" -f mp2 output.mp3
I get an error saying "file name too long" When I run that in terminal. In order to actually save to a .wav file, it has to be done like this: text2wave -o file.wav
Does text2wave writes output on terminal that you want to use in ffmpeg command?
no, text2wave creates an output wav file that I want to use in ffmpeg
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.