mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
cli: add ability to log ffmpeg codecs
This commit is contained in:
parent
f11770b88b
commit
911cd678ff
@ -65,6 +65,7 @@ DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResoluti
|
||||
#include "Utilities/Thread.h"
|
||||
#include "Utilities/File.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
#include "util/media_utils.h"
|
||||
#include "rpcs3_version.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/system_utils.hpp"
|
||||
@ -303,6 +304,7 @@ constexpr auto arg_rsx_capture = "rsx-capture";
|
||||
constexpr auto arg_timer = "high-res-timer";
|
||||
constexpr auto arg_verbose_curl = "verbose-curl";
|
||||
constexpr auto arg_any_location = "allow-any-location";
|
||||
constexpr auto arg_codecs = "codecs";
|
||||
|
||||
int find_arg(std::string arg, int& argc, char* argv[])
|
||||
{
|
||||
@ -664,12 +666,36 @@ int main(int argc, char** argv)
|
||||
parser.addOption(QCommandLineOption(arg_timer, "Enable high resolution timer for better performance (windows)", "enabled", "1"));
|
||||
parser.addOption(QCommandLineOption(arg_verbose_curl, "Enable verbose curl logging."));
|
||||
parser.addOption(QCommandLineOption(arg_any_location, "Allow RPCS3 to be run from any location. Dangerous"));
|
||||
const QCommandLineOption codec_option(arg_codecs, "List ffmpeg codecs");
|
||||
parser.addOption(codec_option);
|
||||
parser.process(app->arguments());
|
||||
|
||||
// Don't start up the full rpcs3 gui if we just want the version or help.
|
||||
if (parser.isSet(version_option) || parser.isSet(help_option))
|
||||
return 0;
|
||||
|
||||
if (parser.isSet(codec_option))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole())
|
||||
{
|
||||
[[maybe_unused]] const auto con_out = freopen("CONOUT$", "w", stdout);
|
||||
[[maybe_unused]] const auto con_err = freopen("CONOUT$", "w", stderr);
|
||||
}
|
||||
#endif
|
||||
for (const utils::ffmpeg_codec& codec : utils::list_ffmpeg_decoders())
|
||||
{
|
||||
fprintf(stdout, "Found ffmpeg decoder: %s (%d, %s)\n", codec.name.c_str(), codec.codec_id, codec.long_name.c_str());
|
||||
sys_log.success("Found ffmpeg decoder: %s (%d, %s)", codec.name, codec.codec_id, codec.long_name);
|
||||
}
|
||||
for (const utils::ffmpeg_codec& codec : utils::list_ffmpeg_encoders())
|
||||
{
|
||||
fprintf(stdout, "Found ffmpeg encoder: %s (%d, %s)\n", codec.name.c_str(), codec.codec_id, codec.long_name.c_str());
|
||||
sys_log.success("Found ffmpeg encoder: %s (%d, %s)", codec.name, codec.codec_id, codec.long_name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set curl to verbose if needed
|
||||
rpcs3::curl::g_curl_verbose = parser.isSet(arg_verbose_curl);
|
||||
|
||||
|
@ -65,6 +65,35 @@ namespace utils
|
||||
return av_error;
|
||||
}
|
||||
|
||||
std::vector<ffmpeg_codec> list_ffmpeg_codecs(bool list_decoders)
|
||||
{
|
||||
std::vector<ffmpeg_codec> codecs;
|
||||
void* opaque = nullptr;
|
||||
for (const AVCodec* codec = av_codec_iterate(&opaque); !!codec; codec = av_codec_iterate(&opaque))
|
||||
{
|
||||
if (list_decoders ? av_codec_is_decoder(codec) : av_codec_is_encoder(codec))
|
||||
{
|
||||
codecs.emplace_back(
|
||||
static_cast<int>(codec->id),
|
||||
codec->name ? codec->name : "unknown",
|
||||
codec->long_name ? codec->long_name : "unknown"
|
||||
);
|
||||
}
|
||||
}
|
||||
std::sort(codecs.begin(), codecs.end(), [](const ffmpeg_codec& l, const ffmpeg_codec& r){ return l.name < r.name; });
|
||||
return codecs;
|
||||
}
|
||||
|
||||
std::vector<ffmpeg_codec> list_ffmpeg_decoders()
|
||||
{
|
||||
return list_ffmpeg_codecs(true);
|
||||
}
|
||||
|
||||
std::vector<ffmpeg_codec> list_ffmpeg_encoders()
|
||||
{
|
||||
return list_ffmpeg_codecs(false);
|
||||
}
|
||||
|
||||
std::pair<bool, media_info> get_media_info(const std::string& path, s32 av_media_type)
|
||||
{
|
||||
media_info info{};
|
||||
@ -721,10 +750,10 @@ namespace utils
|
||||
void* opaque = nullptr;
|
||||
for (const AVCodec* codec = av_codec_iterate(&opaque); !!codec; codec = av_codec_iterate(&opaque))
|
||||
{
|
||||
if (const AVCodec* encoder = avcodec_find_encoder(codec->id); !!encoder)
|
||||
if (av_codec_is_encoder(codec))
|
||||
{
|
||||
media_log.notice("video_encoder: Found video_codec %d = %s", static_cast<int>(used_codec), encoder->name);
|
||||
av_output_format = find_format(encoder);
|
||||
media_log.notice("video_encoder: Found video_codec %d = %s", static_cast<int>(codec->id), codec->name);
|
||||
av_output_format = find_format(codec);
|
||||
|
||||
if (av_output_format)
|
||||
{
|
||||
|
@ -14,6 +14,16 @@ namespace utils
|
||||
{
|
||||
std::string av_error_to_string(int error);
|
||||
|
||||
struct ffmpeg_codec
|
||||
{
|
||||
int codec_id{};
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
};
|
||||
|
||||
std::vector<ffmpeg_codec> list_ffmpeg_decoders();
|
||||
std::vector<ffmpeg_codec> list_ffmpeg_encoders();
|
||||
|
||||
struct media_info
|
||||
{
|
||||
std::string path;
|
||||
|
Loading…
Reference in New Issue
Block a user