Hi,
I'm actually playing a MPEG video in C++ using ffmpeg. However, there is several video stream.
In my test video there is 4 videos streams with ids : 0, 16, 33, 49 and no audio stream. But formatContext->streams[i] give me only 2 streams : a video stream with PID 33 and an audio stream with PID 49 whereas there should be 4 videos streams ! It's the same with VLC (in the console we can see the 4 pids but there is only one video stream and one audio stream).
I'm sure my video contains 4 videos streams identified by these PID. I don't find how to get them with ffmpeg.
Is somebody have any idea ?
- Viewing Profile: Topics: arthur__
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 7
- Profile Views 364
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
102
Neutral
User Tools
Contacts
arthur__ hasn't added any contacts yet.
Latest Visitors
Topics I've Started
[FFMPEG] Play a video with many streams
22 May 2012 - 09:28 AM
FFMPEG and av_open_input_stream
13 March 2012 - 12:06 PM
Hello,
I try to read a mpeg2 video from a stream with ffmpeg library. In my first tests, I tried to read from a byte buffer, but now I read directly from a file (in my ReadPacket function) in order to be sure it's right data.
I tried many way to do that, but av_open_input_stream function return always -1.
I post my code here and hope someone could help me ! If someone have a full code to do that, i''ll be happy to see it. Thanks.
And my readPacket func :
I try to read a mpeg2 video from a stream with ffmpeg library. In my first tests, I tried to read from a byte buffer, but now I read directly from a file (in my ReadPacket function) in order to be sure it's right data.
I tried many way to do that, but av_open_input_stream function return always -1.
I post my code here and hope someone could help me ! If someone have a full code to do that, i''ll be happy to see it. Thanks.
av_log_set_level(AV_LOG_VERBOSE);
avcodec_init();
av_register_all();
avcodec_register_all();
pFormatCtx = avformat_alloc_context();
if (!pFormatCtx)
{
return -1;
}
FILE* f = fopen("D:\\projets\\test_data\\video\\video_ts.mpg", "rb");
int bioBufferSize = 8000;
unsigned char *bioBuffer = (unsigned char *)av_malloc(bioBufferSize + FF_INPUT_BUFFER_PADDING_SIZE);
ByteIOContext *bioContext = new ByteIOContext();
int ret = init_put_byte(bioContext, bioBuffer, bioBufferSize, 0, (void *)f, readPackets, NULL, seekPackets);
AVFormatParameters params, *ap = ¶ms;
memset(ap, 0, sizeof(*ap));
ap->prealloced_context = 1
//pFormatCtx->video_codec_id = findCodecOrDie("mpeg2video", AVMEDIA_TYPE_VIDEO, 0, avcodecOpts[AVMEDIA_TYPE_VIDEO]->strict_std_compliance);
//pFormatCtx->flags |= AVFMT_FLAG_NONBLOCK;
AVInputFormat *inputFormat = av_find_input_format("mpegts");
//pFormatCtx->iformat = inputFormat;
ret = av_open_input_stream(&pFormatCtx, bioContext, "stream", inputFormat, ap);
av_close_input_stream(pFormatCtx);
av_free(bioBuffer);
delete bioContext;
fclose(f);
[...]
And my readPacket func :
static int readPackets(void *opaque, uint8_t *buf, int buf_size)
{
FILE* f = (FILE *)opaque;
int read = fread(buf, 1, buf_size, f);
return read;
}
DirectX (in C# with SlimDX) and ffmepg
12 March 2012 - 08:43 AM
Hello,
I have a C++ DLL which uses ffmepg to read a video. When it gets a picture, I transmit AVFrame (and put it to RGB24 format with sws_scale) to C# code thanks to a callback.
I try to display this picture with DirectX (Texture texture = Texture.FromMemory(..) ). When I convert the AVFrame to bmp, it's working but the image loses alpha canal. I would like use directly AVFrame->data[0] but DirectX do not know how manage it !
Is someone knowning how to display an AVFrame in DirectX ?
I would like to display keyframe and the others frame.
I have a C++ DLL which uses ffmepg to read a video. When it gets a picture, I transmit AVFrame (and put it to RGB24 format with sws_scale) to C# code thanks to a callback.
I try to display this picture with DirectX (Texture texture = Texture.FromMemory(..) ). When I convert the AVFrame to bmp, it's working but the image loses alpha canal. I would like use directly AVFrame->data[0] but DirectX do not know how manage it !
Is someone knowning how to display an AVFrame in DirectX ?
I would like to display keyframe and the others frame.
- Home
- » Viewing Profile: Topics: arthur__

Find content