我使用以下命令使用 ffmpeg 创建了一个流:
ffmpeg -re -thread_queue_size 4 -i video.mp4 -strict -2 -vcodec copy -an -f rtp rtp://127.0.0.1:51372 -sdp_file test.sdp
这会在通过 RTP 流式传输本地视频文件时创建一个 .sdp 文件。
SDP 文件:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=Serenity - HD DVD Trailer
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.29.100
m=video 51372 RTP/AVP 96
b=AS:4674
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QAKaw05QFAFuhAAZdOwExLQCPGDEWA,aO68sA==; profile-level-id=640029
现在我想使用另一个 ffmpeg 实例来记录这个流并保存到一个文件中(假设它是网络中的另一台机器)。
我尝试了以下命令,但它给出了错误。
ffmpeg -i test.sdp -c copy -flags +global_header -f segment -segment_time 60 -protocol_whitelist file,udp,rtp -segment_format_options movflags=+faststart -reset_timestamps 1 test.mp4
错误:
Protocol 'rtp' not on whitelist 'file,crypto'!
custom.sdp: Invalid data found when processing input
最佳答案
您可以尝试添加 -protocol_whitelist file,crypto,udp,rtp
.我不确定在哪里放置这些参数,但 ffmpeg 似乎依赖于这些东西。
问候
约阿希姆
关于ffmpeg - 使用 SDP 文件和 ffmpeg 录制流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58834147/