aboutsummaryrefslogtreecommitdiff
path: root/src/FileAnalyzer.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-30 16:33:07 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-30 16:33:07 +0200
commit47bb22a4aee886deb54ca432bdb14747bf2e9160 (patch)
tree57f4cff63872f70b6d60bf098cb46879bccc3251 /src/FileAnalyzer.cpp
parentc89ffb842054de24e2ad8020d9df81da55e3e574 (diff)
Support webp thumbnails
Diffstat (limited to 'src/FileAnalyzer.cpp')
-rw-r--r--src/FileAnalyzer.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/FileAnalyzer.cpp b/src/FileAnalyzer.cpp
index 9f05919..bd13a01 100644
--- a/src/FileAnalyzer.cpp
+++ b/src/FileAnalyzer.cpp
@@ -21,7 +21,7 @@ namespace QuickMedia {
// What about audio ogg files that are not opus?
// TODO: Test all of these
- static const std::array<MagicNumber, 25> magic_numbers = {
+ static const std::array<MagicNumber, 26> magic_numbers = {
MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'A', 'V', 'I', ' '}, 12, ContentType::VIDEO_AVI },
MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'i', 's', 'o', 'm'}, 12, ContentType::VIDEO_MP4 },
MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'}, 12, ContentType::VIDEO_MP4 },
@@ -47,7 +47,8 @@ namespace QuickMedia {
MagicNumber{ {'G', 'I', 'F', '8', '7', 'a'}, 6, ContentType::IMAGE_GIF },
MagicNumber{ {'G', 'I', 'F', '8', '9', 'a'}, 6, ContentType::IMAGE_GIF },
MagicNumber{ {'B', 'M'}, 2, ContentType::IMAGE_BMP },
- MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'W', 'E', 'B', 'V', 'P'}, 6, ContentType::IMAGE_WEBP }
+ MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'W', 'E', 'B', 'P'}, 12, ContentType::IMAGE_WEBP },
+ MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'W', 'E', 'B', 'V', 'P'}, 13, ContentType::IMAGE_WEBP }
};
bool is_content_type_video(ContentType content_type) {
@@ -121,7 +122,7 @@ namespace QuickMedia {
Path destination_path_tmp = destination_path;
destination_path_tmp.append(".ftmp");
- const char *program_args[] = { "ffmpeg", "-y", "-v", "quiet", "-i", filepath, "-vframes", "1", "-f", "singlejpeg", destination_path_tmp.data.c_str(), nullptr };
+ const char *program_args[] = { "ffmpeg", "-y", "-v", "quiet", "-i", filepath, "-vframes", "1", "-f", "singlejpeg", "--", destination_path_tmp.data.c_str(), nullptr };
std::string ffmpeg_result;
if(exec_program(program_args, nullptr, nullptr) != 0) {
fprintf(stderr, "Failed to execute ffmpeg, maybe its not installed?\n");
@@ -129,7 +130,8 @@ namespace QuickMedia {
}
if(width > 0 && height > 0) {
- if(create_thumbnail(destination_path_tmp, destination_path, sf::Vector2i(width, height))) {
+ FileAnalyzer file_analyzer;
+ if(file_analyzer.load_file(destination_path_tmp.data.c_str(), false) && create_thumbnail(destination_path_tmp, destination_path, sf::Vector2i(width, height), file_analyzer.get_content_type())) {
remove(destination_path_tmp.data.c_str());
return true;
}