From 5d999a9c97b986ff513aa6df71719914a41cb3eb Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 20 Feb 2022 04:14:55 +0100 Subject: Fix video thumbnail not maintaining aspect ratio --- src/FileAnalyzer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/FileAnalyzer.cpp b/src/FileAnalyzer.cpp index 2ce8250..5b67b8d 100644 --- a/src/FileAnalyzer.cpp +++ b/src/FileAnalyzer.cpp @@ -136,10 +136,10 @@ namespace QuickMedia { snprintf(middle_seconds_str, sizeof(middle_seconds_str), "%d", middle_seconds); if(width > 0 && height > 0) { - char framesize[128]; - snprintf(framesize, sizeof(framesize), "%dx%d", width, height); + char size_arg_str[512]; + snprintf(size_arg_str, sizeof(size_arg_str), "scale=%d:%d:force_original_aspect_ratio=decrease", width, height); - const char *program_args[] = { "ffmpeg", "-y", "-v", "quiet", "-ss", middle_seconds_str, "-i", file.get_filepath().c_str(), "-vframes", "1", "-s", framesize, "--", destination_path_tmp.data.c_str(), nullptr }; + const char *program_args[] = { "ffmpeg", "-y", "-v", "quiet", "-ss", middle_seconds_str, "-i", file.get_filepath().c_str(), "-vframes", "1", "-vf", size_arg_str, "--", destination_path_tmp.data.c_str(), nullptr }; if(exec_program(program_args, nullptr, nullptr) != 0) { fprintf(stderr, "Failed to execute ffmpeg, maybe its not installed?\n"); return false; -- cgit v1.2.3