直接将ffmpeg输出到HDFS [英] Output of ffmpeg into HDFS directly

查看:299
本文介绍了直接将ffmpeg输出到HDFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我必须将RTSP流转换成mp4视频或帧(视情况而定)&要将其保存在HDFS(Hadoop文件系统)中。



为此,我尝试使用ffmpeg将RTSP流转换为mp4视频/帧&将视频/帧保存在本地文件系统中。如下 -

ffmpeg -i rtsp://10.0.37.150:8554 / big_bunny.mkv -r 1 -f image2 frames / big_frame-%3d.bmp

ffmpeg -i rtsp://10.0.37.150:8554 / big_bunny.mkv big_bunny.mp4



然后使用put命令将视频/帧(存储在本地文件系统中)保存到hdfs中

hadoop fs -put frames / / user / maddy /

hadoop fs -put big_bunny.mp4 / user / maddy /



这是工作。但是我想直接执行此操作(即在一步而不需要在本地文件系统中保存所需的文件)



我尝试了一些东西(如下面的命令),但它不工作

ffmpeg -i rtsp://10.0.37.150:8554 / big_bunny.mkv hdfs:// localhost:9000 / user / maddy / big_bunny.mp4



我收到这个错误 -

hdfs:// localhost:9000 / user / maddy / big_bunny.mp4:没有找到协议



所以有什么办法使用ffmpeg我可以直接将这些文件保存到hdfs中,而无需先保存我的本地文件系统。

还是有其他工具可以实现这一点?



编辑:



尝试 ffmpeg -i rtsp://10.0.37.150:8554 / big_bunny.mkv - | hadoop fs -put - / user / maddy /

由@incBrain建议



但收到此错误 - < br>
[NULL @ 0xce37a0]无法为'pipe:'找到合适的输出格式
pipe ::无效参数

解决方案

您可以将 ffmpeg 的输出重定向到管道,并使用 hadoop fs -put - / user /... to stdin 读取输入,如下所示:

  ffmpeg -i rtsp://10.0.37.150:8554 / test.mkv -f avi  -  | hadoop fs -put  -  /user/maddy/test.avi 

请注意,您将需要 -f< format> 选项,因为 ffmpeg 不能从文件扩展名中猜出输出格式,因为我们使用我们的管道。


I have a requirement in which I have to convert a RTSP stream into mp4 video or frames (as the case may be) & want to save them in HDFS (Hadoop Filesystem).

For this I have tried using ffmpeg to convert the RTSP stream into mp4 video/frames & saving the video/frames in local filesystem. Like below -
ffmpeg -i rtsp://10.0.37.150:8554/big_bunny.mkv -r 1 -f image2 frames/big_frame-%3d.bmp
ffmpeg -i rtsp://10.0.37.150:8554/big_bunny.mkv big_bunny.mp4

And then saving the video/frames (stored in local filesystem) into hdfs using put command -
hadoop fs -put frames/ /user/maddy/
hadoop fs -put big_bunny.mp4 /user/maddy/

This is working. But I want to do this directly (that is in one step without saving the required files in local filesystem)

I tried something (like below command) but it is not working
ffmpeg -i rtsp://10.0.37.150:8554/big_bunny.mkv hdfs://localhost:9000/user/maddy/big_bunny.mp4

I get this error -
hdfs://localhost:9000/user/maddy/big_bunny.mp4: Protocol not found

So is there any way in which using ffmpeg I can directly save these files into hdfs without first saving in my local filesystem.
Or is there any other tool through which I can achieve this?

EDIT :

Tried ffmpeg -i rtsp://10.0.37.150:8554/big_bunny.mkv - | hadoop fs -put - /user/maddy/
as suggested by @incBrain

But received this error -
[NULL @ 0xce37a0] Unable to find a suitable output format for 'pipe:' pipe:: Invalid argument

解决方案

You can redirect the output of ffmpeg to a pipe and use hadoop fs -put - /user/... to read the input from stdin like this:

ffmpeg -i rtsp://10.0.37.150:8554/test.mkv -f avi - | hadoop fs -put - /user/maddy/test.avi

Note that you will need -f <format> option since ffmpeg can not guess the output format from the file extension since we use our pipe.

这篇关于直接将ffmpeg输出到HDFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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