0

The shell script i'm trying to implement goes like this,

    #!/bin/bash
    while [ 1 ]
    do
       nc -l 1234 | ffmpeg -i pipe:0 -vcodec mpeg4 -s qcif -f m4v -y pipe:1 | nc localhost 1235
    done 

what it does is to simply take in a stream of video input through network and do live video transcoding(with ffmpeg of course!) and streaming back the video through the net. my question is how should i go by to implement this functionality in a clean C code. i know i can use popen() to pipe such a command from a c code but i would like to do better. may be with sockets and staff... any pointers are appreciated.

AskLearnDo.

4

1 回答 1

1

您的 shell 脚本运行良好,为什么还要浪费时间在 C 中重做它?您仍然需要使用 popen() 与 ffmpeg 子程序进行通信,除非您想弄清楚如何调用他们的库以实现等效功能(或重新实现 ffmpeg 转码,这超出了 SO 问题的范围)。

是的,您需要使用套接字- http://beej.us/guide/bgnet/几年前对我来说是一个很好的起点。

于 2011-08-20T23:27:01.513 回答