2

Im new to using FFMpeg and I'd like to do the equivalent of using the command line option -f dvd but in my app, by using the libav api. In the source of FFMpeg the option sets up some parameters as

 opt_video_codec(o, "c:v", "mpeg2video");
 opt_audio_codec(o, "c:a", "ac3");
 parse_option(o, "f", "dvd", options);

 parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
 parse_option(o, "r", frame_rates[norm], options);
 parse_option(o, "pix_fmt", "yuv420p", options);
 av_dict_set(&o->g->codec_opts, "g", norm == PAL ? "15" : "18", AV_DICT_DONT_OVERWRITE);

 av_dict_set(&o->g->codec_opts, "b:v", "6000000", AV_DICT_DONT_OVERWRITE);
 av_dict_set(&o->g->codec_opts, "maxrate", "9000000", AV_DICT_DONT_OVERWRITE);
 av_dict_set(&o->g->codec_opts, "minrate", "0", AV_DICT_DONT_OVERWRITE); // 1500000;
 av_dict_set(&o->g->codec_opts, "bufsize", "1835008", AV_DICT_DONT_OVERWRITE); // 224*1024*8;

 av_dict_set(&o->g->format_opts, "packetsize", "2048", AV_DICT_DONT_OVERWRITE);  // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
 av_dict_set(&o->g->format_opts, "muxrate", "10080000", AV_DICT_DONT_OVERWRITE); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8

 av_dict_set(&o->g->codec_opts, "b:a", "448000", AV_DICT_DONT_OVERWRITE);
 parse_option(o, "ar", "48000", options);

How do these relate to the libav api?

The incoming video frames are at the correct resolution for pal of 720x576 in yuv420p format. Some of my params...

pCodec = avcodec_find_encoder(AV_CODEC_ID_MPEG2VIDEO);

pContext->bitrate = 48000000;
pContext->width = 720;
pContext->height = 576;

AVRational fps = {1,25};
pContext->time_base = fps;

pContext->gop_size = 15;
pContext->max_b_frmaes = 2;
pContext->pix_fmt = AV_PIX_FMT_YUV420P;

av_set_dict(&pDict,"packet_size","2048",0); // This seems to be ignored?

avcodec_open2(pContext,pCodec,&pDict);

The AVDictionary... What is the dictionary? How does it relate the encoding process? Is it simply a user dictionary for passing a collection of settings around your code?

Ultimately I'd like to be able to transcode incoming video frames that are already in the correct size and format for pal dvd and output a dvd compliant mpeg2 video ( data packets of 2048 bytes ). I understand the mpeg2 video format but I'm confused with ffmpeg params.

Thanks!

Dave Camp
  • 115
  • 8
  • Some of those options apply to the video muxer [not sure how to set them...] and some apply to the audio side of things...FWIW. – rogerdpack Jul 21 '14 at 06:40

0 Answers0