I'm in the mid of my project where I'm trying to send the audio data over RTP
using ffmpeg in VC++.
but I'm unable to do that.:
setRTPOutputAddr("192.168.100.48");
        setRTPOutputPort(9985);
        av_register_all();
        avformat_network_init();
        formatCtx= avformat_alloc_context();

        //av_dump_format(formatCtx,0,"rtp",1);
                avio_open_dyn_buf(&ioctx);
                avio_open(&formatCtx->pb, "rtp", AVIO_FLAG_WRITE);
                //av_dump_format(formatCtx,0,"rtp",1);
                formatCtx->pb = ioctx;

                rtpCtx = avformat_alloc_context();
                rtpCtx->oformat = av_guess_format("rtp",0,0);
                AVStream *fakeVideo = 0;
                fakeVideo = avformat_new_stream(rtpCtx,0);
                avcodec_get_context_defaults3(fakeVideo->codec, NULL);
                fakeVideo->codec->codec_id = AV_CODEC_ID_MPEG2TS;
                rtpCtx->audio_codec_id = AV_CODEC_ID_NONE;
                rtpCtx->video_codec_id = AV_CODEC_ID_MPEG2TS;
                // avformat_write_header(rtpCtx,0);
                
                char *url = new char[1024];
                sprintf(url,"rtp://%s:%d",rtpOutputAddr,rtpOutputPort);
                printf("will output to url:%s\n",url);
                avio_open(&rtpCtx->pb,url,AVIO_FLAG_WRITE);
                avformat_write_header(rtpCtx, NULL);
                delete url;

                
                if (avio_open(&formatCtx->pb, "rtp", AVIO_FLAG_WRITE) < 0) 
                {
                        fprintf(stderr, "Could not open '%s'\n", 
formatCtx->filename);
            return -1;
        }
                else
                {
                
                printf("succeed \n");
                }
  

        avformat_write_header(formatCtx, NULL); 
Getting error here


Do any one having any idea why my program crashes here.

Thanks!
        



--
View this message in context: 
http://libav-users.943685.n4.nabble.com/RTP-server-for-audio-stream-tp4658752.html
Sent from the libav-users mailing list archive at Nabble.com.
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to