Skip to content

Commit

Permalink
feat: add convert.c
Browse files Browse the repository at this point in the history
  • Loading branch information
WillowSauceR authored and WillowSauceR committed Sep 14, 2023
1 parent c276eba commit 966a012
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.21)

project(MediaPlayer)
project(convert)

set(CMAKE_C_STANDARD 17)
set(CMAKE_BUILD_TYPE Debug)
Expand Down Expand Up @@ -43,6 +44,8 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT

add_library(MediaPlayer SHARED ${SRC_FILES_DIR})

add_executable(convert ${PROJECT_SOURCE_DIR}/tools/convert.c)

set_target_properties(MediaPlayer PROPERTIES OUTPUT_NAME "MediaPlayer")

target_link_libraries(MediaPlayer
Expand Down
32 changes: 32 additions & 0 deletions tools/convert.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
int width, height, rate;
char cmd[256];

printf("Height(7): ");
scanf("%d", &height);

printf("Width(4): ");
scanf("%d", &width);

printf("Rate(1000): ");
scanf("%d", &rate);

int x = width * 128;
int y = height * 128;

system("mkdir output");
remove("output.mp4");
snprintf(cmd, sizeof(cmd), "ffmpeg.exe -i input.mp4 -r 20 -vf scale=%d:%d -b:v %dk -c:v libx264 -preset medium -c:a aac output.mp4", x, y, rate);
system(cmd);

snprintf(cmd, sizeof(cmd), "ffmpeg.exe -i output.mp4 -vf fps=20,scale=%d:%d:flags=lanczos,pad=%d:%d:(ow-iw)/2:(oh-ih)/2:color=black,format=rgba output/%%09d.png", x, y, x, y);
system(cmd);
system("pause");

return 0;
}

0 comments on commit 966a012

Please sign in to comment.