RaidenVideoRipper
/
videoprocessor.cpp
48 строк · 996.0 Байт
1#include "videoprocessor.h"
2
3extern "C" {
4#include <dullahan_ffmpeg.h>
5}
6
7#include <QDebug>
8
9VideoProcessor::VideoProcessor(
10const int startPosition,
11const int endPosition,
12const QString& videoPath,
13const QString& outputVideoPath
14)
15: startPosition(startPosition),
16endPosition(endPosition),
17videoPath(videoPath),
18outputVideoPath(outputVideoPath)
19{
20}
21
22void VideoProcessor::cancel()
23{
24dullahan_ffmpeg_cancel();
25}
26
27void VideoProcessor::run()
28{
29auto arguments = std::vector<std::string> {
30"ffmpeg",
31"-y",
32"-i",
33videoPath.toStdString(),
34"-ss",
35std::to_string(startPosition) + "ms",
36"-to",
37std::to_string(endPosition) + "ms",
38outputVideoPath.toStdString()
39};
40
41std::vector<char*> argv;
42for (const auto& arg : arguments) {
43argv.push_back(const_cast<char*>(arg.c_str()));
44}
45
46auto result = dullahan_ffmpeg_main(argv.size(), argv.data());
47emit videoProcessingDidFinish(result);
48}
49