开发者

possible C code implementation ideas for a given shell script(related to ffmpeg)

开发者 https://www.devze.com 2023-03-29 19:07 出处:网络
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

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 开发者_JAVA百科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.


Your shell script works fine, why would you bother wasting the time to redo it in C? You're still going to need to use popen() to communicate with a ffmpeg sub program unless you want to figure out how to call their library to achieve equivalent functionality (or reimplement the ffmpeg transcoding, which is beyond the scope of a SO question).

And yes you would need to use sockets - http://beej.us/guide/bgnet/ was a good starting point for me years ago.

0

精彩评论

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