首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ffserver通过RTSP从MP4文件流传输

使用ffserver通过RTSP从MP4文件流传输
EN

Stack Overflow用户
提问于 2012-10-19 03:34:53
回答 2查看 13.1K关注 0票数 5

我正在尝试使用ffserver在RTSP上流式传输一个mp4文件,到目前为止还没有成功。我只想直接从文件流,而不是从ffmpeg馈送(不涉及转码)。但我已经让它在mpg视频上工作了。

下面是我的ffserver配置文件:

代码语言:javascript
复制
Port 8090
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 500000
CustomLog -
NoDaemon

RTSPPort 7654
RTSPBindAddress 0.0.0.0

<Stream test1-rtsp>
    Format rtp
    File "/home/g/video_streaming/sample3-mpeg2.mpg"
</Stream>
<Stream test2-rtsp>
    Format rtp
    File "/home/g/video.mp4"
</Stream>

当我启动ffserver时,根据日志输出,一切似乎都很正常:

代码语言:javascript
复制
$ ./dev/ffmpeg/ffserver -f ffserver-sample.conf
ffserver version N-45673-gd0c27e8 Copyright (c) 2000-2012 the FFmpeg developers
  built on Oct 18 2012 10:36:52 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration:
  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 33.100 / 54. 33.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.103 /  3. 19.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
Thu Oct 18 11:54:22 2012 Opening file '/home/g/video.mp4'
Thu Oct 18 11:54:22 2012 Opening file '/home/g/video.mp4'
Thu Oct 18 11:54:23 2012 Opening file '/home/g/video_streaming/sample3-mpeg2.mpg'
Thu Oct 18 11:54:23 2012 [mpeg @ 0x1dae3c0]max_analyze_duration 5000000 reached at 5005000
Thu Oct 18 11:54:23 2012 Opening file '/home/g/video_streaming/sample3-mpeg2.mpg'
Thu Oct 18 11:54:23 2012 [mpeg @ 0x1dae3c0]max_analyze_duration 5000000 reached at 5005000
Thu Oct 18 11:54:23 2012 FFserver started.

最后,如果我运行ffplay来测试服务器,对于mpg文件来说一切正常,但对于mp4却不是这样:

代码语言:javascript
复制
$ ffplay rtsp://192.168.1.99:7654/test2-rtsp
ffplay version N-45656-g916352f Copyright (c) 2003-2012 the FFmpeg developers
  built on Oct 17 2012 16:14:14 with gcc 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5.1)
  configuration:
  libavutil      51. 76.100 / 51. 76.100
  libavcodec     54. 66.100 / 54. 66.100
  libavformat    54. 33.100 / 54. 33.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 19.103 /  3. 19.103
  libswscale      2.  1.101 /  2.  1.101
  libswresample   0. 16.100 /  0. 16.100
rtsp://192.168.1.99:7654/test2-rtsp: Invalid data found when processing input

Server's output:

Thu Oct 18 11:57:51 2012 FFserver started.
Thu Oct 18 11:58:01 2012 192.168.1.101 - - [DESCRIBE] "rtsp://192.168.1.99:7654/test2-rtsp RTSP/1.0" 200 167
Segmentation fault (core dumped)

我真的不知道我会错过什么。我刚刚在in the official doc上读到,从文件流传输是一种破坏。因为我不知道这是不是最新的,所以我决定在这里试一试。

有什么帮助或建议吗?替代方案?

EN

回答 2

Stack Overflow用户

发布于 2012-10-21 23:20:12

如果您正在寻找替代方案,live555 (http://www.live555.com/ )和darwin服务器是不错的选择。我已经使用了它们,并且在从文件流传输时表现良好。

在上述情况下,您甚至可以通过分析核心转储来尝试调试。通过查看日志,我认为服务器甚至在收到播放命令之前就已经崩溃了。所以这可能是某处的一个小问题

票数 1
EN

Stack Overflow用户

发布于 2016-10-18 22:09:41

仅仅4年后的...

您不能使用FFserver流式传输mp4视频,因为它在文件头中包含全局元数据-这使得随机流访问变得不可能。

可能的替代方案:

代码语言:javascript
复制
// convert awesome.mp4 to awesome.flv

$ ffmpeg -i awesome.mp4 -c:v libx264 -ar 22050 -crf 28 awesome.flv 

有关FFmpeg的更多信息...转到blog

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12962358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档