MCPcopy Create free account
hub / github.com/IENT/YUView / loadFFmpegLibraries

Method loadFFmpegLibraries

YUViewLib/src/ffmpeg/FFmpegVersionHandler.cpp:330–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330void FFmpegVersionHandler::loadFFmpegLibraries()
331{
332 if (this->librariesLoaded)
333 return;
334
335 // Try to load the ffmpeg libraries from the current working directory and several other
336 // directories. Unfortunately relative paths like "./" do not work: (at least on windows)
337
338 // First try the specific FFMpeg libraries (if set)
339 QSettings settings;
340 settings.beginGroup("Decoders");
341 auto avFormatLib = settings.value("FFmpeg.avformat", "").toString();
342 auto avCodecLib = settings.value("FFmpeg.avcodec", "").toString();
343 auto avUtilLib = settings.value("FFmpeg.avutil", "").toString();
344 auto swResampleLib = settings.value("FFmpeg.swresample", "").toString();
345 if (!avFormatLib.isEmpty() && //
346 !avCodecLib.isEmpty() && //
347 !avUtilLib.isEmpty() && //
348 !swResampleLib.isEmpty())
349 {
350 this->log("Trying to load the libraries specified in the settings.");
351 this->librariesLoaded =
352 loadFFMpegLibrarySpecific(avFormatLib, avCodecLib, avUtilLib, swResampleLib);
353 }
354 else
355 this->log("No ffmpeg libraries were specified in the settings.");
356
357 if (!this->librariesLoaded)
358 {
359 // Next, we will try some other paths / options
360 QStringList possibilites;
361 auto decoderSearchPath = settings.value("SearchPath", "").toString();
362 if (!decoderSearchPath.isEmpty())
363 possibilites.append(decoderSearchPath); // Try the specific search path (if one is set)
364 possibilites.append(QDir::currentPath() + "/"); // Try the current working directory
365 possibilites.append(QDir::currentPath() + "/ffmpeg/");
366 possibilites.append(QCoreApplication::applicationDirPath() +
367 "/"); // Try the path of the YUView.exe
368 possibilites.append(QCoreApplication::applicationDirPath() + "/ffmpeg/");
369 possibilites.append(
370 ""); // Just try to call QLibrary::load so that the system folder will be searched.
371
372 for (auto path : possibilites)
373 {
374 if (path.isEmpty())
375 this->log("Trying to load the libraries in the system path");
376 else
377 this->log("Trying to load the libraries in the path " + path);
378
379 this->librariesLoaded = loadFFmpegLibraryInPath(path);
380 if (this->librariesLoaded)
381 break;
382 }
383 }
384
385 if (this->librariesLoaded)
386 this->lib.avutil.av_log_set_callback(&FFmpegVersionHandler::avLogCallback);
387}

Callers 2

decoderFFmpegMethod · 0.80

Calls 4

logMethod · 0.95
toStringMethod · 0.80
appendMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected