From 863cf1111e8b4c837e74280bcc5b2881f1fdacce Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 5 Jun 2019 10:33:29 +0200 Subject: [PATCH] Added option to list available pixfmts --- src/host.cpp | 13 +++++++++++++ src/host.h | 1 + src/main.cpp | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/host.cpp b/src/host.cpp index d54884edb..b245da6d3 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -39,6 +39,7 @@ #include #endif +using rang::style; using namespace std; unsigned int audio_capture_channels = DEFAULT_AUDIO_CAPTURE_CHANNELS; @@ -388,6 +389,18 @@ void print_param_doc() } } +void print_pixel_formats(void) { + for (codec_t c = static_cast(1); c != VIDEO_CODEC_COUNT; c = static_cast(static_cast(c) + 1)) { + char tag; + if (is_codec_opaque(c)) { + continue; + } + + tag = codec_is_a_rgb(c) ? 'R' : 'Y'; + cout << " " << style::bold << left << setw(12) << get_codec_name(c) << style::reset << setw(0) << " " << tag << " " << setw(2) << get_bits_per_component(c) << setw(0) << " " << get_codec_name_long(c) << "\n"; + } +} + bool register_mainloop(mainloop_t m, void *u) { if (mainloop) { diff --git a/src/host.h b/src/host.h index 9acb74b50..ef3a78b9a 100644 --- a/src/host.h +++ b/src/host.h @@ -144,6 +144,7 @@ bool set_output_buffering(); void register_param(const char *param, const char *doc); bool validate_param(const char *param); void print_param_doc(void); +void print_pixel_formats(void); bool register_mainloop(mainloop_t, void *); diff --git a/src/main.cpp b/src/main.cpp index 73163079e..9575bb9b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,6 +123,7 @@ static constexpr const char *DEFAULT_AUDIO_CODEC = "PCM"; #define OPT_LIST_MODULES (('L' << 8) | 'M') #define OPT_MCAST_IF (('M' << 8) | 'I') #define OPT_PARAM (('O' << 8) | 'P') +#define OPT_PIX_FMTS (('P' << 8) | 'F') #define OPT_PROTOCOL (('P' << 8) | 'R') #define OPT_START_PAUSED (('S' << 8) | 'P') #define OPT_VERBOSE (('V' << 8) | 'E') @@ -347,10 +348,10 @@ static void usage(const char *exec_path, bool full = false) printf("\t--capture-filter | help\n"); printf("\t \tcapture filter(s), must be given before capture device\n"); printf("\n"); - } - if (full) { printf("\t--param | help \tadditional advanced parameters, use help for list\n"); printf("\n"); + printf("\t--pix-fmts \tlist of pixel formats\n"); + printf("\n"); } printf("\taddress \tdestination address\n"); printf("\n"); @@ -588,6 +589,7 @@ int main(int argc, char *argv[]) {"protocol", required_argument, 0, OPT_PROTOCOL}, {"rtsp-server", optional_argument, 0, 'H'}, {"param", required_argument, 0, OPT_PARAM}, + {"pix-fmts", no_argument, 0, OPT_PIX_FMTS}, {0, 0, 0, 0} }; const char optstring[] = "d:t:m:r:s:v46c:hM:p:f:P:l:A:"; @@ -927,6 +929,9 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } break; + case OPT_PIX_FMTS: + print_pixel_formats(); + return EXIT_SUCCESS; case '?': default: usage(uv_argv[0]);