My goal is to use wget to download an flv file, and pipe the output to ffmpeg to convert it to an MP3. This way the user can download the MP3 without waiting for the FLV to download to my server first. I've been playing around with it, and it seems that ffmpeg can only do piping on raw video. So I was working with something like this:
wget -O - 'videoinput.flv' | ffmpeg -y -i - -vcodec rawvideo -f yuv4mpegpipe - | ffmpeg -y -i - -ab 128k audiooutput.mp3
Anybody have experience with this type of on-the-fly ffmpeg encoding process?
The accepted syntax is: pipe:[ number ] number is the number corresponding to the file descriptor of the pipe (e.g. 0 for stdin, 1 for stdout, 2 for stderr). If number is not specified, by default the stdout file descriptor will be used for writing, stdin for reading.
ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.
FFmpeg is a free software project that produces libraries and programs for handling and manipulating multimedia data. FFmpeg can handle the entire process of transcoding, video and image manipulation (resizing, denoising, etc.), packaging, streaming, and playback.
I haven't tested this but should be like this or very close.
wget [URL] | ffmpeg -i pipe:0 -vcodec mpeg4 -s qcif -f m4v -y output.flv
A potentially better option to piping from a separate HTTP client is to use ffmpeg's built-in one. At least newer versions can take a URL as an input file argument. This way FFmpeg can pull the file down itself, and for formats that have container data near the end of the file, it can (if the server supports it) grab that portion of the file first, unlike piping from curl or wget, which fetch the file sequentially. See http://ffmpeg.org/ffmpeg-all.html#http
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With