[Ffmpeg-devel] how to decode RTP packet containing mp3 data
sanjay kumar gupta
Thu Feb 22 06:31:25 CET 2007
as you suggested, I have broken the each lines which was very big. please find the content of my previous post below.
Helix server in LAN is streaming mp3 file and I am receiving the RTP
I would like to decode this RTP packets data and get the decoded
buffer and its length so that I can play this decoded data using SDL
I have a program which plays mp3 locally. To play mp3 file locally, I
needed format context and codec context pointers. Piece of code used to
decode the local audio file is given below.
But in case of RTP packet containing mp3 data.
how to get the pFormatCtx. can we get the stream info as with local
file as it is needed to get the pCodecCtx which in turn used to get the
Any example code or document would be helpful.
Thanks in advance for help.
// Register all formats and codecs
// Open video file
if(av_open_input_file(&pFormatCtx, argv/*mp3 file name*/, NULL, 0,
return -1; // Couldn't open file
// Retrieve stream information
return -1; // Couldn't find stream information
// Find the first video stream
for(i=0; i<pFormatCtx->nb_streams; i++)
if(audioStream == -1)
return -1; // Didn't find a video/audio stream
// Get a pointer to the codec context for the video stream
// Find the decoder for the video stream
return -1; // Codec not found
// Open codec
return -1; // Could not open codec
while(av_read_frame(pFormatCtx, &packet)>= 0 )
// Is this a packet from the audio stream?
// Decode audio frame
len=avcodec_decode_audio(pCodecCtx, outBuf, &outBufSize,
if (len < 0)
printf("Error while decoding\n");
//send this decoded audio to SDL.
// Free the packet that was allocated by av_read_frame
Thanks & Regards,
On Thu, 22 Feb 2007 Luca Barbato wrote :
>Please break your lines at 78 cols.
>sanjay kumar gupta wrote:
> > Hi All,
> > Helix server in LAN is streaming mp3 file and I am receiving the RTP packets.
> > Any example code or document would be helpful.
>Check ffplay, you need to add a playout buffer or the player will starve.
>ffmpeg-devel mailing list
>ffmpeg-devel at mplayerhq.hu
More information about the ffmpeg-devel