我想使用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
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
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 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
如果有人知道如何解决或需要更多信息,请告诉我,谢谢!
答案 0 :(得分:1)
我终于得到了解决方案!
使用ffserver(将rtp流转换为http)+ videojs(以html播放flv视频)
/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>
$ ffserver -d -f /etc/ffserver.conf
$ 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>
答案 1 :(得分:0)
这可能会对您有所帮助:FFMPEG - RTMP to HLS no audio output
您可以使用rtp输入从这里开始工作,检查分段选项,因为您需要的是HLS输出格式