Skip to content

FFmpeg dict opt in QtAV

WangBin edited this page Dec 19, 2016 · 6 revisions

FFmpeg/Libav has functions like av_opt_set_xxx, av_dict_set. In QtAV, the you can use

void AVPlayer::setOptionsForFormat(const QVariantHash& dict);     //avformat
void AVPlayer::setOptionsForAudioCodec(const QVariantHash& dict); //avcodec
void AVPlayer::setOptionsForVideoCodec(const QVariantHash& dict); //avcodec

You can add a wrapper for the options. i.e. add a key and make the options as it's value. The key is avformat for AVPlayer::setOptionsForFormat and avcodec for AVPlayer::setOptionsForAudioCodec and AVPlayer::setOptionsForVideoCodec.

Example: the following options are equal

QVariantHash opt;
opt["probesize"] = 4096;
player->setOptionsForFormat(opt);

and

QVariantHash avfmt_opt;
avfmt_opt["probesize"] = 4096;
avfmt_opt["user_agent"] = "xxx";
QVariantHash opt;
opt["avformat"] = avfmt_opt;
player->setOptionsForFormat(opt);

The option above can change the stream latency. See https://trac.ffmpeg.org/wiki/StreamingGuide#Latency

####TODO

command line options and gui in player example

Clone this wiki locally