Title ffserver looses control of ffm
Type bug
Priority normal Status new new
Superseder Nosy List
Depends On
Assigned To Topics ffserver

Created on 2009-12-15.16:07:57 by kirk, last changed 2009-12-20.04:38:25 by kirk.

Please provide full uncut output from "ffmpeg -i" if you are reporting issues with unplayable files.
Messages
msg8328 (view) Author: kirk Date: 2009-12-15.16:07:57
hi,

i've deployed ffserver to stream some inputs from a card which outputs  h264
video, with mulaw audio,
i've packed the stream into mpegts, and i send it to ffserver using:
-----------
#!/bin/bash
IA="-aframes 25 -ar 16000 -f mulaw -i audio.dat -ab 128k -acodec mp2"
IV=" -i video.h264"

ffmpeg   $IV $IA -vcodec copy  -f mpegts  -|
  ffmpeg -i - -vcodec copy -acodec copy http://localhost:8090/feed1.ffm
-----------
my ffserver's config file:
-----------
Port 8090
BindAddress 0.0.0.0
RTSPPort 5454
MaxHTTPConnections 2000
MaxClients 100
MaxBandwidth 1000000
CustomLog -
NoDaemon
<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 5000K
ACL allow 127.0.0.1
</Feed>
<Stream test1.avi>
Feed feed1.ffm
Format mpegts
AudioChannels 1
VideoBufferSize 40
VideoBitRate 4000
AudioBitRate 128
VideoFrameRate 25
VideoSize 720x576
VideoGopSize 12
AVOptionVideo flags +global_header
VideoCodec libx264
Preroll 600
</Stream>
<Stream stat.html>
Format status
ACL allow localhost
</Stream>
<Redirect index.html>
URL stat.html
</Redirect>
-----------

starting up the streaming is ok.
but after feed1.ffm reaches the  FileMaxSize limit new clients can't connect to
the server and ffserver outputs:

Tue Dec 15 16:58:43 2009 [ffm @ 0x1017ad0]invalid stream index 240
Tue Dec 15 16:58:45 2009 [ffm @ 0x1017ad0]invalid stream index 255
Tue Dec 15 16:58:45 2009 [ffm @ 0x1017ad0]invalid stream index 4

for me: it looks like that ffserver wasn't able to keep track of the old data in
the ffm file, and it starts reading at a bad position

version/etc:
FFmpeg version SVN-r20761, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  built on Dec 15 2009 12:39:00 with gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
  configuration: --enable-libx264 --enable-gpl --enable-version3
  libavutil     50. 5. 1 / 50. 5. 1
  libavcodec    52.42. 0 / 52.42. 0
  libavformat   52.41. 0 / 52.41. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libswscale     0. 7. 2 /  0. 7. 2


-------output of the piped feed command
[h264 @ 0xff73c0]max_analyze_duration reached
[h264 @ 0xff73c0]Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1)
-> 25.00 (50/2)
Input #0, h264, from 'video.h264':
  Duration: N/A, bitrate: N/A
    Stream #0.0: Video: h264, yuv420p, 720x576, 25 tbr, 1200k tbn, 50 tbc
[mulaw @ 0x11f19d0]Estimating duration from bitrate, this may be inaccurate
Input #1, mulaw, from 'audio.dat':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #1.0: Audio: pcm_mulaw, 16000 Hz, 1 channels, s16, 128 kb/s
Output #0, mpegts, to 'pipe:':
    Stream #0.0: Video: libx264, yuv420p, 720x576, q=2-31, 90k tbn, 25 tbc
    Stream #0.1: Audio: mp2, 16000 Hz, 1 channels, s16, 128 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press [q] to stop encoding
[mpegts @ 0x1008b30]dts < pcr, TS is invalid
[mpegts @ 0xff73c0]max_analyze_duration reached
[mpegts @ 0xff73c0]Estimating duration from bitrate, this may be inaccurate

Seems stream 0 codec frame rate differs from container frame rate: 50.00 (50/1)
-> 25.00 (25/1)
Input #0, mpegts, from 'pipe:':
  Duration: N/A, start: 0.700000, bitrate: 128 kb/s
  Program 1 Service01
    Stream #0.0[0x100]: Video: h264, yuv420p, 720x576, 25 tbr, 90k tbn, 50 tbc
    Stream #0.1[0x101]: Audio: mp2, 16000 Hz, 1 channels, s16, 128 kb/s
Output #0, ffm, to 'http://localhost:8090/feed1.ffm':
    Stream #0.0: Audio: mp2, 16000 Hz, 1 channels, 128 kb/s
    Stream #0.1: Video: libx264, yuv420p, 720x576, q=3-31, 1000k tbn, 25 tbc
Stream mapping:
  Stream #0.1 -> #0.0
  Stream #0.0 -> #0.1
frame=  311 fps= 42 q=-1.0 size=    4632kB time=12.24 bitrate=3100.1kbits/s         



note: i done the ffserver feeding in two pass because it wasn't worked by giving
the whole thing in one command, the input should be mpegts for the feed uploader
msg8345 (view) Author: kirk Date: 2009-12-16.01:17:39
i think i finally understand the problem:
on data reception, ffserver writes the frame into the 'ffm' file, which is
opened by newcomer clients and seeked to the appropriate frame.

the problem i'm facing is when the 'ffm' file is corrupt and and 'av_read_frame'
wasn't able to get a packet out of it.

...my question is: i think that if i could be able to detect keyframes at the
time i they written into the ffm file, and by not taking the MaxFileSize
limitation so seriously, the key frame could be sneaked into position ;)
History
Date User Action Args
2009-12-20 04:38:25kirksetmessages: - msg8439
2009-12-20 04:38:12kirksettopic: + ffserver
messages: + msg8439
2009-12-16 02:00:07kirksetmessages: - msg8343
2009-12-16 01:59:09kirksetmessages: - msg8330
2009-12-16 01:17:39kirksetmessages: + msg8345
2009-12-15 21:36:38kirksetmessages: + msg8343
2009-12-15 16:20:03kirksetmessages: + msg8330
2009-12-15 16:07:57kirkcreate