5

I want to use ffmpeg for transcoding RTP streaming to MP4(HTTP) streaming, so I can play in html video tag,

but I can only transcode to flv format successfully.

Below is my settings:

[/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>

[Commands]

$ ffserver -d -f /etc/ffserver.conf

$ ffmpeg -i MY_RTP_SOURCE  http://localhost:8090/feed1.ffm

[Other information]

  1. Input format

$ 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

  1. AVI error message when access (at 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

  1. MP4 error mesage when access (at 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
  1. My ffmpeg version
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

If anyone know how to solve it or need more information, please tell me, thanks!

Asoul
  • 996
  • 1
  • 10
  • 22

2 Answers2

3

I finally got the solution!

Use ffserver (transform rtp streaming to http) + videojs (play flv video in html)

My /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>

My Commands

ffserver

$ ffserver -d -f /etc/ffserver.conf

ffmpeg

$ ffmpeg -i rtp://MY_RTP_RESOURCE http://localhost:8090/feed1.ffm

My Demo page

<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>
Asoul
  • 996
  • 1
  • 10
  • 22
1

this may help you: FFMPEG - RTMP to HLS no audio output

you can work from here with your rtp input, check the segment options since what you need is a HLS output format

Community
  • 1
  • 1