我正在使用ffprobe来获取RTSP流中的所有参数,如比特率,fps等。
我正在使用Porcelain.exec
来执行命令。命令有效但Porcelain
给出空输出,但是终端显示命令在输出中有参数。
这是代码:
Porcelain.exec("ffprobe", ["rtsp://90.101.245.146:9201/h264/ch1/main/av_stream"]).out
它给输出空字符串但终端显示以下命令输出。
Metadata:
title: Media Presentation
Duration: N/A, start: 0.239978, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709), 1920x1080, 25 fps, 25.25 tbr, 90k tbn, 50 tbc
对此有何解决方案?
答案 0 :(得分:1)
ffprobe
将该数据打印到stderr,默认情况下Porcelain.exec
不会捕获stderr
的输出。使用Porcelain的Basic
驱动程序,您可以将stderr重定向到标准输出,然后阅读.out
:
Porcelain.exec("ffprobe", ["rtsp://90.101.245.146:9201/h264/ch1/main/av_stream"], [err: :out]).out
使用Porcelain的Goon
驱动程序,您可以执行更高级的操作,例如重定向到流或文件。您可以在docs for Porcelain.exec/3。