Hi,
On 02/06/10 07:23, Steffen Ebersbach wrote:
[...]
2) mux them in an MPEG TS, using the TS muxer. But instead of writing
the TS stream to a file, you have to store it in memory buffers (you
can use url_open_dyn_buf() and friends, I think - ffserver.c should
contain some code showing how to do something similar... It uses
ASF, SWF, RM, etc instead of TS, and it uses HTTP instead of RTP,
but I think you can easily see what to do from there)
OK, I create a ByteIOcontext with url_open_dyn_buf() and set it to
AVFormatContext->pb from my mpegts with mpeg2 video so when i make
av_write_interleaved_frame() on this context the packets go to this
buffer.
Right... Then, you can use url_close_dyn_buf() to save the stream in an
array that you can use for writing to the RTP muxer (as I said, I never
tried this: I am just looking at ffserver's code).
3) setup a "fake" codec with codec ID CODEC_ID_MPEG2TS
4) use such a codec for opening the RTP muxer (use one single AVStream,
with this codec)
my code for this:
AVFormatContext *rtpcontext = av_alloc_context()
AVStream *fakevideo = 0;
fakevideo = av_new_stream(rtpcontext,0); //Videostream
if (!fakevideo) return -1;
rtpcontext->oformat = guess_format("rtp",0,0);
rtpcontext->video_codec_id = CODEC_ID_MPEG2TS; //fakecodec
No, I think this should be
fakevideo->codec->codec_id = CODEC_ID_MPEG2TS;
(and before this, you might need an
"avcodec_get_context_defaults2(fakevideo->codec, AVMEDIA_TYPE_VIDEO);"
or similar, I do not know...).
url_fopen(&rtpcontext->pb,"rtp://1.1.1.1:8000", URL_RDWR);
Maybe this could be URL_WRONLY, I do not know...
5) write in the RTP muxer the buffers where you muxed the TS (point 2)
That's the problem , I use get_bufer() from the ts-context and when
put_buffer with the rtpcontext. But everytime only 1024 Bytes are read, an
the output on IP is wrong. I think this is because url_open_dyn_buf()
returns a write only buffer (see avio.h)
Looking at ffserver.c, you should do
len = url_close_dyn_buf(pb, &my_buffer);
where pb is the ByteIOContext you opened with url_open_dyn_buf() and
used to mux in TS. Now, you should have the muxed TS packets in
"my_buffer". You can put that buffer in an AVPacket, and use
av_write_frame() on the RTP muxer. That should work...
Luca
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user