【发布时间】:2014-08-21 22:47:01
【问题描述】:
我想流式传输无穷无尽的实时视频数据,例如从我的 Ubuntu 机器的 网络摄像头 到 Android 客户端。因此,我使用 ffmpeg (2.2.git) 和 ffserver (2.2.git) 以使用 H.264 进行编码,包装成 mp4,最后通过 RTSP 流式传输。
我成功地流式传输(发送、接收和播放)文件,例如像这样配置ffmpeg:
ffmpeg -re -i input.mp4 \
-pix_fmt yuv420p \
-c:v libx264 -profile:v baseline -level 3.0 \
-c copy http://127.0.0.1:8888/feed1.ffm
然而,同样借助(1)、(2)、(3) 和其他文章,我无法成功流式传输'endless' 网络摄像头数据 - 更不用说任何与 Android 兼容的东西了。我们的想法是使用碎片化的 mp4。
当我尝试以下操作时:
ffmpeg -re -f v4l2 -video_size 1280x720 -i /dev/video0 \
-pix_fmt yuv420p \
-c:v libx264 -profile:v baseline -level 3.0 \
-f mp4 -movflags frag_keyframe+empty_moov \
-c copy http://127.0.0.1:8888/feed1.ffm
ffmpeg 显示错误:
[NULL @ 0x26b3ce0] [Eval @ 0x7fffa0738a20] Undefined constant or missing '(' in 'baseline'
[NULL @ 0x26b3ce0] Unable to parse option value "baseline"
[NULL @ 0x26b3ce0] Error setting option profile to value baseline.
[mp4 @ 0x26b2f20] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
[mp4 @ 0x26b2f20] Could not find tag for codec rawvideo in stream #0, codec not currently supported in container
有以下细微差别:
ffmpeg \
-re -f v4l2 -i /dev/video0 \
-pix_fmt yuv420p \
-c:v libx264 \
-f mp4 -movflags frag_keyframe+empty_moov http://127.0.0.1:8888/feed2.ts
ffmpeg 开始编码,但在大约 2 秒后停止,输出如下:
[libx264 @ 0x2549aa0] frame= 0 QP=23.20 NAL=3 Slice:I Poc:0 I:1200 P:0 SKIP:0 size=15471 bytes
它让 shell 崩溃。
我还尝试了上述配置的多种变体。 V4l2 工作正常。我假设是因为我可以从我的网络摄像头录制视频,例如。
我必须做什么才能流式传输网络摄像头数据?
编辑:我使用 H.264、H.264 的基线配置文件和 mp4 的组合,因为我知道 Android's compatibility。正如我所说,流式处理在与普通文件一起使用时效果很好。
【问题讨论】:
标签: android linux ffmpeg streaming mp4