[FFmpeg-devel] [PATCH] ffserver rtsp bug fixes

Howard Chu hyc
Wed May 19 07:27:28 CEST 2010


Howard Chu wrote:
> Howard Chu wrote:
>> Martin suggested I repost the explanations of each patch, so I'm doing this here.
>
>>> @@ -3872,6 +3878,15 @@
>>>        st->codec = avcodec_alloc_context();
>>>        stream->streams[stream->nb_streams++] = st;
>>>        memcpy(st->codec, av, sizeof(AVCodecContext));
>>> +    codec = avcodec_find_encoder(st->codec->codec_id);
>>> +    if (!codec) {
>>> +        http_log("Encoder (codec id %d) not found\n", st->codec->codec_id);
>>> +        exit(1);
>>> +    }
>>> +    if (avcodec_open(st->codec, codec)<   0) {
>>> +        http_log("Error opening encoder\n");
>>> +        exit(1);
>>> +    }
>>>    }
>>>
>>>    static enum CodecID opt_audio_codec(const char *arg)
>>
>> This was the first fix I posted. The codec must actually be opened/initialized
>> to give it a chance to set up its extradata when global headers are
>> configured. Otherwise the config option has no effect. Without this patch RTSP
>> always fails when trying to use AAC; you get the message "AAC with no global
>> headers is currently not supported."
>
> Found a better approach to this problem - ffmpeg actually gives ffserver the
> extradata that is needed, but ffserver was reading it into the feed stream and
> not pushing it down into the actual stream. With this set of patches it just
> uses the same codec structure for all streams that depend on the feed, so the
> info gets set properly in one place and is used by all the relevant streams.

Still seems a bit too kludgy. I'd like to have ffserver write the ffm header 
that it receives from ffmpeg back into the ffm file, because then the ffm file 
can be played back directly using ffplay. Otherwise, the ffm header that 
ffserver generates is still missing a bunch of header info that only gets 
populated when a codec is opened. If we just allow ffserver to do this, it 
will reject the ffm file on the next startup because its contents don't match 
ffserver's config (because ffserver's config is not fully initialized). I 
guess, as an alternative, I can just remove the offending check which depends 
on codec initialization (it looks like only the audio codec frame_size 
comparison is mismatched, ffserver has zero and an init'd AAC codec has 1024).
-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/



More information about the ffmpeg-devel mailing list