Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use piping with ffmpeg?

Tags:

ffmpeg

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?

like image 659
DiglettPotato Avatar asked Dec 29 '10 18:12

DiglettPotato


People also ask

What is pipe in FFmpeg?

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.

What does FFmpeg use?

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.

What is FFmpeg process?

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.


2 Answers

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
like image 142
Ted Avatar answered Sep 22 '22 06:09

Ted


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

like image 45
user371366 Avatar answered Sep 19 '22 06:09

user371366