Hi Gavin,

Gavin Smith wrote:
[...]
> I was able to edit the output_example.c with some mixed success.  I was able 
> to submit MPEG-2 (video) over rtp to a VLC client.
> 
> What I actually did was I "tricked" the AVOutputFormat *fmt variable by 
> parsing 
> 
> fmt = guess_format("mpeg2video", NULL, NULL ) 
> 
> instead of:
> 
> fmt = guess_format("mpeg2video", filename, NULL );

Uhm... This does not look correct: in this way, you are not using the RTP 
format,
but the mpeg2video format. I would use someting like
rtp_format = guess_format("rtp", NULL, NULL);
s = av_alloc_format_context();
s->oformat = rtp_format;
snprintf(s->filename, sizeof(s->filename), "rtp://%s:%d", dst, port);
st = av_new_stream(s, 0);
st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
...     /* and so on... */
(WARNING: Untested code! And you have to add all the error checks)

[...]
> All is well, but if I try and submit an h264 ES  (video-only) file over rtp 
> and call:
> 
> fmt = guess_format("h264", NULL, NULL )
> 
> it appears to find the correct codec, but when I call the open_video 
> function, it exits because it cannot find the h264 codec when calling 
> avcodec_find_decoder.

I guess you copied too much code from output_example, and you confused some 
things:
where does the avcodec_find_decoder() come from? open_video() is a function in
output_example.c which is used to open a video encoder, but I guess you do not
need it (because you said that you only need to packetize some already encoded
video).
What you have to do is to use some code similar to the one I suggested above,
setting codec_id to CODEC_ID_H264 (or whatever is the right name). Of course, 
you
will also have to fill other important fields in the AVCodecContext structure.

[...]
> Again, I successfully submitted the test clip over the network using RTP.  In 
> addition, I managed to successfully create a valid SDP file using the 
> avf_sdp_create function.
> 
> All that I have transmitted thus far has been the test clip.  Now, my end 
> goal is to use my own encoder and my own h264 encoded data.  
> 
> I found the AVPacket struct which encapsulate the h264 data to be 
> transmitted.  I understand how to add data to the packet and the rest, but 
> I'm unsure on how I can parse my h264 data (such that it recognizes NALs and 
> the like) and add it to the packet.
> 
> All I get out of my own encoder is a byte array which is populated every now 
> and then which [I suspect] contains a couple of h264 es frames.
You can use libavformat to read your stream, and to properly fill the AVPacket
struct - basically you have to do something similar to
ffmpeg -i <h264 stream> -vcodec copy -f rtp rtp://<dst addr>:<dst port>

Or maybe you can directly use the H264 parse to split your elementary stream
in frames (see libavcodec/h264_parser.c). But I do not know the correct API:
I generally open an input stream and use av_read_frame().


                                        Luca
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to