使用mkfifo和传输流,这可能吗? [英] Working with mkfifo and transport streams, is this possible?

查看:74
本文介绍了使用mkfifo和传输流,这可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行一个bash脚本,该脚本将执行以下操作:

I want to execute a bash script that would do the following:

应用程序'ffmpeg'生成LIVE传输流(.ts)文件.我需要处理此实时条纹(执行多路分解等).

Application 'ffmpeg' generates a LIVE transport stream (.ts) file. I need to work on this live streaam (perform de-multiplexing, etc).

现在我知道这必须通过FIFO完成;但这是我的任务.

Now I know this has to be done via FIFOs; but here is my task.

我需要重定向ffmpeg的输出以写入到fifo,然后另一个应用程序将在该fifo内容上工作.这会持续实时进行,直到我按Ctrl + C为止.

I need to redirect the output of ffmpeg to write to a fifo, and then another application will work on that fifo contents. This happens continuously in real time until I press, say Ctrl+C.

这可能吗?我必须要做的是两个终端吗?

Is this possible? Will I have to do this is two terminals?

我基本上是为上述操作(以及更多操作)编写一个bash脚本,所以我必须调用两个终端,还是分叉?

I'm basically writing a bash script for the above operations (and more) so do I have to invoke two terminals, or maybe fork?

请告知.

提前谢谢!

推荐答案

FFmpeg不支持管道.您要做的所有事情都是这样的:

FFmpeg does support pipes. Everything you have to done is approach as follows:

  1. 结识朋友

  1. make a fifo

mkfifo first.ts  

  • 使用管道运行ffmpeg

  • run ffmpeg with pipe

    ffmpeg -i sample.ts -c copy -muxrate 5000000 pipe:1 > first.ts
    

  • 运行与传输流文件配合使用的任何其他工具,例如OpenCaster工具tscbrmuxer,可以添加例如NIT表传输流文件

  • run any other tools which work with transport stream files, e.g. OpenCaster tool tscbrmuxer which can add e.g. NIT table to transport stream file

    tscbrmuxer b:3008 NIT.ts b:5000000 first.ts > second.ts
    

  • 如果要停止使用2个工具,只需杀死最后一个使用pipe/fifo的工具即可.万一您必须杀死tscbrmuxer.

  • If you want to stop 2 tools simply kill the last one that uses pipe/fifo. in out case you have to kill tscbrmuxer.

    kill tscbrmuxer
    

    OR
    如果您没有在后台运行最后一个工具,只需使用[ctrl + c]

    OR
    If you are not running last tool in the background simply kill it with [ctrl+c]

    由于使用了这种方法(例如,作为shell脚本或Python),所有使用管道/fifo的工具都会由于管道损坏而终止.

    Thanks to using such an approach (e.g. as a shell script or Python one) all tools that uses pipe/fifo will be terminated due to broken pipe.

    我希望这会对您有所帮助.

    I hope this will help you.

    这篇关于使用mkfifo和传输流,这可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆