[FFmpeg-user] Does anyone have a working ffmpeg -> ffserver config for hls/m3u8?

Ricardo Kleemann ricardo at americasnet.com
Tue May 5 20:31:48 CEST 2015


I've been searching around the net found only a few examples but so far not
having much success.

My objective is to get a camera stream (available as input to ffmpeg as
m3u8) and feed it to ffserver, and play it out also as m3u8.

First, what I'm doing is simulating that by taking an mp4 file as input
instead.

Here's the info on the sample file:

~/bin/ffmpeg -i sample.mp4
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler


Here's my ffmpeg feed to ffserver.
~/bin/ffmpeg -re -i sample.mp4 -c copy -hls_time 10 -hls_list_size 6
-hls_wrap 18 -start_number 1 -override_ffserver
http://localhost:8090/feed1.ffm
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : now
    encoder         : Lavf56.31.100
    Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 424x240,
q=2-31, 420 kb/s, 24 fps, 24 tbr, 1000k tbn, 24 tbc (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, 99
kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)


Using username "ubuntu".
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue May  5 11:17:35 PDT 2015

  System load:  0.0               Processes:           120
  Usage of /:   39.1% of 7.74GB   Users logged in:     1
  Memory usage: 2%                IP address for eth0: 172.31.17.7
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

8 packages can be updated.
8 updates are security updates.


Last login: Tue May  5 11:17:36 2015 from 147.21.8.1
ubuntu at aws01:~$ cd video
ubuntu at aws01:~/video$ ~/bin/ffmpeg -i sample.mp4
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
At least one output file must be specified
ubuntu at aws01:~/video$ !links
links http://localhost:8090/stat.html
                                                      ffserver Status (p1
of 2)
                                ffserver Status

Available Streams

Path       Served       Format Bit     Video           Audio
Feed
           Conns  bytes        rate    kbits/s Codec   kbits/s Codec
                               kbits/s
live.m3u8       0                                              libfdk_aac
feed1.
stat.html       1   +------------ Exit Links -------------+
index.html      0   |                                     |
                    |  Do you really want to exit Links?  |
Feed feed1.ffm      |                                     |
                    |           [ Yes ]  [ No ]           |
    Stream  type    +-------------------------------------+
         0  video                                             4
         1  audio       99  libfdk_aac  2 channel(s), 48000 Hz

Connection Status

   Number of connections: 2 / 1000
   Bandwidth in use: 0k / 1000k

http://localhost:8090/live.m3u8























ubuntu at aws01:~/video$ links http://localhost:8090/stat.html
                                                      ffserver Status (p1
of 2)
                                ffserver Status

Available Streams

Path       Served       Format Bit     Video           Audio
Feed
           Conns  bytes        rate    kbits/s Codec   kbits/s Codec
                               kbits/s
live.m3u8       0     0  hls       464     420 libx264      99 libfdk_aac
feed1.
stat.html       2  1868   -          -       -               -
index.html      0     0   -          -       -               -

Feed feed1.ffm

    Stream  type   kbits/s  codec       Parameters
         0  video      420  libx264     424x240, q=2-31, fps=24
         1  audio       99  libfdk_aac  2 channel(s), 48000 Hz

Connection Status

   Number of connections: 2 / 1000
   Bandwidth in use: 0k / 1000k

http://localhost:8090/live.m3u8
Using username "ubuntu".
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue May  5 11:17:35 PDT 2015

  System load:  0.0               Processes:           120
  Usage of /:   39.1% of 7.74GB   Users logged in:     1
  Memory usage: 2%                IP address for eth0: 172.31.17.7
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

8 packages can be updated.
8 updates are security updates.


Last login: Tue May  5 11:17:36 2015 from 147.21.8.1
ubuntu at aws01:~$ cd video
ubuntu at aws01:~/video$ ~/bin/ffmpeg -i sample.mp4
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
At least one output file must be specified
ubuntu at aws01:~/video$ !links
links http://localhost:8090/stat.html
                                                      ffserver Status (p1
of 2)
                                ffserver Status

Available Streams

Path       Served       Format Bit     Video           Audio
Feed
           Conns  bytes        rate    kbits/s Codec   kbits/s Codec
                               kbits/s
live.m3u8       0                                              libfdk_aac
feed1.
stat.html       1   +------------ Exit Links -------------+
index.html      0   |                                     |
                    |  Do you really want to exit Links?  |
Feed feed1.ffm      |                                     |
                    |           [ Yes ]  [ No ]           |
    Stream  type    +-------------------------------------+
         0  video                                             4
         1  audio       99  libfdk_aac  2 channel(s), 48000 Hz

Connection Status

   Number of connections: 2 / 1000
   Bandwidth in use: 0k / 1000k

http://localhost:8090/live.m3u8























ubuntu at aws01:~/video$ links http://localhost:8090/stat.html
                                                      ffserver Status (p1
of 2)
                                ffserver Status

Available Streams

Path       Served       Format Bit     Video           Audio
Feed
           Conns  bytes        rate    kbits/s Codec   kbits/s Codec
                               kbits/s
live.m3u8       0     0  hls       464     420 libx264      99 libfdk_aac
feed1.
stat.html       2  1868   -          -       -               -
index.html      0     0   -          -       -               -

Feed feed1.ffm

    Stream  type   kbits/s  codec       Parameters
         0  video      420  libx264     424x240, q=2-31, fps=24
         1  audio       99  libfdk_aac  2 channel(s), 48000 Hz

Connection Status

   Number of connections: 2 / 1000
   Bandwidth in use: 0k / 1000k

http://localhost:8090/live.m3u8

Using username "ubuntu".
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue May  5 11:17:35 PDT 2015

  System load:  0.0               Processes:           120
  Usage of /:   39.1% of 7.74GB   Users logged in:     1
  Memory usage: 2%                IP address for eth0: 172.31.17.7
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

8 packages can be updated.
8 updates are security updates.


Last login: Tue May  5 11:17:36 2015 from 147.21.8.1
ubuntu at aws01:~$ cd video
ubuntu at aws01:~/video$ ~/bin/ffmpeg -i sample.mp4
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler


Using username "ubuntu".
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Tue May  5 11:17:35 PDT 2015

  System load:  0.0               Processes:           120
  Usage of /:   39.1% of 7.74GB   Users logged in:     1
  Memory usage: 2%                IP address for eth0: 172.31.17.7
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

8 packages can be updated.
8 updates are security updates.


Last login: Tue May  5 11:17:36 2015 from 147.21.8.1
ubuntu at aws01:~$ cd video
ubuntu at aws01:~/video$ ~/bin/ffmpeg -i sample.mp4
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_build
--pkg-config-flags=--static
--extra-cflags=-I/home/ubuntu/ffmpeg_build/include
--extra-ldflags=-L/home/ubuntu/ffmpeg_build/lib --bindir=/home/ubuntu/bin
--enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      54. 23.101 / 54. 23.101
  libavcodec     56. 35.101 / 56. 35.101
  libavformat    56. 31.100 / 56. 31.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.100 /  5. 16.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'sample.mp4':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf52.73.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 524 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 424x240, 420 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc
(default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler
      encoder         : libx264
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 99 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : DataHandler


Here's output of stat.html

ubuntu at aws01:~/video$ links http://localhost:8090/stat.html
                                                      ffserver Status (p1
of 2)
                                ffserver Status

Available Streams

Path       Served       Format Bit     Video           Audio
Feed
           Conns  bytes        rate    kbits/s Codec   kbits/s Codec
                               kbits/s
live.m3u8       0     0  hls       464     420 libx264      99 libfdk_aac
feed1.
stat.html       2  1868   -          -       -               -
index.html      0     0   -          -       -               -

Feed feed1.ffm

    Stream  type   kbits/s  codec       Parameters
         0  video      420  libx264     424x240, q=2-31, fps=24
         1  audio       99  libfdk_aac  2 channel(s), 48000 Hz

Connection Status

   Number of connections: 2 / 1000
   Bandwidth in use: 0k / 1000k


                                                      ffserver Status (p2
of 2)
# File             IP        Proto    State             Target   Actual
Bytes
                                                        bits/sec bits/sec
transf
1 stat.html        127.0.0.1 HTTP/1.1 HTTP_WAIT_REQUEST        0        0
2 feed1.ffm(input) 127.0.0.1 HTTP/1.1 RECEIVE_DATA          841k     653k

     ----------------------------------------------------------------------

   Generated at Tue May 5 11:20:51 2015


My ffserver config is very simple, since I'm trying to use the original
input and using override_ffserver.

<Stream live.m3u8>
Feed feed1.ffm
Format hls
</Stream>

Now when I try to access http://<ip addr>:8090/live.m3u8 I get a ton of
repeated errors on ffserver

Tue May  5 11:29:23 2015 [mpegts @ 0x3cdad60]AAC bitstream not in ADTS
format and extradata missing
Tue May  5 11:29:23 2015 Error writing frame to output for stream
'live.m3u8': Invalid data found when processing input
Tue May  5 11:29:23 2015 [mpegts @ 0x3cdad60]AAC bitstream not in ADTS
format and extradata missing
Tue May  5 11:29:23 2015 Error writing frame to output for stream
'live.m3u8': Invalid data found when processing input
Tue May  5 11:29:23 2015 [mpegts @ 0x3cdad60]H.264 bitstream error,
startcode missing, size 258 data 000000FE
Tue May  5 11:29:23 2015 [mpegts @ 0x3cdad60]AAC bitstream not in ADTS
format and extradata missing
Tue May  5 11:29:23 2015 Error writing frame to output for stream
'live.m3u8': Invalid data found when processing input
Tue May  5 11:29:23 2015 [mpegts @ 0x3cdad60]AAC bitstream not in ADTS
format and extradata missing
Tue May  5 11:29:23 2015 Error writing frame to output for stream
'live.m3u8': Invalid data found when processing input

I don't know if the fact that I'm using a file and attempting to stream
that as a simulation for live is the problem...? I haven't tried with the
real live stream from camera yet.

If anyone has gotten a working config to have ffserver stream hls, I'd
really appreciate the help

thanks
Ricardo


More information about the ffmpeg-user mailing list