Hello libav users !
I tried to create a very simple mpeg2 file : a container with one video stream.
But I don't understand very well all API functions needed to perform this
operation :
When I execute the attached sample program (below) I obtain an empty
"video.mpg" file. Is avformat_write_header function who write the media file
header ?
Or some information are missing in my settings ? I have to admit I'm a little
bit confused :-(
#include "libavutil/opt.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavutil/imgutils.h"
static const char *video = "video.mpg";
static const int fps = 25;
int main(int argc, char **argv)
{
avcodec_register_all();
av_register_all();
AVFormatContext *outfile;
AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);
if (codec != NULL)
{
avformat_alloc_output_context2(&outfile, NULL, "mpeg2video", NULL);
AVStream *stream = avformat_new_stream(outfile, codec);
stream->codec->codec_id = codec->id;
stream->codec->width = 1920;
stream->codec->height = 1080;
stream->codec->time_base = (AVRational) {1, fps};
stream->codec->pix_fmt = PIX_FMT_YUV422P;
stream->codec->bit_rate = 15 * 1000 * 1000;
stream->codec->gop_size = fps / 2;
stream->codec->max_b_frames = 1;
avio_open(&outfile->pb, video, AVIO_FLAG_WRITE); // Without this line no file
created
avformat_write_header(outfile, NULL);
av_dump_format(outfile, 0, video, 1);
avformat_free_context(outfile);
}
return 0;
}
Sincerly,
Guillaume _______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user