Skip to content

Commit 48cacec

Browse files
authored
Merge pull request #11 from leonyu1010/codecContext_option
Add a method to set generic AVOptions
2 parents 07503c7 + fed082a commit 48cacec

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

source/ffmpeg-cpp/encode_video/encode_video.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ int main()
2121
// parameter -qscale and must be within range [0,31].
2222
codec->SetQualityScale(0);
2323

24+
// Set the bit rate option -b:v 2M
25+
codec->SetGenericOption("b", "2M");
26+
2427
// Create an encoder that will encode the raw audio data as MP3.
2528
// Tie it to the muxer so it will be written to the file.
2629
VideoEncoder* encoder = new VideoEncoder(codec, muxer);

source/ffmpeg-cpp/ffmpeg-cpp/Codecs/Codec.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ namespace ffmpegcpp
3535
av_opt_set_double(codecContext->priv_data, name, value, 0);
3636
}
3737

38+
void Codec::SetGenericOption(const char* name, const char* value)
39+
{
40+
av_opt_set(codecContext, name, value, 0);
41+
}
42+
3843
AVCodecContext* Codec::LoadContext(AVCodec* codec)
3944
{
4045
AVCodecContext* codecContext = avcodec_alloc_context3(codec);

source/ffmpeg-cpp/ffmpeg-cpp/Codecs/Codec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace ffmpegcpp
2020
void SetOption(const char* name, int value);
2121
void SetOption(const char* name, double value);
2222

23+
void SetGenericOption(const char* name, const char* value);
24+
2325
void SetGlobalContainerHeader(); // used by the Muxer for configuration purposes
2426

2527
protected:

0 commit comments

Comments
 (0)