[PATCH] Implement an option in ffmpeg to make it print the output SDP and exit
Hi all, this patch changes the current behavious of ffmpeg which currently print if needed the SDP of the output streams. 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. Note that this breaks compatibility with the previous behaviour, now when ffmpeg is invoked without -sdp it won't print the SDP anymore. Also the SDP printed won't be prefixed by "SDP:\n" as before. Comments/suggestions are welcome as always. Regards. -- FFmpeg = Furious & Friendly Martial Proud Elitarian God
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. 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). Luca
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 opinion. Thanks for the feedback, regards. -- FFmpeg = Furious Freak Monstrous Problematic Educated Gadget
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Concerning the gods, I have no means of knowing whether they exist or not or of what sort they may be, because of the obscurity of the subject, and the brevity of human life -- Protagoras
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file. But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0. So can anyone explain why it is necessary to set t > 0?, attached patch is a first naive attempt to fix the t>0 issue. Regards. -- FFmpeg = Foolish and Frenzy Multipurpose Programmable Erudite God
On Thu, Jul 17, 2008 at 08:57:09PM +0200, Stefano Sabatini wrote:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
grep . file
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
So can anyone explain why it is necessary to set t > 0?, attached patch is a first naive attempt to fix the t>0 issue.
what is t by default? what will you patch do in that case? ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB it is not once nor twice but times without number that the same ideas make their appearance in the world. -- Aristotle
On date Thursday 2008-07-17 22:18:08 +0200, Michael Niedermayer encoded:
On Thu, Jul 17, 2008 at 08:57:09PM +0200, Stefano Sabatini wrote: [...]
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
So can anyone explain why it is necessary to set t > 0?, attached patch is a first naive attempt to fix the t>0 issue.
what is t by default? what will you patch do in that case? ...
Yes, anyway if the user writes: ffmpeg -t 0 -i test.avi -y test.mpeg then I think he expects to transcode *nothing* rather than the whole file, this also according to the docs: @item -t @var{duration} Restrict the transcoded/captured video sequence to the duration specified in seconds. @code{hh:mm:ss[.xxx]} syntax is also supported. New patch attached, this also doesn't break the default behaviour when -t isn't specified. Regards. -- FFmpeg = Friendly Fostering Magic Prodigious Empowered Guru
On Fri, Jul 18, 2008 at 12:27:33AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 22:18:08 +0200, Michael Niedermayer encoded:
On Thu, Jul 17, 2008 at 08:57:09PM +0200, Stefano Sabatini wrote: [...]
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
So can anyone explain why it is necessary to set t > 0?, attached patch is a first naive attempt to fix the t>0 issue.
what is t by default? what will you patch do in that case? ...
Yes, anyway if the user writes: ffmpeg -t 0 -i test.avi -y test.mpeg
then I think he expects to transcode *nothing* rather than the whole file, this also according to the docs:
@item -t @var{duration} Restrict the transcoded/captured video sequence to the duration specified in seconds. @code{hh:mm:ss[.xxx]} syntax is also supported.
New patch attached, this also doesn't break the default behaviour when -t isn't specified.
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire
On date Friday 2008-07-18 01:58:27 +0200, Michael Niedermayer encoded:
On Fri, Jul 18, 2008 at 12:27:33AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 22:18:08 +0200, Michael Niedermayer encoded:
On Thu, Jul 17, 2008 at 08:57:09PM +0200, Stefano Sabatini wrote: [...]
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
So can anyone explain why it is necessary to set t > 0?, attached patch is a first naive attempt to fix the t>0 issue.
what is t by default? what will you patch do in that case? ...
Yes, anyway if the user writes: ffmpeg -t 0 -i test.avi -y test.mpeg
then I think he expects to transcode *nothing* rather than the whole file, this also according to the docs:
@item -t @var{duration} Restrict the transcoded/captured video sequence to the duration specified in seconds. @code{hh:mm:ss[.xxx]} syntax is also supported.
New patch attached, this also doesn't break the default behaviour when -t isn't specified.
ok
Committed. -- FFmpeg = Fast and Fiendish Mega Problematic Elitarian Game
On date Thursday 2008-07-17 20:57:09 +0200, Stefano Sabatini encoded:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
Now that this is implemented here it is the patch. Behaviour: stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -sdp -i ~/test.flv -f rtp rtp://localhost:5008 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 c=IN IP4 localhost m=audio 5008 RTP/AVP 0 b=AS:64 stefano at geppetto ~/s/ffmpeg> ffmpeg -t 1 -sdp -i ~/test.flv -f rtp rtp://localhost:5008 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 c=IN IP4 localhost m=audio 5008 RTP/AVP 0 b=AS:64 stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -sdp -i ~/test.flv -f avi rtp://localhost:5008 FFmpeg version SVN-r14284, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: --prefix=/home/stefano --disable-shared --enable-libschroedinger --enable-libx264 --enable-pthreads --enable-gpl --enable-debug=3 --enable-libtheora --enable-libvorbis --enable-avfilter --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libfaad --enable-libfaac --enable-x11grab --enable-libmp3lame --disable-optimizations --disable-mmx libavutil version: 49.7.0 libavcodec version: 51.60.0 libavformat version: 52.17.0 libavdevice version: 52.0.0 libavfilter version: 0.0.0 built on Jul 19 2008 00:06:02, gcc: 4.2.3 20071014 (prerelease) (Debian 4.2.2-3) Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1) Input #0, flv, from '/home/stefano/test.flv': Duration: 00:00:30.01, start: 0.000000, bitrate: 96 kb/s Stream #0.0: Video: vp6f, yuv420p, 320x240, 25.00 tb(r) Stream #0.1: Audio: mp3, 44100 Hz, mono, 96 kb/s Output #0, avi, to 'rtp://localhost:5008': Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 25.00 tb(c) Stream #0.1: Audio: mp2, 44100 Hz, mono, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Output cannot be described by an SDP My only doubt is now about the behaviour when the output stream cannot be described by an SDP, I think the best solution is to exit with an error code as soon as possible, in this way the user can check the return code, slighly simpler than to check for the emptiness of the output file. Regards. -- FFmpeg = Free and Fiendish Mastering Pitiless Erotic Gem
On Sat, Jul 19, 2008 at 12:49:41AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 20:57:09 +0200, Stefano Sabatini encoded:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
Now that this is implemented here it is the patch.
after a few seconds of thinking .. i think sdp should be a muxer that outputs a file containing that stuff that is printed to stdout. Much cleaner and needs no changes to ffmpeg.c [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Complexity theory is the science of finding the exact solution to an approximation. Benchmarking OTOH is finding an approximation of the exact
On date Saturday 2008-07-19 20:35:40 +0200, Michael Niedermayer encoded:
On Sat, Jul 19, 2008 at 12:49:41AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 20:57:09 +0200, Stefano Sabatini encoded:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
Now that this is implemented here it is the patch.
after a few seconds of thinking .. i think sdp should be a muxer that outputs a file containing that stuff that is printed to stdout. Much cleaner and needs no changes to ffmpeg.c
Very nice idea, I'll try to implement it. Regards. -- FFmpeg = Freak Funny Mind-dumbing Patchable EnGraver
On date Sunday 2008-07-20 01:27:03 +0200, Stefano Sabatini encoded:
On date Saturday 2008-07-19 20:35:40 +0200, Michael Niedermayer encoded:
On Sat, Jul 19, 2008 at 12:49:41AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 20:57:09 +0200, Stefano Sabatini encoded:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote:
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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
Now that this is implemented here it is the patch.
after a few seconds of thinking .. i think sdp should be a muxer that outputs a file containing that stuff that is printed to stdout. Much cleaner and needs no changes to ffmpeg.c
Very nice idea, I'll try to implement it.
On the other hand I'm not sure it is possible to implement an SDP muxer. Indeed the SDP issued by ffmpeg has to know *all* the RTP output streams: stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -i ~/test.flv -sdp -f rtp rtp://localhost:5008 -f rtp -acodec libmp3lame rtp://localhost:5004 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 m=audio 5008 RTP/AVP 0 c=IN IP4 localhost b=AS:64 m=audio 5004 RTP/AVP 14 c=IN IP4 localhost b=AS:64 so it's not possible to write a muxer, because this for definition only knows one output file. Any idea? Otherwise I propose to implement the already proposed -sdp option. Regards. -- FFmpeg = Faboulous and Friendly Mega Purposeless Eccentric Genius
On Tue, Jul 22, 2008 at 01:49:02AM +0200, Stefano Sabatini wrote:
On date Sunday 2008-07-20 01:27:03 +0200, Stefano Sabatini encoded:
On date Saturday 2008-07-19 20:35:40 +0200, Michael Niedermayer encoded:
On Sat, Jul 19, 2008 at 12:49:41AM +0200, Stefano Sabatini wrote:
On date Thursday 2008-07-17 20:57:09 +0200, Stefano Sabatini encoded:
On date Wednesday 2008-07-16 18:46:50 +0200, Michael Niedermayer encoded:
On Wed, Jul 16, 2008 at 10:38:55AM +0200, Stefano Sabatini wrote: > 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.
What would -sdp output on stdout in case of an error? if nothing then this should be enough to distinguish it.
What I want to avoid is to require the user to perform that check, simply performing a check on the return code is way simpler, I couldn't even take out from the top of my head a simple way to check for the emptiness of a file.
But if we can avoid *at all* to transcode then I'm fine, ideally a: ffmpeg -t 0 -i test.avi -sdp -f rtp -an rtp://test.mpeg > test.sdp
should be fine, if *no* transcoding is performed then the return code tells if we wrote that SDP or not, which isn't guaranteed if we have to set t > 0.
Now that this is implemented here it is the patch.
after a few seconds of thinking .. i think sdp should be a muxer that outputs a file containing that stuff that is printed to stdout. Much cleaner and needs no changes to ffmpeg.c
Very nice idea, I'll try to implement it.
On the other hand I'm not sure it is possible to implement an SDP muxer. Indeed the SDP issued by ffmpeg has to know *all* the RTP output streams:
stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -i ~/test.flv -sdp -f rtp rtp://localhost:5008 -f rtp -acodec libmp3lame rtp://localhost:5004 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 m=audio 5008 RTP/AVP 0 c=IN IP4 localhost b=AS:64 m=audio 5004 RTP/AVP 14 c=IN IP4 localhost b=AS:64
so it's not possible to write a muxer, because this for definition only knows one output file.
Any idea? Otherwise I propose to implement the already proposed -sdp option.
make rtp support multiple streams something like: -f rtp rtp://localhost:5008,localhost:5004 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire
On date Tuesday 2008-07-22 02:25:37 +0200, Michael Niedermayer encoded:
On Tue, Jul 22, 2008 at 01:49:02AM +0200, Stefano Sabatini wrote: [...]
Ehm, sorry for the slow reply...
On the other hand I'm not sure it is possible to implement an SDP muxer. Indeed the SDP issued by ffmpeg has to know *all* the RTP output streams:
stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -i ~/test.flv -sdp -f rtp rtp://localhost:5008 -f rtp -acodec libmp3lame rtp://localhost:5004 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 m=audio 5008 RTP/AVP 0 c=IN IP4 localhost b=AS:64 m=audio 5004 RTP/AVP 14 c=IN IP4 localhost b=AS:64
so it's not possible to write a muxer, because this for definition only knows one output file.
Any idea? Otherwise I propose to implement the already proposed -sdp option.
make rtp support multiple streams
something like: -f rtp rtp://localhost:5008,localhost:5004
So what about something like this: ffmpeg -i audio1.mp2 -i audio2.vorbis -acodec pcm_mulaw -acodec libmp3lame -f rtp rtp://localhost:5004,localhost:5008 -newaudio ? In order to print the sdp we could do something like: ffmpeg -i audio1.mp2 -i audio2.vorbis -acodec pcm_mulaw -acodec libmp3lame -f sdp rtp://localhost:5004,localhost:5008 -newaudio The problem with this approach is that we can't specify the SDP output. Maybe a better solution could be: ffmpeg -dest localhost:5004 -i audio1.mp2 \ -dest localhost:5008 -i audio2.ogg \ -acodec pcm_mulaw -acodec libmp3lame \ -f sdp test.sdp -newaudio which would need another field (for example "dest") in AVCodecContext. Ideas are very welcome. Regards. -- FFmpeg = Faboulous & Frightening Mega Proud Energized Game
On date Wednesday 2008-11-12 00:01:14 +0100, Stefano Sabatini encoded:
On date Tuesday 2008-07-22 02:25:37 +0200, Michael Niedermayer encoded:
On Tue, Jul 22, 2008 at 01:49:02AM +0200, Stefano Sabatini wrote: [...]
Ehm, sorry for the slow reply...
On the other hand I'm not sure it is possible to implement an SDP muxer. Indeed the SDP issued by ffmpeg has to know *all* the RTP output streams:
stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -i ~/test.flv -sdp -f rtp rtp://localhost:5008 -f rtp -acodec libmp3lame rtp://localhost:5004 2> /dev/null v=0 o=- 0 0 IN IPV4 127.0.0.1 t=0 0 s=No Name a=tool:libavformat 52.17.0 m=audio 5008 RTP/AVP 0 c=IN IP4 localhost b=AS:64 m=audio 5004 RTP/AVP 14 c=IN IP4 localhost b=AS:64
so it's not possible to write a muxer, because this for definition only knows one output file.
Any idea? Otherwise I propose to implement the already proposed -sdp option.
make rtp support multiple streams
something like: -f rtp rtp://localhost:5008,localhost:5004
So what about something like this: ffmpeg -i audio1.mp2 -i audio2.vorbis -acodec pcm_mulaw -acodec libmp3lame -f rtp rtp://localhost:5004,localhost:5008 -newaudio ?
In order to print the sdp we could do something like: ffmpeg -i audio1.mp2 -i audio2.vorbis -acodec pcm_mulaw -acodec libmp3lame -f sdp rtp://localhost:5004,localhost:5008 -newaudio
The problem with this approach is that we can't specify the SDP output.
Maybe a better solution could be: ffmpeg -dest localhost:5004 -i audio1.mp2 \ -dest localhost:5008 -i audio2.ogg \ -acodec pcm_mulaw -acodec libmp3lame \ -f sdp test.sdp -newaudio
which would need another field (for example "dest") in AVCodecContext.
Forget about this last one, the syntax is wrong and I think it is better to use the filename string to express that anyway, something like -f sdp rtp://localhost:5004,localhost:5008/test.sdp but I need to think more about it.
Ideas are very welcome.
Regards. -- FFmpeg = Fiendish & Frenzy Maxi Portable Energized God
On 13-11-2008 9:05, Stefano Sabatini wrote:
Forget about this last one, the syntax is wrong and I think it is better to use the filename string to express that anyway, something like -f sdp rtp://localhost:5004,localhost:5008/test.sdp but I need to think more about it.
I'd try an approach similar to map -map_sdp output_stream_id:sdp_filename -map_sdp 0:en.sdp -map_sdp 1:en.sdp -map_sdp 0:fr.sdp -map_sdp 2:fr.sdp This way you get en.sdp and fr.sdp sharing the video stream 0 and using their language specific audio stream 1 and 2. lu
Hi, Luca Barbato wrote:
On 13-11-2008 9:05, Stefano Sabatini wrote:
Forget about this last one, the syntax is wrong and I think it is better to use the filename string to express that anyway, something like -f sdp rtp://localhost:5004,localhost:5008/test.sdp but I need to think more about it.
I'd try an approach similar to map
-map_sdp output_stream_id:sdp_filename
-map_sdp 0:en.sdp -map_sdp 1:en.sdp -map_sdp 0:fr.sdp -map_sdp 2:fr.sdp
This way you get en.sdp and fr.sdp sharing the video stream 0 and using their language specific audio stream 1 and 2.
Yes, I like this solution. Anyway, whatever solution is chosen the important thing is not to break the current libavformat API (avf_sdp_create(), and the way rtp:// URLs are specified). Luca
On date Thursday 2008-11-13 16:48:15 +0100, Luca Abeni encoded:
Hi,
Luca Barbato wrote:
On 13-11-2008 9:05, Stefano Sabatini wrote:
Forget about this last one, the syntax is wrong and I think it is better to use the filename string to express that anyway, something like -f sdp rtp://localhost:5004,localhost:5008/test.sdp but I need to think more about it.
I'd try an approach similar to map
-map_sdp output_stream_id:sdp_filename
-map_sdp 0:en.sdp -map_sdp 1:en.sdp -map_sdp 0:fr.sdp -map_sdp 2:fr.sdp
This way you get en.sdp and fr.sdp sharing the video stream 0 and using their language specific audio stream 1 and 2.
Yes, I like this solution.
I like it too, but I introduced a variant so that the syntax is: -map_sdp output_stream_index:output_sdp_stream_index So the previous example becomes: -map_sdp 0:0 -map_sdp 1:0 -map_sdp 0:1 -map_sdp -2:1 en.sdp fr.sdp A complete example: ffmpeg -i audio-en.mp3 -i audio-fr.ogg -i video.mpeg \ test.flv \ # output stream 1 -acodec pcm_mulaw rtp:/localhost:5004 \ # output stream 2, en -acodec libmp3lame rtp:/localhost:5008 \ # output stream 3, fr -vcodec h263 rtp:/localhost:5010 \ # output stream 4 -title "A/V multistream en" -f sdp en.sdp -map_sdp 2:5 -map_sdp 4:5 # output stream 5 -title "A/V multistream fr" -f sdp fr.sdp -map_sdp 3:6 -map_sdp 4:6 # output stream 6 This is functionally equivalent, slightly less verbose in case of long SDP files names and easier/cleaner to implement.
Anyway, whatever solution is chosen the important thing is not to break the current libavformat API (avf_sdp_create(), and the way rtp:// URLs are specified).
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files. (Still no patch ready, stay tuned...). Regards. -- FFmpeg = Fiendish Frenzy Merciless Purposeless Everlasting Gymnast
Hi, Stefano Sabatini wrote: [...]
Anyway, whatever solution is chosen the important thing is not to break the current libavformat API (avf_sdp_create(), and the way rtp:// URLs are specified).
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files.
Ok, good. Note that avf_sdp_create() should already be able to do what you need (you just need to prepare a proper "AVFormatContext *ac[]" before calling it). So, I guess everything you need is a new muxer which sets up the "ac" array and calls avf_sdp_create(). Luca
On date Monday 2008-11-17 10:00:49 +0100, Luca Abeni encoded:
Hi,
Stefano Sabatini wrote: [...]
Anyway, whatever solution is chosen the important thing is not to break the current libavformat API (avf_sdp_create(), and the way rtp:// URLs are specified).
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files.
Ok, good. Note that avf_sdp_create() should already be able to do what you need (you just need to prepare a proper "AVFormatContext *ac[]" before calling it). So, I guess everything you need is a new muxer which sets up the "ac" array and calls avf_sdp_create().
The problem with avf_sdp_create() is that it takes AVOutputFormat, while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header. So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files. I'm attaching my implementation, but I'm somehow not satisfied with it). Patch consists of the part (I'll split it when we'll agree on some solution for the problem I'm going to discuss): * cosmetics to sdp.c: struct sdp_session_level -> SDPContext and other renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header) * implement SDP muxer write_header() function and structure * implement av_dup_stream() in lavf * implement ffmpeg.c support to SDP mapping Usage example: stefano at geppetto ~/s/ffmpeg> ffmpeg -t 0 -i test.flv -acodec libmp3lame -f rtp rtp://localhost:5004 -acodec pcm_mulaw -ar 8000 -f rtp rtp://localhost:5008 -title "test SDP" -f sdp - -map_sdp 0:2 -map_sdp 1:2 FFmpeg version SVN-r15884, Copyright (c) 2000-2008 Fabrice Bellard, et al. [...] Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1) Input #0, flv, from 'test.flv': Duration: 00:00:30.03, start: 0.000000, bitrate: 64 kb/s Stream #0.0: Video: flv, yuv420p, 320x240, 25.00 tb(r) Stream #0.1: Audio: mp3, 44100 Hz, mono, s16, 64 kb/s Output #0, rtp, to 'rtp://localhost:5004': Stream #0.0: Audio: libmp3lame, 44100 Hz, mono, s16, 64 kb/s Output #1, rtp, to 'rtp://localhost:5008': Stream #1.0: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s Output #2, sdp, to 'pipe:': Stream #2.0: Audio: libmp3lame, 44100 Hz, mono, s16, 64 kb/s Stream #2.1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s Stream mapping: Stream #0.1 -> #0.0 Stream #0.1 -> #1.0 SDP file mapping Output file #0 -> #2 Output file #1 -> #2 v=0 o=- 0 0 IN IP4 127.0.0.1 t=0 0 s=test SDP a=tool:libavformat 52.23.1 m=audio 5004 RTP/AVP 14 c=IN IP4 localhost b=AS:64 m=audio 5008 RTP/AVP 0 c=IN IP4 localhost b=AS:64 Press [q] to stop encoding size= 0kB time=0.05 bitrate= 4.3kbits/s video:0kB audio:0kB global headers:0kB muxing overhead -93.285372% The use of av_dup_stream() is necessary for the "special" status of the SDP muxer, which takes streams which have been already defined. For this reason I'm duplicating the output stream which is mapped to the SDP, alternative solution, consisting into simply copy the already defined stream in the SDP muxer simply isn't valid (crashes or double free problems): if ((st = rtp_ctx->streams[0])) { // duplicate st and put the duplicated stream in sdp_ctx if (!(st2 = av_dup_stream(sdp_ctx, sdp_ctx->nb_streams, st))) { fprintf(stderr, "Could not alloc stream\n"); av_exit(1); } // copy file filename in the stream, used to extract later // the output port st2->filename = strdup(rtp_ctx->filename); } also since the destination port for the RTP stream/SDP description is extracted from the filename, I'm copying in the stream the filename of the corresponding file so that I can access it later when calling write_header() in the SDP muxer. av_dup_stream() is also very similar to av_new_stream(), so I'm aware they could be factorized, I didn't do it because I don't like so much this solution, and I hope that someone has some better idea. Regards. -- FFmpeg = Fantastic and Forgiving Merciful Patchable Epic Gospel
Hi Stefano, Stefano Sabatini wrote: [...]
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files. Ok, good. Note that avf_sdp_create() should already be able to do what you need (you just need to prepare a proper "AVFormatContext *ac[]" before calling it). So, I guess everything you need is a new muxer which sets up the "ac" array and calls avf_sdp_create().
The problem with avf_sdp_create() is that it takes AVOutputFormat,
What is the exact problem with this?
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header.
Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files.
I suspect this will result in some code duplication; you should not do it. What you should do is to write a write_header() function that prepares an array of AVFormatContexts for avf_sdp_create(), and then calls it.
I'm attaching my implementation, but I'm somehow not satisfied with it).
Patch consists of the part (I'll split it when we'll agree on some solution for the problem I'm going to discuss):
* cosmetics to sdp.c: struct sdp_session_level -> SDPContext and other
What's the point of this change? Note that it is wrong: sdp_session_level is not a generic "SDP context", but it contains the session-level description of an SDP.
renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media
Sorry, but again I do not see the point in this change.
sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header)
Idem. Sorry, but I'll not approve this kind of changes.
The use of av_dup_stream() is necessary for the "special" status of the SDP muxer, which takes streams which have been already defined.
I am not sure about it; let's see Michael's comments. Luca
On date Thursday 2008-11-20 08:22:50 +0100, Luca Abeni encoded:
Hi Stefano,
Stefano Sabatini wrote: [...]
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files. Ok, good. Note that avf_sdp_create() should already be able to do what you need (you just need to prepare a proper "AVFormatContext *ac[]" before calling it). So, I guess everything you need is a new muxer which sets up the "ac" array and calls avf_sdp_create().
The problem with avf_sdp_create() is that it takes AVOutputFormat,
What is the exact problem with this?
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header.
Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files.
I suspect this will result in some code duplication; you should not do it. What you should do is to write a write_header() function that prepares an array of AVFormatContexts for avf_sdp_create(), and then calls it.
Yes, this can be factorized.
I'm attaching my implementation, but I'm somehow not satisfied with it).
Patch consists of the part (I'll split it when we'll agree on some solution for the problem I'm going to discuss):
* cosmetics to sdp.c: struct sdp_session_level -> SDPContext and other
What's the point of this change? Note that it is wrong: sdp_session_level is not a generic "SDP context", but it contains the session-level description of an SDP.
What about an SDPContext having sdp_session_level as a field?
renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media
Sorry, but again I do not see the point in this change.
sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header)
Idem. Sorry, but I'll not approve this kind of changes.
I think they make sense, but I won't insist on them. sdp_write_header() may be confused with the muxer write_header() function, also I think it is more clear to call it write_sdp_header since what it does is to write the SDP header, same for the other function. Compare this list: sdp_write_header() sdp_write_media() sdp_media_attributes() with: write_sdp_header() write_sdp_media() write_sdp_media_attributes() I think the second list is better, but again I won't waste our time on this if you prefer the other way.
The use of av_dup_stream() is necessary for the "special" status of the SDP muxer, which takes streams which have been already defined.
I am not sure about it; let's see Michael's comments.
Thanks for the review, regards. -- FFmpeg = Fiendish and Freak Magical Prodigious Eretic Gadget
On date Thursday 2008-11-20 10:05:41 +0100, Stefano Sabatini encoded:
On date Thursday 2008-11-20 08:22:50 +0100, Luca Abeni encoded:
Hi Stefano,
Stefano Sabatini wrote: [...]
Yes, this solution won't break neither URLs syntax neither old API interface, while on the other hand I'm extending the interface, in order to create a representation of an SDP from a list of RTP files. Ok, good. Note that avf_sdp_create() should already be able to do what you need (you just need to prepare a proper "AVFormatContext *ac[]" before calling it). So, I guess everything you need is a new muxer which sets up the "ac" array and calls avf_sdp_create().
The problem with avf_sdp_create() is that it takes AVOutputFormat,
What is the exact problem with this?
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header.
Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
I'm the mapping code of ffmpeg.c I'm storing the AVFormatOutput filename in the AVStream filename, which is then used to compute the destination address. It works but looks very fragile and I'm not very happy about it.
So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files.
I suspect this will result in some code duplication; you should not do it. What you should do is to write a write_header() function that prepares an array of AVFormatContexts for avf_sdp_create(), and then calls it.
Yes, this can be factorized.
Done.
I'm attaching my implementation, but I'm somehow not satisfied with it).
Patch consists of the part (I'll split it when we'll agree on some solution for the problem I'm going to discuss):
* cosmetics to sdp.c: struct sdp_session_level -> SDPContext and other
What's the point of this change? Note that it is wrong: sdp_session_level is not a generic "SDP context", but it contains the session-level description of an SDP.
What about an SDPContext having sdp_session_level as a field?
No, that was plenty wrong, fixed, now there is no SDPContext.
renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media
Sorry, but again I do not see the point in this change.
sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header)
Idem. Sorry, but I'll not approve this kind of changes.
I think they make sense, but I won't insist on them.
sdp_write_header() may be confused with the muxer write_header() function, also I think it is more clear to call it write_sdp_header since what it does is to write the SDP header, same for the other function.
Compare this list:
sdp_write_header() sdp_write_media() sdp_media_attributes()
with:
write_sdp_header() write_sdp_media() write_sdp_media_attributes()
I think the second list is better, but again I won't waste our time on this if you prefer the other way.
Keeping it in the patch while waiting for your reply.
The use of av_dup_stream() is necessary for the "special" status of the SDP muxer, which takes streams which have been already defined.
I am not sure about it; let's see Michael's comments.
Thanks for the review, regards.
Quilt series attached. Please note that I didn't thoroughly test the patches, since I think we're still at a "consulting for the best solution" phase. Regards. -- FFmpeg = Free & Faboulous Multimedia Porno Enhanced Geisha
Hi, Stefano Sabatini wrote: [...]
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header. Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
I'm the mapping code of ffmpeg.c I'm storing the AVFormatOutput filename in the AVStream filename, which is then used to compute the destination address. It works but looks very fragile and I'm not very happy about it.
I did not know about AVStream->filename. What's its expected behaviour? The comments says "source filename of the stream", which does not make too much sense in this case... Is it ok to use AVStream->filename in this way? Where is it used in libavformat, and who sets it? Depending on the answers, maybe a patch like the attached one (completely untested, and maybe needs some fixes/cleanup) would make sense. This patch would greatly simplify the SDP muxer.
So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files. I suspect this will result in some code duplication; you should not do it. What you should do is to write a write_header() function that prepares an array of AVFormatContexts for avf_sdp_create(), and then calls it. Yes, this can be factorized.
Done.
I do not like the way you did it... In particular, I think that avf_sdp_create2() is not needed: you can just move the needed code in the SDP muxer "write_header" method, and then call avf_sdp_create() directly.
renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media Sorry, but again I do not see the point in this change.
sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header) Idem. Sorry, but I'll not approve this kind of changes. I think they make sense, but I won't insist on them.
sdp_write_header() may be confused with the muxer write_header() function, also I think it is more clear to call it write_sdp_header since what it does is to write the SDP header, same for the other function.
I am still against this rename. My preference is for a <subsystem>_<verb>_<object> naming scheme. Summing up: - sdp-rename.patch: NACK. Some of the renames might make sense (I am still undecided, but I do not like the ones like "sdp_write_header ---> write_sdp_header". - implement-avf-sdp-create2.patch: I think this is not needed (and we do not need a new function). - implement-sdp-muxer-2.patch: This must be modified to use the attached patch (if it makes sense - it depends on what AVStream->filename is, and on how it is used), or to forge a proper array of AVFormatContexts and then call avf_sdp_create() I am not sure about implement-av-dup-stream-1.patch (I leave it to Michael, since it touches the core of libavformat), and implement-ffmpeg-sdp-mapping-2.patch looks ok, but Michael should comment on it. Thanks, Luca
Luca Abeni wrote:
Hi,
Stefano Sabatini wrote: [...]
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header. Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
I'm the mapping code of ffmpeg.c I'm storing the AVFormatOutput filename in the AVStream filename, which is then used to compute the destination address. It works but looks very fragile and I'm not very happy about it.
I did not know about AVStream->filename. What's its expected behaviour? The comments says "source filename of the stream", which does not make too much sense in this case... Is it ok to use AVStream->filename in this way? Where is it used in libavformat, and who sets it?
IIRC it is currently used only for attachment streams (eg. a ttf font embedded in a mkv file). Subtitles often refer to fonts by their filename, which have to be exported in case of embedded font. So, IOW, AVStream->filename should be the name of the original raw stream file which was used to when muxing to the container, and this should be the default/preferred name if the raw stream is dumped again into a file. I'm not sure your proposition would fit with this definition... Aurel
On Fri, Nov 21, 2008 at 07:43:47PM +0100, Aurelien Jacobs wrote:
Luca Abeni wrote:
Hi,
Stefano Sabatini wrote: [...]
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header. Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
I'm the mapping code of ffmpeg.c I'm storing the AVFormatOutput filename in the AVStream filename, which is then used to compute the destination address. It works but looks very fragile and I'm not very happy about it.
I did not know about AVStream->filename. What's its expected behaviour? The comments says "source filename of the stream", which does not make too much sense in this case... Is it ok to use AVStream->filename in this way? Where is it used in libavformat, and who sets it?
IIRC it is currently used only for attachment streams (eg. a ttf font embedded in a mkv file). Subtitles often refer to fonts by their filename, which have to be exported in case of embedded font. So, IOW, AVStream->filename should be the name of the original raw stream file which was used to when muxing to the container, and this should be the default/preferred name if the raw stream is dumped again into a file. I'm not sure your proposition would fit with this definition...
I really do not like how mkv and subtitles interact, this is really sick design, fonts have names or whatever the correct term is. Filenames really seem the wrong way to identify them. btw, i think this thread shows that the documentation of AVStream.filename is insufficient ... I think this should be improved [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
On date Friday 2008-11-21 08:41:04 +0100, Luca Abeni encoded:
Hi,
Stefano Sabatini wrote: [...]
while I think the expected behaviour for the muxer would be to take a list of *AVStreams* and create from these the header. Maybe. But then, is it still possible to have different destination multicast groups for different streams? I mean: does an AVStream allow to store the destination MC group (and port) somewhere?
In the mapping code of ffmpeg.c I'm storing the AVFormatOutput filename in the AVStream filename, which is then used to compute the destination address. It works but looks very fragile and I'm not very happy about it.
I did not know about AVStream->filename. What's its expected behaviour? The comments says "source filename of the stream", which does not make too much sense in this case... Is it ok to use AVStream->filename in this way? Where is it used in libavformat, and who sets it? Depending on the answers, maybe a patch like the attached one (completely untested, and maybe needs some fixes/cleanup) would make sense. This patch would greatly simplify the SDP muxer.
I see the point of your patch, but I cannot see how it could simplify the SDP muxer. Also I'm not sure if the use of the stream filename field is meaningful, if that's the case we could copy the AVOutputStream filename while creating a new stream as in the attached patch. Then we should free the filename when closing the stream (and here I miss an av_close_output_stream() function...). Also in the code we're assuming that an RTP AVOutputStream may contain more than one AVStream, does this make sense?
So I write a write_header() function which is very similar to avf_sdp_create(), but which reads from streams rather than from a list of files. I suspect this will result in some code duplication; you should not do it. What you should do is to write a write_header() function that prepares an array of AVFormatContexts for avf_sdp_create(), and then calls it. Yes, this can be factorized.
Done.
I do not like the way you did it... In particular, I think that avf_sdp_create2() is not needed: you can just move the needed code in the SDP muxer "write_header" method, and then call avf_sdp_create() directly.
See the comment below.
renames in order to make them more meaningful and consistent (e.g.: sdp_write_media -> write_sdp_media Sorry, but again I do not see the point in this change.
sdp_media_attributes -> write_sdp_media_attributes sdp_write_header -> write_sdp_header) Idem. Sorry, but I'll not approve this kind of changes. I think they make sense, but I won't insist on them.
sdp_write_header() may be confused with the muxer write_header() function, also I think it is more clear to call it write_sdp_header since what it does is to write the SDP header, same for the other function.
I am still against this rename. My preference is for a <subsystem>_<verb>_<object> naming scheme.
Summing up: - sdp-rename.patch: NACK. Some of the renames might make sense (I am still undecided, but I do not like the ones like
"sdp_write_header ---> write_sdp_header".
What about something like: sdp_write_header ---> sdp_write_sdp_header All I want is to avoid semantic conflicts with the names of the function, now that sdp.c contains now both the code for avf_create_sdp and the SDP muxer (for which a write_header() function which writes the whole SDP is needed). I think that having both: sdp_write_header() // writes the "header" part of an SDP and write_header() // writes the whole SDP, implemented as part of the muxer API is confusing. Furthermore having the sdp_ prefix seems pointless to me, since all the function are static so they can't conflict with other namespaces (but I have no strong opinion regarding this prefixing issue).
- implement-avf-sdp-create2.patch: I think this is not needed (and we do not need a new function). - implement-sdp-muxer-2.patch: This must be modified to use the attached patch (if it makes sense - it depends on what AVStream->filename is, and on how it is used), or to forge a proper array of AVFormatContexts and then call avf_sdp_create()
The SDP muxer will work taking an array of streams as found in the AVOutputStream, and issuing the SDP from them. Taking the path: creation of the SDP AVOutputStream : files -> streams and then writing of the SDP in write_header(): streams -> files is unnecessarily complicated, while with using the function avf_sdp_create2 we would avoid the second conversion (while the first one is necessary in each case). Then I thought that having avf_create_sdp2() in the public API may be useful, but we could simply avoid to make it public.
I am not sure about implement-av-dup-stream-1.patch (I leave it to Michael, since it touches the core of libavformat), and implement-ffmpeg-sdp-mapping-2.patch looks ok, but Michael should comment on it.
Yes, and I suspect the memcpy on the AVCodecContext may cause major problems, maybe we would need also some sort of avcodec_dup_context(). [...] Thanks for the review, regards. -- FFmpeg = Fantastic & Funny Meaningful Problematic Elastic Gadget
Hi, Stefano Sabatini wrote: [...]
Depending on the answers, maybe a patch like the attached one (completely untested, and maybe needs some fixes/cleanup) would make sense. This patch would greatly simplify the SDP muxer.
I see the point of your patch, but I cannot see how it could simplify the SDP muxer.
The idea is that with this patch the SDP muxer could directly call avf_sdp_create() passing the input AVFormatContext to it. But looking at Aurelien's email it seems that AVStream->filename cannot be used in this way... So the patch is not good (and I think the SDP muxer should be designed to work in a different way, since I suspect it cannot use AVStream->filename). [...]
Also in the code we're assuming that an RTP AVOutputStream may contain more than one AVStream, does this make sense?
I do not know... In the definition of AVOutputStream in ffmpeg.c I see that it contains a pointer to a single AVStream: where is this "more than one AVStream" assumption? [...]
- sdp-rename.patch: NACK. Some of the renames might make sense (I am still undecided, but I do not like the ones like
"sdp_write_header ---> write_sdp_header".
What about something like: sdp_write_header ---> sdp_write_sdp_header
Sorry, no. sdp_write_header is ok. If you really hate this name, or you want to use it for different things, this can be changed in something like sdp_write_session_level_description.
All I want is to avoid semantic conflicts with the names of the function, now that sdp.c contains now both the code for avf_create_sdp and the SDP muxer (for which a write_header() function which writes the whole SDP is needed).
I am beginning to think that the SDP muxer should be in a different file (this would avoid #ifdefs when a user dos not want to compile it).
- implement-avf-sdp-create2.patch: I think this is not needed (and we do not need a new function). - implement-sdp-muxer-2.patch: This must be modified to use the attached patch (if it makes sense - it depends on what AVStream->filename is, and on how it is used), or to forge a proper array of AVFormatContexts and then call avf_sdp_create()
The SDP muxer will work taking an array of streams as found in the AVOutputStream, and issuing the SDP from them. Well, it will receive a pointer to AVFormatContext, like all the other muxers. What it has to do is to get the relevant information from it, and fill an array of AVOutputStream to pass to avf_sdp_create().
[...]
Then I thought that having avf_create_sdp2() in the public API may be useful, but we could simply avoid to make it public.
No, I do not think we need another function in the public API, unless you show that there is some situation in which avf_create_sdp() is not enough. Luca
On date Saturday 2008-11-22 13:24:26 +0000, Luca Abeni encoded:
Hi,
Stefano Sabatini wrote: [...]
Depending on the answers, maybe a patch like the attached one (completely untested, and maybe needs some fixes/cleanup) would make sense. This patch would greatly simplify the SDP muxer.
I see the point of your patch, but I cannot see how it could simplify the SDP muxer.
The idea is that with this patch the SDP muxer could directly call avf_sdp_create() passing the input AVFormatContext to it.
But looking at Aurelien's email it seems that AVStream->filename cannot be used in this way... So the patch is not good (and I think the SDP muxer should be designed to work in a different way, since I suspect it cannot use AVStream->filename).
Yes, so the problem is to store the destination address of the stream, which is different for each stream so it can't be simply specified in the AVFormatContext. Possible solutions: * use the priv_data field (to fill in av_new_stream(), if it is an RTP stream then it will fill it with a structure containing the MC destination info) * define some other field in AVStream I don't know if any of this solutions is valid.
[...]
Also in the code we're assuming that an RTP AVOutputStream may contain more than one AVStream, does this make sense?
I do not know... In the definition of AVOutputStream in ffmpeg.c I see that it contains a pointer to a single AVStream: where is this "more than one AVStream" assumption?
Sorry I really meant AVOutputStream, in rtpenc.c we have (rtp_write_header.c) if (s1->nb_streams != 1) return -1; So for example: stefano at geppetto ~/s/ffmpeg> ffmpeg -i slow.flv -vcodec mpeg4 -f rtp rtp://localhost:5004 FFmpeg version SVN-r15925, Copyright (c) 2000-2008 Fabrice Bellard, et al. [...] Input #0, flv, from 'slow.flv': Duration: 00:03:58.15, start: 0.000000, bitrate: 64 kb/s Stream #0.0: Video: flv, yuv420p, 320x240, 29.97 tb(r) Stream #0.1: Audio: mp3, 22050 Hz, mono, s16, 64 kb/s Output #0, rtp, to 'rtp://localhost:5004': Stream #0.0: Video: mpeg4, yuv420p, 320x240, q=2-31, 200 kb/s, 29.97 tb(c) Stream #0.1: Audio: pcm_mulaw, 22050 Hz, mono, s16, 176 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Could not write header for output file #0 (incorrect codec parameters ?) fails, while the logic in the avf_sdp_create seems to support more than one stream in the output format: for (j = 0; j < ac[i]->nb_streams; j++) { sdp_write_media(buff, size, ac[i]->streams[j]->codec, dst[0] ? dst : NULL, (port > 0) ? port + j * 2 : 0, ttl); and it will assign the port PORT, PORT + 2, PORT + 4... to the various streams.
[...]
- sdp-rename.patch: NACK. Some of the renames might make sense (I am still undecided, but I do not like the ones like
"sdp_write_header ---> write_sdp_header".
What about something like: sdp_write_header ---> sdp_write_sdp_header
Sorry, no. sdp_write_header is ok. If you really hate this name, or you want to use it for different things, this can be changed in something like sdp_write_session_level_description.
Mmh, afterall I begin to see the logic into those names, please check the attached patch to see which of the remaining renamings I'm doing make sense to you. Regards. -- FFmpeg = Forgiving and Fast Multipurpose Porno Elitarian Guru
Hi, Stefano Sabatini wrote: [...]
But looking at Aurelien's email it seems that AVStream->filename cannot be used in this way... So the patch is not good (and I think the SDP muxer should be designed to work in a different way, since I suspect it cannot use AVStream->filename).
Yes, so the problem is to store the destination address of the stream, which is different for each stream so it can't be simply specified in the AVFormatContext.
Yes, this is the real problem when implementing an SDP muxer. I have no good ideas for addressing it; I remember seeing proposals about storing all the destination addresses in the URL, or using some metadata in AVFormatContext, adding fields to AVFormatContext, etc... But I do not remember any idea that fully convinced me (I believe the key point is to make something that is not really SDP/RTP specific).
Also in the code we're assuming that an RTP AVOutputStream may contain more than one AVStream, does this make sense? I do not know... In the definition of AVOutputStream in ffmpeg.c I see that it contains a pointer to a single AVStream: where is this "more than one AVStream" assumption?
Sorry I really meant AVOutputStream
This is intended. avf_sdp_create() is designed to be both flexible and easy to use. If every RTP stream has a different destination address, then the only possible solution is to use an array of AVFormatContexts, and each of them has only one stream. But an RTSP server generally uses a single destination address (and allocating the ports as p, p+2, etc... is reasonable), so in this case a single AVFormatContext (with multiple streams) can be used, simplifying the caller. ffserver uses this feature, for example.
Sorry, no. sdp_write_header is ok. If you really hate this name, or you want to use it for different things, this can be changed in something like sdp_write_session_level_description.
Mmh, afterall I begin to see the logic into those names, please check the attached patch to see which of the remaining renamings I'm doing make sense to you.
This one looks ok. Luca
On date Wednesday 2008-11-26 21:32:02 +0000, Luca Abeni encoded:
Hi,
Stefano Sabatini wrote: [...]
But looking at Aurelien's email it seems that AVStream->filename cannot be used in this way... So the patch is not good (and I think the SDP muxer should be designed to work in a different way, since I suspect it cannot use AVStream->filename).
Yes, so the problem is to store the destination address of the stream, which is different for each stream so it can't be simply specified in the AVFormatContext.
Yes, this is the real problem when implementing an SDP muxer. I have no good ideas for addressing it; I remember seeing proposals about storing all the destination addresses in the URL, or using some metadata in AVFormatContext, adding fields to AVFormatContext, etc... But I do not remember any idea that fully convinced me (I believe the key point is to make something that is not really SDP/RTP specific).
What about a struct in AVStream? It could be allocated and set only if the muxer is of some given type (implementable through a flag) then a function could parse the filename and fill it in av_new_stream() Maybe something like AVUrl may do the trick.
Also in the code we're assuming that an RTP AVOutputStream may contain more than one AVStream, does this make sense? I do not know... In the definition of AVOutputStream in ffmpeg.c I see that it contains a pointer to a single AVStream: where is this "more than one AVStream" assumption?
Sorry I really meant AVOutputStream
Doh! I really meant AVFormatContext!
This is intended. avf_sdp_create() is designed to be both flexible and easy to use. If every RTP stream has a different destination address, then the only possible solution is to use an array of AVFormatContexts, and each of them has only one stream. But an RTSP server generally uses a single destination address (and allocating the ports as p, p+2, etc... is reasonable), so in this case a single AVFormatContext (with multiple streams) can be used, simplifying the caller. ffserver uses this feature, for example.
I wonder if this feature could be useful in the RTP muxer too, implementing the same logic for assigning the port to the various elementary streams. It makes sense to me for example define something like this: ffmpeg -i test.mpeg -f rtp rtp://localhost:5004 where the resulting RTP output format also contains a video stream.
Sorry, no. sdp_write_header is ok. If you really hate this name, or you want to use it for different things, this can be changed in something like sdp_write_session_level_description.
Mmh, afterall I begin to see the logic into those names, please check the attached patch to see which of the remaining renamings I'm doing make sense to you.
This one looks ok.
I'll soon apply it. Regards. -- FFmpeg = Frenzy and Faboulous Magic Patchable Exciting Glue
On date Friday 2008-11-28 00:35:58 +0100, Stefano Sabatini encoded:
On date Wednesday 2008-11-26 21:32:02 +0000, Luca Abeni encoded: [...]
Mmh, afterall I begin to see the logic into those names, please check the attached patch to see which of the remaining renamings I'm doing make sense to you.
This one looks ok.
I'll soon apply it.
Applied. -- FFmpeg = Fantastic Forgiving Mastering Portable Elastic Glue
participants (5)
-
aurel@gnuage.org -
lu_zero@gentoo.org -
lucabe72@email.it -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it