The one problem with the other answer is that it is pcm_s16le, not s16le. Also, it includes a lot of redundant parameters.
I would use pcm instead of flac in the pipe, because it takes far less time to process (PCM is raw audio, FLAC takes lots of time to encode).
Anyway, here's how I would do it.
ffmpeg -i <input video file/stream> -vcodec rawvideo -acodec pcm_s16le pipe:1 | ffmpeg -f rawvideo -i - -vcodec <video output codec> -acodec <audio output codec> -vb <video bitrate if applicable> -ab <audio bitrate if applicable> <final-output-filename>
This worked for me when I last tried, but my goal was to pipe ffmpeg into ffplay, which is a slightly different process.
example:
This pipes a video from ffmpeg to another instance as raw video output and 16 bit little-endian PCM (both lossless unless you have 24 bit PCM, then substitute pcm_s24le
.) It then converts them to h.264 in the second instance, with the fraunhoefer AAC library from the Android project (libfaac
is more commonly included in ffmpeg builds. You can replace it with this instead.)
ffmpeg -i montypythonsflyingcircus-s1e1.avi -vcodec rawvideo -acodec pcm_s16le pipe:1 | ffmpeg -i - -vcodec libx264 -acodec libfdk_aac -vb 1200k -ab 96k mpfc-s1e01-output.mkv
If this doesn't pipe the subtitles, you can always rip them to SRT's and then mux them back in later, or add them to the pipes above easily.