mirror of
https://github.com/tkmxqrdxddd/davinci-video-converter
synced 2025-11-09 02:55:04 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64cde37777 | ||
|
|
0b8b922e5d | ||
|
|
f46e7b4465 | ||
|
|
32ab30b370 | ||
|
|
7dcf7200ca | ||
|
|
c4918446b9 | ||
|
|
a5cda7e500 | ||
|
|
b4c0399399 | ||
|
|
ba28ea0c9b |
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@@ -15,12 +15,19 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt-get install -y build-essential ffmpeg
|
run: sudo apt-get install -y build-essential ffmpeg wget
|
||||||
|
|
||||||
|
- name: Create Tests Directory
|
||||||
|
run: mkdir -p tests # Create the tests directory if it doesn't exist
|
||||||
|
|
||||||
|
- name: Download Sample Video
|
||||||
|
run: wget -O tests/sample_video.mp4 https://www.pexels.com/video/3195394/download/
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make
|
run: |
|
||||||
|
g++ -o davinci-convert src/main.cpp -lstdc++fs
|
||||||
|
|
||||||
- name: Run
|
- name: Run
|
||||||
run: |
|
run: |
|
||||||
echo "Running the Video Converter..."
|
echo "Running the Video Converter..."
|
||||||
./output/davinci-convert
|
./davinci-convert tests/sample_video.mp4 --output tests/output/video.mov
|
||||||
|
|||||||
14
Makefile
14
Makefile
@@ -3,25 +3,25 @@
|
|||||||
# 'make clean' removes all .o and executable files
|
# 'make clean' removes all .o and executable files
|
||||||
#
|
#
|
||||||
|
|
||||||
# define the Cpp compiler to use
|
# Define the C++ compiler to use
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
||||||
# define any compile-time flags
|
# Define any compile-time flags
|
||||||
CXXFLAGS = -std=c++17 -Wall -Wextra -g
|
CXXFLAGS = -std=c++17 -Wall -Wextra -g
|
||||||
|
|
||||||
# define output directory
|
# Define output directory
|
||||||
OUTPUT = output
|
OUTPUT = output
|
||||||
|
|
||||||
# define source directory
|
# Define source directory
|
||||||
SRC = src
|
SRC = src
|
||||||
|
|
||||||
# define the main executable name
|
# Define the main executable name
|
||||||
MAIN = davinci-convert
|
MAIN = davinci-convert
|
||||||
|
|
||||||
# define the C source files
|
# Define the C source files
|
||||||
SOURCES = $(wildcard $(SRC)/*.cpp)
|
SOURCES = $(wildcard $(SRC)/*.cpp)
|
||||||
|
|
||||||
# define the C object files
|
# Define the C object files
|
||||||
OBJECTS = $(SOURCES:.cpp=.o)
|
OBJECTS = $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
OUTPUTMAIN = $(OUTPUT)/$(MAIN)
|
OUTPUTMAIN = $(OUTPUT)/$(MAIN)
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ Before building and running the application, ensure you have the following insta
|
|||||||
|
|
||||||
1. Clone the repository:
|
1. Clone the repository:
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/tkmxqrdxddd/DavinciVideoConverter.git
|
git clone (https://github.com/tkmxqrdxddd/davinci-video-converter)
|
||||||
cd DavinciVideoConverter
|
cd davinci-video-converter
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Run the build script to install dependencies and build the project:
|
2. Run the build script to install dependencies and build the project:
|
||||||
|
|||||||
6
build.sh
6
build.sh
@@ -26,7 +26,7 @@ install_redhat_dependencies() {
|
|||||||
# Function to install dependencies for Arch Linux
|
# Function to install dependencies for Arch Linux
|
||||||
install_arch_dependencies() {
|
install_arch_dependencies() {
|
||||||
echo "Installing dependencies for Arch Linux..."
|
echo "Installing dependencies for Arch Linux..."
|
||||||
sudo pacman -Syu --noconfirm base-devel ffmpeg || {
|
sudo pacman -S --noconfirm base-devel ffmpeg || {
|
||||||
echo "Failed to install dependencies for Arch Linux."
|
echo "Failed to install dependencies for Arch Linux."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ fi
|
|||||||
|
|
||||||
# Install the application
|
# Install the application
|
||||||
echo "Installing the application..."
|
echo "Installing the application..."
|
||||||
sudo make install
|
make install
|
||||||
|
|
||||||
# Inform the user about the executable
|
# Inform the user about the executable
|
||||||
echo "You can run the application using davinci-convert"
|
echo "You can run the application using 'davinci-convert'"
|
||||||
|
|||||||
74
src/main.cpp
74
src/main.cpp
@@ -2,30 +2,45 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
class VideoConverter {
|
class VideoConverter {
|
||||||
private:
|
|
||||||
bool conversionInProgress;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoConverter() : conversionInProgress(false) {}
|
void startConversion(const std::string &inputFile, const std::string &outputFile);
|
||||||
|
|
||||||
void startConversion(const std::string &inputFile, const std::string &outputFile) {
|
private:
|
||||||
|
bool conversionInProgress = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
void VideoConverter::startConversion(const std::string &inputFile, const std::string &outputFile) {
|
||||||
if (conversionInProgress) {
|
if (conversionInProgress) {
|
||||||
std::cerr << "Error: Conversion already in progress." << std::endl;
|
std::cerr << "Error: Conversion already in progress." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputFile.empty() || outputFile.empty()) {
|
if (inputFile.empty()) {
|
||||||
std::cerr << "Error: Please enter both input and output file names." << std::endl;
|
std::cerr << "Error: Please provide an input file name." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine the output path
|
||||||
|
std::filesystem::path outputPath;
|
||||||
|
if (outputFile.empty()) {
|
||||||
|
// If no output file is specified, create one in the current directory
|
||||||
|
outputPath = std::filesystem::current_path() / (std::filesystem::path(inputFile).stem().string() + ".mov");
|
||||||
|
} else {
|
||||||
|
outputPath = std::filesystem::path(outputFile);
|
||||||
|
if (outputPath.extension() != ".mov") {
|
||||||
|
outputPath += ".mov";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conversionInProgress = true;
|
conversionInProgress = true;
|
||||||
std::cout << "Starting conversion..." << std::endl;
|
std::cout << "Starting conversion..." << std::endl;
|
||||||
|
|
||||||
std::thread conversionThread([this, inputFile, outputFile]() {
|
std::thread([this, inputFile, outputPath]() {
|
||||||
std::string command = "ffmpeg -i \"" + inputFile + "\" -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a alac \"" + outputFile + "\"";
|
std::string command = "ffmpeg -i \"" + inputFile + "\" -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a alac \"" + outputPath.string() + "\" 2> /dev/null";
|
||||||
int result = std::system(command.c_str());
|
int result = std::system(command.c_str());
|
||||||
conversionInProgress = false;
|
conversionInProgress = false;
|
||||||
|
|
||||||
@@ -34,21 +49,42 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
std::cerr << "Error: Conversion failed with exit code " << result << std::endl;
|
std::cerr << "Error: Conversion failed with exit code " << result << std::endl;
|
||||||
}
|
}
|
||||||
});
|
}).detach();
|
||||||
|
}
|
||||||
|
|
||||||
conversionThread.detach(); // Detach the thread to allow it to run independently
|
void printHelp() {
|
||||||
}
|
std::cout << "Usage: davinci-convert /path/to/video [--output /path/to/output/folder]\n";
|
||||||
};
|
std::cout << "Options:\n";
|
||||||
|
std::cout << " /path/to/video Path to the input video file.\n";
|
||||||
|
std::cout << " --output /path/to/output/folder Path to the output video file (optional).\n";
|
||||||
|
std::cout << " --help Show this help message.\n";
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char *argv[]) {
|
||||||
VideoConverter converter;
|
VideoConverter converter;
|
||||||
std::string inputFile, outputFile;
|
std::string inputFile, outputFile;
|
||||||
|
|
||||||
std::cout << "Welcome to the Video Converter!" << std::endl;
|
if (argc < 2) {
|
||||||
std::cout << "Enter the input file path: ";
|
printHelp();
|
||||||
std::getline(std::cin, inputFile);
|
return 1;
|
||||||
std::cout << "Enter the output file path: ";
|
}
|
||||||
std::getline(std::cin, outputFile);
|
|
||||||
|
// The first argument is the input file
|
||||||
|
inputFile = argv[1];
|
||||||
|
|
||||||
|
// Parse the remaining arguments
|
||||||
|
for (int i = 2; i < argc; i++) {
|
||||||
|
if (std::strcmp(argv[i], "--output") == 0 && i + 1 < argc) {
|
||||||
|
outputFile = argv[++i];
|
||||||
|
} else if (std::strcmp(argv[i], "--help") == 0) {
|
||||||
|
printHelp();
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
std::cerr << "Unknown option: " << argv[i] << std::endl;
|
||||||
|
printHelp();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
converter.startConversion(inputFile, outputFile);
|
converter.startConversion(inputFile, outputFile);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user