[Ffmpeg-devel] [Ffmpeg-devel-old] rtp mpeg4 packetize problem
Wed Jul 20 10:37:53 CEST 2005
On Wed, 2005-07-20 at 15:58 +0800, mike lee wrote:
> Luca Abeni wrote:
> >Hello Mike,
> >On Wed, 2005-07-20 at 12:19 +0800, mike lee wrote:
> >>Dear all
> >> I am now trying to use ffmpeg library to stream data and test with
> >>videolan player thought rtsp/rtp/udp .
> >I wrote a similar application some time ago (a very simple one,
> >streaming only video).
> It is what exactly i am doing. Will you share those codes with us?
Unfortunately, I cannot (I wrote that code at work, and I do not have it
> >>But i found that error occur
> >>whenever a frame is sent with multiple packets which is likely to be the
> >>key frame. Final image is a mess at the bottom but ok at the top. And i
> >>have checked that the marker bit is properly set on the last packet.
> >What I did is pretty simple, and works ok:
> >1) send only 1 frame per rtp packet (no more than 1 frame)
> >2) if a frame does not fit in a single rtp packet, split it in more
> >packets, setting the M flag to 1 only on the last one. It is important
> >that the last packet contains only the end of the frame (and not the
> >beginning of the next one, for example).
> Method(1) should be ok for any non-key frame, but it is quite difficult
> for key frame. Method(2) is what i am doing and videolan player seem ok
> with my marker bit setting.
Ah, ok... So you fixed the problem that you described in the previous
> I am now using videlan player compiled with live.com library. The
> streaming should be ok, but the problem i guess should be because of the
> non-standard packetize method in libavformat/rtp.c
So, you are using libavformat for encapsulating the MPEG4 stream in RTP
packets? I do not remember exactly, but I think when I developed my
application libavformat did not support the MPEG4 payload.
I wrote my own RTP code, and I used it (just few lines of C code to put
an RTP header in front of the packet).
BTW: have you had a look at mpeg4ip? It is a little bit complex, but it
can do exactly what you need (and it can use libavcodec for encoding).
> >> Also, according rfc3016, mpeg4 rtp payload may include specific
> >I did not double-check, but I do not remember rfc3016 asking for
> >specific headers in the payload (I think it simply cites some standard
> >MPEG4 headers). The only "strange thing" that you can do is to put the
> >MPEG4 "global headers" in the config line in the SDP, and remove them
> >from the MPEG4 video stream (use CODEC_FLAG_GLOBAL_HEADER).
> Due to lack of knowledge on mpeg coding
Well, I do not know very much of it too :)
> Could you tell me the usage on CODEC_FLAG_GLOBAL_HEADER?
Just set such flag in the "flags" field of AVCodecContext before opening
the codec. After opening the codec, you will have the "global headers"
in the extradata field (look at extradata and extradata_size in
AVCodecContext). You can dump the extradata field in ascii and put it in
the config= in the SDP file (according to RFC3016).
> Will it cut off all the headers including VOL, VP,etc?
Well, I do not know... I am not an expert in MPEG4 encoding (I just
blindly use libavcodec, and it works :)
Email.it, the professional e-mail, gratis per te: http://www.email.it/f
Proteggi la tua moto dalle intemperie e... dagli sguardi indiscreti con il Telo Coprimoto!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2744&d=20-7
More information about the ffmpeg-devel