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

Method SetVideoOptions

src/FFmpegWriter.cpp:165–275  ·  view source on GitHub ↗

Set video export options

Source from the content-addressed store, hash-verified

163
164// Set video export options
165void FFmpegWriter::SetVideoOptions(bool has_video, std::string codec, Fraction fps, int width, int height, Fraction pixel_ratio, bool interlaced, bool top_field_first, int bit_rate) {
166 // Set the video options
167 if (codec.length() > 0) {
168 const AVCodec *new_codec;
169 // Check if the codec selected is a hardware accelerated codec
170#if USE_HW_ACCEL
171#if defined(__linux__)
172 if (strstr(codec.c_str(), "_vaapi") != NULL) {
173 new_codec = avcodec_find_encoder_by_name(codec.c_str());
174 hw_en_on = 1;
175 hw_en_supported = 1;
176 hw_en_av_pix_fmt = AV_PIX_FMT_VAAPI;
177 hw_en_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
178 } else if (strstr(codec.c_str(), "_nvenc") != NULL) {
179 new_codec = avcodec_find_encoder_by_name(codec.c_str());
180 hw_en_on = 1;
181 hw_en_supported = 1;
182 hw_en_av_pix_fmt = AV_PIX_FMT_CUDA;
183 hw_en_av_device_type = AV_HWDEVICE_TYPE_CUDA;
184 } else {
185 new_codec = avcodec_find_encoder_by_name(codec.c_str());
186 hw_en_on = 0;
187 hw_en_supported = 0;
188 }
189#elif defined(_WIN32)
190 if (strstr(codec.c_str(), "_dxva2") != NULL) {
191 new_codec = avcodec_find_encoder_by_name(codec.c_str());
192 hw_en_on = 1;
193 hw_en_supported = 1;
194 hw_en_av_pix_fmt = AV_PIX_FMT_DXVA2_VLD;
195 hw_en_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
196 } else if (strstr(codec.c_str(), "_nvenc") != NULL) {
197 new_codec = avcodec_find_encoder_by_name(codec.c_str());
198 hw_en_on = 1;
199 hw_en_supported = 1;
200 hw_en_av_pix_fmt = AV_PIX_FMT_CUDA;
201 hw_en_av_device_type = AV_HWDEVICE_TYPE_CUDA;
202 } else {
203 new_codec = avcodec_find_encoder_by_name(codec.c_str());
204 hw_en_on = 0;
205 hw_en_supported = 0;
206 }
207#elif defined(__APPLE__)
208 if (strstr(codec.c_str(), "_videotoolbox") != NULL) {
209 new_codec = avcodec_find_encoder_by_name(codec.c_str());
210 hw_en_on = 1;
211 hw_en_supported = 1;
212 hw_en_av_pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX;
213 hw_en_av_device_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX;
214 } else {
215 new_codec = avcodec_find_encoder_by_name(codec.c_str());
216 hw_en_on = 0;
217 hw_en_supported = 0;
218 }
219#else // unknown OS
220 new_codec = avcodec_find_encoder_by_name(codec.c_str());
221#endif //__linux__/_WIN32/__APPLE__
222#else // USE_HW_ACCEL

Callers

nothing calls this directly

Calls 4

InvalidCodecClass · 0.85
FractionClass · 0.85
ReduceMethod · 0.80
AppendDebugMethodMethod · 0.80

Tested by

no test coverage detected