使用FFMPEG将RTSP流录制到本地文件

问题描述 投票:0回答:3

我正在寻找一个片段(C/ObjC),其中使用最新版本的 FFMPEG 来捕获 RTSP 或 RTP 流并将其作为 .mp4 文件保存到设备上(带有开始/停止录音按钮)

几乎所有片段都已过时。我想使用 FFMPEG/Libav v3.2-v3.4

我使用 IJKPlayer 来显示流,效果很好,但不包含记录功能。

有什么建议吗?谢谢!

ios ffmpeg stream record libav
3个回答
1
投票

您可以从命令行使用 ffmpeg 调用。 FFmpeg 语法非常简单。

ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...

因此,如果您不需要重新编码或解码 RTPS 视频流,您只需运行:

ffmpeg -i rtsp://your_stream_url your_file_name.format

格式可以是 avi、mp4、flv 或其他格式,ffmpeg 会自动将流打包到输出文件。

更多信息请点击这里。

https://www.ffmpeg.org/ffmpeg.html


0
投票

我的演示: ffmpeg -i "rtsp://admin:[email protected]:554/h264/ch1/main/av_stream" -f 段-segment_time 5 %d.mp4


0
投票
ffmpeg -i rtsp://video.example.com:8554/path_to_stream -c copy outfile.mp4

看来魔法酱是

-c copy
。例如,如果我尝试在没有
-c copy
的情况下录制到 mp4,数据将写入磁盘,但尝试使用 ffplay 播放会导致错误:

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7faddc000cc0] moov atom not found0/0   
outfile.mp4: Invalid data found when processing input

这是与:

ffplay version 4.4.3 Copyright (c) 2003-2022 the FFmpeg developers

我从这个存储库注意到了这一点,并迭代到一个工作基本案例。

© www.soinside.com 2019 - 2024. All rights reserved.