Hey Guys
I would like to open an rtsp stream (3gp file) with ffmpeg and read just the
audio stream it contains. I was able to extract the
audio stream (from a previously downloaded file), but I'm still puzzled by the
rstp streaming part.
I'm relatively new to ffmpeg, so any help is appreciated.
Here's the code that extracts the audio stream:
AVFormatContext *pFormatCtx;
int audioStream;
AVCodecContext *aCodecCtx;
AVCodec *aCodec;
av_register_all();
// Open video file
if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
return -1; // Couldn't open file
// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0)
return -1; // Couldn't find stream information
// Dump information about file onto standard error
dump_format(pFormatCtx, 0, argv[1], 0);
audioStream=-1;
for(i=0; i<pFormatCtx->nb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO &&
audioStream < 0) {
audioStream=i;
}
}
if(audioStream==-1)
return -1;
aCodecCtx=pFormatCtx->streams[audioStream]->codec;
aCodec = avcodec_find_decoder(aCodecCtx->codec_id);
if(!aCodec) {
fprintf(stderr, "Unsupported codec!\n");
return -1;
}
avcodec_open(aCodecCtx, aCodec);
Thanks,
Stephane Rufer
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user