0

I know ffmpeg supports piping. I am trying to achieve what was described in this answer quoted below

If you are willing to accept a solution that does not truly stream the resulting frames, but does still adhere to your specification (read FLV from URL resource, output MP4 to stdout), you can always try to first encode the FLV to a temporary file and then output that to stdout.

Would I be able to achive this with ffmpeg via piping with something like this?

ffmpeg -i "%s" -c:v libx264 -c:a copy -f mp4 temp.mp4 | -

1 Answer 1

0

You're almost there. You already succeed in encoding your input file to an MP4 file named temp.mp4:

ffmpeg -i "%s" -c:v libx264 -c:a copy -f mp4 temp.mp4

To read the resulting file to stdout, once it's been fully written, you can use cat:

cat temp.mp4

To combine both, use the && operator (which makes the second command only execute when the first command succeeds):

ffmpeg -i "%s" -c:v libx264 -c:a copy -f mp4 temp.mp4 && cat temp.mp4

You can then pipe the output of this command to whatever program you like.

Note that in general this pattern (e.g. reading a file with cat solely to pipe it into another program) is frowned upon when the other program has native support for reading the respective file. Pass temp.mp4 as an input file to the consuming program whenever possible instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .