[Ffmpeg-devel] Transcoding RTP/RTSP streams

Julian Lamberty julian.lamberty
Mon Apr 2 13:54:10 CEST 2007


Hi!

I'm trying to create a small program using libavcodec/format that can 
transcode network (RTP/RTSP) streams "on the fly". I've started looking 
at ffplay.c and ffserver.c but can't make my way through the code.

Until now I have managed to open a file, re-encode it and write it to a 
file again with the following code (only an excerpt):

while(av_read_frame(ipFormatCtx, &ipacket) >= 0 && frame_count < 200)
    {
        if(ipacket.stream_index == ivideo_stream)
        {
            dec_bytes = avcodec_decode_video(ipCodecCtx, ipFrame, 
&iframeFinished, ipacket.data, ipacket.size);
            if(iframeFinished)
            {
                enc_bytes = avcodec_encode_video(opCodecCtx, outbuf, 
outbuf_size, ipFrame);
                if(enc_bytes != 0)
                {
                    av_init_packet(&opacket);
                    opacket.data = outbuf;
                    opacket.size = enc_bytes;
                    opacket.stream_index = ostream->index;
                    opacket.pts = 
av_rescale_q(opCodecCtx->coded_frame->pts, opCodecCtx->time_base, 
ostream->time_base);
                    if(opCodecCtx->coded_frame->key_frame)
                    {
                        opacket.flags |= PKT_FLAG_KEY;
                    }
                    if(av_write_frame(opFormatCtx, &opacket) < 0)
                    {
                        printf("ERROR: Could not write frame");
                        exit(1);
                    }
                }     
            }     
        }
        av_free_packet(&ipacket);
    }

I'm using av_open_input_file() to open the file. How can I manage to 
read packets from a network stream instead of a file? Please help me 
(maybe with some example code if someone has done somthing similar?!)

Thanks a lot

Julian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5198 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070402/2d9acd78/attachment.bin>



More information about the ffmpeg-devel mailing list