| FFmpegKit Linux API 6.0

Loading...
Searching...
No Matches
FFprobeKit.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Taner Sener
3 *
4 * This file is part of FFmpegKit.
5 *
6 * FFmpegKit is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpegKit is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "FFmpegKit.h"
21#include "FFmpegKitConfig.h"
22#include "FFprobeKit.h"
23
24 extern void* ffmpegKitInitialize();
25
26 const void* _ffprobeKitInitializer{ffmpegKitInitialize()};
27
28 static std::list<std::string> defaultGetMediaInformationCommandArguments(const std::string& path) {
29 return std::list<std::string>{"-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-show_chapters", "-i", path};
30}
31
32std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArguments(const std::list<std::string>& arguments) {
33 auto session = ffmpegkit::FFprobeSession::create(arguments);
34 ffmpegkit::FFmpegKitConfig::ffprobeExecute(session);
35 return session;
36}
37
38std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFprobeSessionCompleteCallback completeCallback) {
39 auto session = ffmpegkit::FFprobeSession::create(arguments, completeCallback);
40 ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
41 return session;
42}
43
44std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFprobeSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback) {
45 auto session = ffmpegkit::FFprobeSession::create(arguments, completeCallback, logCallback);
46 ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
47 return session;
48}
49
50std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::execute(const std::string command) {
51 auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()));
52 ffmpegkit::FFmpegKitConfig::ffprobeExecute(session);
53 return session;
54}
55
56std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback) {
57 auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback);
58 ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
59 return session;
60}
61
62std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback){
63 auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback, logCallback);
64 ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
65 return session;
66}
67
68std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformation(const std::string path) {
69 auto arguments = defaultGetMediaInformationCommandArguments(path);
70 auto session = ffmpegkit::MediaInformationSession::create(arguments);
71 ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
72 return session;
73}
74
75std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformation(const std::string path, const int waitTimeout) {
76 auto arguments = defaultGetMediaInformationCommandArguments(path);
77 auto session = ffmpegkit::MediaInformationSession::create(arguments);
78 ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, waitTimeout);
79 return session;
80}
81
82std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback) {
83 auto arguments = defaultGetMediaInformationCommandArguments(path);
84 auto session = ffmpegkit::MediaInformationSession::create(arguments, completeCallback);
85 ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
86 return session;
87}
88
89std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback, const int waitTimeout) {
90 auto arguments = defaultGetMediaInformationCommandArguments(path);
91 auto session = ffmpegkit::MediaInformationSession::create(arguments, completeCallback, logCallback);
92 ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute(session, waitTimeout);
93 return session;
94}
95
96std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationFromCommand(const std::string command) {
97 auto session = ffmpegkit::MediaInformationSession::create(FFmpegKitConfig::parseArguments(command.c_str()));
98 ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
99 return session;
100}
101
102std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::FFprobeSession>>> ffmpegkit::FFprobeKit::listFFprobeSessions() {
103 return ffmpegkit::FFmpegKitConfig::getFFprobeSessions();
104}
105
106std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::MediaInformationSession>>> ffmpegkit::FFprobeKit::listMediaInformationSessions() {
107 return ffmpegkit::FFmpegKitConfig::getMediaInformationSessions();
108}
FFmpegKit.h
logCallback
static ffmpegkit::LogCallback logCallback
Definition FFmpegKitConfig.cpp:69
FFmpegKitConfig.h
defaultGetMediaInformationCommandArguments
static std::list< std::string > defaultGetMediaInformationCommandArguments(const std::string &path)
Definition FFprobeKit.cpp:28
_ffprobeKitInitializer
const void * _ffprobeKitInitializer
Definition FFprobeKit.cpp:26
ffmpegKitInitialize
void * ffmpegKitInitialize()
Definition FFmpegKitConfig.cpp:771
FFprobeKit.h
ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit
static constexpr int DefaultTimeoutForAsynchronousMessagesInTransmit
Definition AbstractSession.h:37
ffmpegkit::FFmpegKitConfig::getMediaInformationSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::MediaInformationSession > > > getMediaInformationSessions()
Definition FFmpegKitConfig.cpp:1308
ffmpegkit::FFmpegKitConfig::getFFprobeSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFprobeSession > > > getFFprobeSessions()
Definition FFmpegKitConfig.cpp:1290
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute
static void asyncFFprobeExecute(const std::shared_ptr< ffmpegkit::FFprobeSession > ffprobeSession)
Definition FFmpegKitConfig.cpp:1088
ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute
static void asyncGetMediaInformationExecute(const std::shared_ptr< ffmpegkit::MediaInformationSession > mediaInformationSession, int waitTimeout)
Definition FFmpegKitConfig.cpp:1116
ffmpegkit::FFmpegKitConfig::getMediaInformationExecute
static void getMediaInformationExecute(const std::shared_ptr< ffmpegkit::MediaInformationSession > mediaInformationSession, const int waitTimeout)
Definition FFmpegKitConfig.cpp:1036
ffmpegkit::FFmpegKitConfig::parseArguments
static std::list< std::string > parseArguments(const std::string &command)
Definition FFmpegKitConfig.cpp:1366
ffmpegkit::FFmpegKitConfig::ffprobeExecute
static void ffprobeExecute(const std::shared_ptr< ffmpegkit::FFprobeSession > ffprobeSession)
Definition FFmpegKitConfig.cpp:1024
ffmpegkit::FFprobeKit::listMediaInformationSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::MediaInformationSession > > > listMediaInformationSessions()
Definition FFprobeKit.cpp:106
ffmpegkit::FFprobeKit::getMediaInformation
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformation(const std::string path)
Definition FFprobeKit.cpp:68
ffmpegkit::FFprobeKit::executeWithArgumentsAsync
static std::shared_ptr< ffmpegkit::FFprobeSession > executeWithArgumentsAsync(const std::list< std::string > &arguments, FFprobeSessionCompleteCallback completeCallback)
Definition FFprobeKit.cpp:38
ffmpegkit::FFprobeKit::getMediaInformationFromCommand
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformationFromCommand(const std::string command)
Definition FFprobeKit.cpp:96
ffmpegkit::FFprobeKit::executeAsync
static std::shared_ptr< ffmpegkit::FFprobeSession > executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback)
Definition FFprobeKit.cpp:56
ffmpegkit::FFprobeKit::executeWithArguments
static std::shared_ptr< ffmpegkit::FFprobeSession > executeWithArguments(const std::list< std::string > &arguments)
Definition FFprobeKit.cpp:32
ffmpegkit::FFprobeKit::listFFprobeSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFprobeSession > > > listFFprobeSessions()
Definition FFprobeKit.cpp:102
ffmpegkit::FFprobeKit::execute
static std::shared_ptr< ffmpegkit::FFprobeSession > execute(const std::string command)
Definition FFprobeKit.cpp:50
ffmpegkit::FFprobeKit::getMediaInformationAsync
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback)
Definition FFprobeKit.cpp:82
ffmpegkit::FFprobeSession::create
static std::shared_ptr< ffmpegkit::FFprobeSession > create(const std::list< std::string > &arguments)
Definition FFprobeSession.cpp:26
ffmpegkit::MediaInformationSession::create
static std::shared_ptr< ffmpegkit::MediaInformationSession > create(const std::list< std::string > &arguments)
Definition MediaInformationSession.cpp:26
ffmpegkit::MediaInformationSessionCompleteCallback
std::function< void(const std::shared_ptr< ffmpegkit::MediaInformationSession > session)> MediaInformationSessionCompleteCallback
Definition MediaInformationSessionCompleteCallback.h:53
ffmpegkit::LogCallback
std::function< void(const std::shared_ptr< ffmpegkit::Log > log)> LogCallback
Definition LogCallback.h:35
ffmpegkit::FFprobeSessionCompleteCallback
std::function< void(const std::shared_ptr< ffmpegkit::FFprobeSession > session)> FFprobeSessionCompleteCallback
Definition FFprobeSessionCompleteCallback.h:52