[FFmpeg-devel] [PATCH] Implement an option in ffmpeg to make it print the output SDP and exit

Stefano Sabatini stefano.sabatini-lala
Wed Jul 16 10:38:55 CEST 2008

On date Wednesday 2008-07-16 08:38:54 +0200, Luca Abeni encoded:
> Hi Stefano,
> Stefano Sabatini wrote:
> > Hi all,
> > 
> > this patch changes the current behavious of ffmpeg which currently
> > print if needed the SDP of the output streams.
> Michael is ffmpeg.c maintainer, but since I am the one who
> implemented SDP output I have some comments.
> First of all, thanks for the patch: I believe the "-sdp" option is
> needed (and I've been lazy not implementing it :).
> > This patch implements a behaviour which could result useful when
> > scripting things like this:
> > 
> > ffmpeg  -i ~/test.avi -vn -sdp -f rtp rtp://localhost:5004 > test.sdp
> > ffplay test.sdp
> > ffmpeg  -i ~/test.avi -vn -f rtp rtp://localhost:5004 > test.sdp
> > 
> > Since I think this is the assumed use for the SDP output then I think
> > this behaviour is preferable since it doesn't require the user to
> > invoke a transcoding just to print out the SDP.
> I generally use "-t 0.001" if I want to generate the SDP without actually
> streaming anything.
> > Note that this breaks compatibility with the previous behaviour, now
> > when ffmpeg is invoked without -sdp it won't print the SDP anymore.
> I think this is ok.
> > Also the SDP printed won't be prefixed by "SDP:\n" as before.
> I believe this is ok too.
> > Comments/suggestions are welcome as always.
> In my opinion, it would be more useful to have a "-sdp" option that
> prints the SDP without exiting (if the user wants ffmpeg to exit
> immediately after printing the SDP, he can use "-t 0.001").
> But I have no strong opinions about this: if other people think that
> "-sdp" should exit, I am ok with it.

What I want to achieve is to give the user the possibility to
understand if the SDP has been written, if for example the output
stream doesn't support an SDP (e.g. ffmpeg -i foo.mpeg -sdp foo.avi)
then ffmpeg should exit with an error code.

This is achievable also without to exit, the only problem is for
example when the outgoing stream *may* be described by an SDP but the
transcoding occurred in the firtst 0.01 seconds is broken and ffmpeg
exits with 1, in this case the user cannot distinguish the two cases.

If we still want to print the SDP even when transcoding (which is
reasonable), then we could for example make -sdp take a parameter:
0 = don't care about SDP,
1 = exit immediately after printing the SDP,
2 = print the SDP and go on with transcoding.

> Another small comments about your patch: since the SDP is now
> printed when "-sdp" is specified, maybe the want_sdp variable can
> be removed? Or, at least it can be merged with print_sdp_and_exit:
> make it global, set it to 0 by default (and set it to 1 when "-sdp"
> is used), and set it to 0 if the output format is != "rtp" (as
> currently done for want_sdp).

want_sdp is still needed to discern the case when the user asked to
print the SDP (do_print_sdp= 1) but the outgoing stream cannot be
described by an SDP (!want_sdp), which should issue an error in my

Thanks for the feedback, regards.
FFmpeg = Furious Freak Monstrous Problematic Educated Gadget

More information about the ffmpeg-devel mailing list