开发者

using pipes to channel file i/o to another process

Just started learning/using pipes and was wondering how to route file output of an application into a pipe so that another application can use it.

To be exact, I want to pipe ffmpeg's output (transcoded video data) into my application to use it. If I create a named pipe like /tmp/out.mp4 and give it to ffmpeg as output filename, ffmpeg is going to try to create this file again, probably overwriting my pipe (Or something like that). How to deal with this kind of situation?

is there any general way to divert File IO of an application transparently?

(I am trying to write a video streaming server 开发者_运维百科(Just for learning and fun) which transcodes formats like avi into streaming friendly format like mpeg4 during streaming, I found ffmpeg to be too slow for this purpose, it was taking like 2 secs to transcode 1 sec video :(

Is it the problem with my setup/PC or ffmpeg is known for sluggishness? )

PS : I am writing this in C by the way.


ffmpeg can be persuaded to output to a pipe:

ffmpeg -i whatever.avi -f mp4 -

The "-" tells it to output to stdout instead of to a file, and the "-f" tells it what output the output file should be.

You could redirect that to a named pipe, of course, but calling it with popen to get the output as a file descriptor directly seems the way to go to me.


ffmpeg can also read from stdin and write to stdout like this:

ffmpeg -i pipe:0 -f wav pipe:1

where 0 and 1 are the standard POSIX file descriptors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜