MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / SetAudioOptions

Method SetAudioOptions

src/FFmpegWriter.cpp:288–321  ·  view source on GitHub ↗

Set audio export options

Source from the content-addressed store, hash-verified

286
287// Set audio export options
288void FFmpegWriter::SetAudioOptions(bool has_audio, std::string codec, int sample_rate, int channels, ChannelLayout channel_layout, int bit_rate) {
289 // Set audio options
290 if (codec.length() > 0) {
291 const AVCodec *new_codec = avcodec_find_encoder_by_name(codec.c_str());
292 if (new_codec == NULL)
293 throw InvalidCodec("A valid audio codec could not be found for this file.", path);
294 else {
295 // Set audio codec
296 info.acodec = new_codec->name;
297 }
298 }
299 if (sample_rate > 7999)
300 info.sample_rate = sample_rate;
301 if (channels > 0)
302 info.channels = channels;
303 if (bit_rate > 999)
304 info.audio_bit_rate = bit_rate;
305 info.channel_layout = channel_layout;
306
307 // init resample options (if zero)
308 if (original_sample_rate == 0)
309 original_sample_rate = info.sample_rate;
310 if (original_channels == 0)
311 original_channels = info.channels;
312
313 ZmqLogger::Instance()->AppendDebugMethod(
314 "FFmpegWriter::SetAudioOptions (" + codec + ")",
315 "sample_rate", sample_rate,
316 "channels", channels,
317 "bit_rate", bit_rate);
318
319 // Enable / Disable audio
320 info.has_audio = has_audio;
321}
322
323
324// Set audio export options (overloaded function)

Callers 5

WriteFrameMethod · 0.80
FFmpegWriter.cppFile · 0.80
mainFunction · 0.80
Example.pyFile · 0.80

Calls 2

InvalidCodecClass · 0.85
AppendDebugMethodMethod · 0.80

Tested by

no test coverage detected