[FFmpeg-devel] [PATCH] Add the frame size attribute to SDP descriptions

Luca Abeni lucabe72
Fri Jan 8 11:31:17 CET 2010

Martin Storsj? wrote:
>> 2) Not using c->{width,height}, but using the AVMetadata
>>    infrastructure... This might be a little bit more complex, but
>>    I believe it is more flexible, allowing the user to add more "a="
>>    lines if needed (without needing to modify sdp.c every time).
>>    My basic idea is that if the AVFormatContext contains a metadata
>>    tag with key "key" and value "value", then the "a=key:value" line
>>    is added to the SDP (the "title" metadata should be excluded
>>    because it is already used for the "s=" line).
> That would at least be the most general thing, leaving the choice to the 
> libavformat user. That'd also be good for adding the other 3gpp SDP 
> headers mentioned in the same document.

Yes, this is why I had this idea.

> However, if e.g. transcoding a stream with ffmpeg, where the input file 
> has some normal metadata, wouldn't these be copied into the SDP, resulting 
> in completely bogus SDP entries?

Right... I did not think about this problem...

> Should the AVMetadata entries to be added 
> to the SDP be tagged in some way, e.g. key = sdp:keyname, adding a 
> a=keyname:value in that case?

This looks a good solution to the problem, thanks!

> As for setting this particular attribute - it includes the payload type 
> number, which is set internally within the rtp muxer and sdp writer and 
> not available to the libavformat user setting the AVMetadata entries, so 
> setting it externally isn't too easy, if we don't make assumptions about 
> in which way libavformat assigns the payload type numbers.

Yes... I thought about this problem. Right now, libavformat is using
dynamic payload type 96 for video and 97 for audio (so, externally setting
this attribute should not be a problem), but this might change in the
I think the best solution would be to support some kind of "special keyword"
in the attribute value, which the SDP generator replaces with the payload
type. For example, something like "%PT 352-288" will generate "96 352-288"...

Anyway, this is becoming complex. If there is need for the "framesize"
attribute now, I can commit your patch with a comment... (hoping that
someone can provide the "correct patch" in a second time).
Let me know.

> Some other formats (such as AAC, H.264) add extradata to the SDP, so in 
> those cases, you can't change parameters later on in the stream anyway.

I do not know about AAC, but H.264 does not require "out-of-band config
informations". In other words "sprop-parameters-set" is not mandatory, and
you can encode H.264 video without using CODEC_FLAG_GLOBAL_HEADER. This
will place SPS and PPS inline in the video stream and will allow changing
the video resolution. I've been told that some DVB-H channels do this (for
commercials, or similar reasons).


More information about the ffmpeg-devel mailing list