ffmpeg 将 rtp 转换为 mp4(http) 流
ffmpeg convert rtp to mp4(http) streaming
我想使用 ffmpeg 将 RTP 流媒体转码为 MP4(HTTP) 流媒体,这样我就可以在 html 视频标签中播放,
但是我只能成功转码成flv格式
以下是我的设置:
[/etc/ffserver.conf]
...
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 5M
ACL allow localhost
</Feed>
<Stream flv>
Feed feed1.ffm
Format flv
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
<Stream mp4>
Feed feed1.ffm
Format mp4
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
<Stream avi>
Feed feed1.ffm
Format avi
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
[命令]
$ ffserver -d -f /etc/ffserver.conf
$ ffmpeg -i MY_RTP_SOURCE http://localhost:8090/feed1.ffm
[其他信息]
- 输入格式
$ ffprobe -i MY_RTP_SOURCE
Input #0, rtp, from 'MY_RTP_SOURCE':
Duration: N/A, start: 47175.696200, bitrate: N/A
Program 1
Stream #0:1: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080, 25 tbr, 90k tbn
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 255 kb/s
- 访问时出现 AVI 错误消息(在 ffserver)
Wed Feb 17 17:09:16 2016 127.0.0.1 - - New connection: GET /avi
Wed Feb 17 17:09:16 2016 [avi @ 0x7fac8b800150]Too large number of skipped frames 873420092564 > 60000
Wed Feb 17 17:09:16 2016 Error writing frame to output for stream 'avi': Invalid argument
Wed Feb 17 17:09:16 2016 [avi @ 0x7fac8b800150]Too large number of skipped frames 873420092564 > 60000
Wed Feb 17 17:09:16 2016 127.0.0.1 - - [GET] "/avi HTTP/1.1" 200 2598
- 访问时出现 MP4 错误消息(在 ffserver)
Wed Feb 17 17:09:56 2016 127.0.0.1 - - New connection: GET /mp4
Wed Feb 17 17:09:56 2016 [mp4 @ 0x7fac8c000150]muxer does not support non seekable output
Wed Feb 17 17:09:56 2016 Error writing output header for stream 'mp4': Invalid argument
Wed Feb 17 17:09:56 2016 127.0.0.1 - - [GET] "/mp4 HTTP/1.1" 200 62
- 我的ffmpeg版本
ffmpeg version 2.8.6 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
如果有人知道如何解决或需要更多信息,请告诉我,谢谢!
这可能对您有帮助:FFMPEG - RTMP to HLS no audio output
您可以从这里使用您的 rtp 输入,检查段选项,因为您需要的是 HLS 输出格式
终于找到答案了!
使用ffserver(将rtp流转为http)+videojs(播放flv视频html)
我的/etc/ffserver.conf
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 40000
CustomLog -
UseDefaults
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 50M
</Feed>
<Stream stream>
Feed feed1.ffm
Format flv
VideoFrameRate 24
VideoBitRate 32768
VideoSize 1280x720
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 1
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
我的命令
ff服务器
$ ffserver -d -f /etc/ffserver.conf
ffmpeg
$ ffmpeg -i rtp://MY_RTP_RESOURCE http://localhost:8090/feed1.ffm
我的演示页面
<head>
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
</head>
<body>
<video id="video1" class="video-js vjs-default-skin" width="640" height="360"
data-setup='{"controls" : true, "autoplay" : true, "preload" : "auto"}'>
<source src="http://10.10.3.108:8090/stream" type="video/x-flv">
</video>
</body>
我想使用 ffmpeg 将 RTP 流媒体转码为 MP4(HTTP) 流媒体,这样我就可以在 html 视频标签中播放,
但是我只能成功转码成flv格式
以下是我的设置:
[/etc/ffserver.conf]
...
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 5M
ACL allow localhost
</Feed>
<Stream flv>
Feed feed1.ffm
Format flv
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
<Stream mp4>
Feed feed1.ffm
Format mp4
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
<Stream avi>
Feed feed1.ffm
Format avi
VideoFrameRate 40
VideoBitRate 128
VideoSize 1920x1080
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
[命令]
$ ffserver -d -f /etc/ffserver.conf
$ ffmpeg -i MY_RTP_SOURCE http://localhost:8090/feed1.ffm
[其他信息]
- 输入格式
$ ffprobe -i MY_RTP_SOURCE Input #0, rtp, from 'MY_RTP_SOURCE': Duration: N/A, start: 47175.696200, bitrate: N/A Program 1 Stream #0:1: Video: h264 (High) (HDMV / 0x564D4448), yuv420p, 1920x1080, 25 tbr, 90k tbn Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp, 255 kb/s
- 访问时出现 AVI 错误消息(在 ffserver)
Wed Feb 17 17:09:16 2016 127.0.0.1 - - New connection: GET /avi Wed Feb 17 17:09:16 2016 [avi @ 0x7fac8b800150]Too large number of skipped frames 873420092564 > 60000 Wed Feb 17 17:09:16 2016 Error writing frame to output for stream 'avi': Invalid argument Wed Feb 17 17:09:16 2016 [avi @ 0x7fac8b800150]Too large number of skipped frames 873420092564 > 60000 Wed Feb 17 17:09:16 2016 127.0.0.1 - - [GET] "/avi HTTP/1.1" 200 2598
- 访问时出现 MP4 错误消息(在 ffserver)
Wed Feb 17 17:09:56 2016 127.0.0.1 - - New connection: GET /mp4 Wed Feb 17 17:09:56 2016 [mp4 @ 0x7fac8c000150]muxer does not support non seekable output Wed Feb 17 17:09:56 2016 Error writing output header for stream 'mp4': Invalid argument Wed Feb 17 17:09:56 2016 127.0.0.1 - - [GET] "/mp4 HTTP/1.1" 200 62
- 我的ffmpeg版本
ffmpeg version 2.8.6 Copyright (c) 2000-2016 the FFmpeg developers built with Apple LLVM version 7.0.2 (clang-700.1.81) configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100
如果有人知道如何解决或需要更多信息,请告诉我,谢谢!
这可能对您有帮助:FFMPEG - RTMP to HLS no audio output
您可以从这里使用您的 rtp 输入,检查段选项,因为您需要的是 HLS 输出格式
终于找到答案了!
使用ffserver(将rtp流转为http)+videojs(播放flv视频html)
我的/etc/ffserver.conf
HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 40000
CustomLog -
UseDefaults
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 50M
</Feed>
<Stream stream>
Feed feed1.ffm
Format flv
VideoFrameRate 24
VideoBitRate 32768
VideoSize 1280x720
AVOptionVideo flags +global_header
AudioBitRate 24
AudioChannels 1
AudioSampleRate 44100
AVOptionAudio flags +global_header
</Stream>
我的命令
ff服务器
$ ffserver -d -f /etc/ffserver.conf
ffmpeg
$ ffmpeg -i rtp://MY_RTP_RESOURCE http://localhost:8090/feed1.ffm
我的演示页面
<head>
<link href="http://vjs.zencdn.net/c/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/c/video.js"></script>
</head>
<body>
<video id="video1" class="video-js vjs-default-skin" width="640" height="360"
data-setup='{"controls" : true, "autoplay" : true, "preload" : "auto"}'>
<source src="http://10.10.3.108:8090/stream" type="video/x-flv">
</video>
</body>