# FFmpegKit Linux API: FFprobeKit.cpp Source File

FFprobeKit.cpp
Go to the documentation of this file.
/*
* Copyright (c) 2022 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
#include "fftools_ffmpeg.h"
#include "FFmpegKit.h"
#include "FFmpegKitConfig.h"
#include "FFprobeKit.h"
extern void* ffmpegKitInitialize();
const void* _ffprobeKitInitializer{ffmpegKitInitialize()};
static std::list<std::string> defaultGetMediaInformationCommandArguments(const std::string& path) {
return std::list<std::string>{"-v", "error", "-hide_banner", "-print_format", "json", "-show_format", "-show_streams", "-show_chapters", "-i", path};
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArguments(const std::list<std::string>& arguments) {
auto session = ffmpegkit::FFprobeSession::create(arguments);
ffmpegkit::FFmpegKitConfig::ffprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFprobeSessionCompleteCallback completeCallback) {
auto session = ffmpegkit::FFprobeSession::create(arguments, completeCallback);
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeWithArgumentsAsync(const std::list<std::string>& arguments, FFprobeSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback) {
auto session = ffmpegkit::FFprobeSession::create(arguments, completeCallback, logCallback);
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::execute(const std::string command) {
auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()));
ffmpegkit::FFmpegKitConfig::ffprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback) {
auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback);
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::FFprobeSession> ffmpegkit::FFprobeKit::executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback){
auto session = ffmpegkit::FFprobeSession::create(FFmpegKitConfig::parseArguments(command.c_str()), completeCallback, logCallback);
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute(session);
return session;
}
std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformation(const std::string path) {
auto arguments = defaultGetMediaInformationCommandArguments(path);
auto session = ffmpegkit::MediaInformationSession::create(arguments);
ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
return session;
}
std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformation(const std::string path, const int waitTimeout) {
auto arguments = defaultGetMediaInformationCommandArguments(path);
auto session = ffmpegkit::MediaInformationSession::create(arguments);
ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, waitTimeout);
return session;
}
std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback) {
auto arguments = defaultGetMediaInformationCommandArguments(path);
auto session = ffmpegkit::MediaInformationSession::create(arguments, completeCallback);
ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
return session;
}
std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback, ffmpegkit::LogCallback logCallback, const int waitTimeout) {
auto arguments = defaultGetMediaInformationCommandArguments(path);
auto session = ffmpegkit::MediaInformationSession::create(arguments, completeCallback, logCallback);
ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute(session, waitTimeout);
return session;
}
std::shared_ptr<ffmpegkit::MediaInformationSession> ffmpegkit::FFprobeKit::getMediaInformationFromCommand(const std::string command) {
auto session = ffmpegkit::MediaInformationSession::create(FFmpegKitConfig::parseArguments(command.c_str()));
ffmpegkit::FFmpegKitConfig::getMediaInformationExecute(session, ffmpegkit::AbstractSession::DefaultTimeoutForAsynchronousMessagesInTransmit);
return session;
}
std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::FFprobeSession>>> ffmpegkit::FFprobeKit::listFFprobeSessions() {
return ffmpegkit::FFmpegKitConfig::getFFprobeSessions();
}
std::shared_ptr<std::list<std::shared_ptr<ffmpegkit::MediaInformationSession>>> ffmpegkit::FFprobeKit::listMediaInformationSessions() {
return ffmpegkit::FFmpegKitConfig::getMediaInformationSessions();
}
FFmpegKit.h
logCallback
static ffmpegkit::LogCallback logCallback
Definition: FFmpegKitConfig.cpp:64
FFmpegKitConfig.h
defaultGetMediaInformationCommandArguments
static std::list< std::string > defaultGetMediaInformationCommandArguments(const std::string &path)
Definition: FFprobeKit.cpp:29
_ffprobeKitInitializer
const void * _ffprobeKitInitializer
Definition: FFprobeKit.cpp:27
ffmpegKitInitialize
void * ffmpegKitInitialize()
Definition: FFmpegKitConfig.cpp:766
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:1303
ffmpegkit::FFmpegKitConfig::getFFprobeSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFprobeSession > > > getFFprobeSessions()
Definition: FFmpegKitConfig.cpp:1285
ffmpegkit::FFmpegKitConfig::asyncFFprobeExecute
static void asyncFFprobeExecute(const std::shared_ptr< ffmpegkit::FFprobeSession > ffprobeSession)
Definition: FFmpegKitConfig.cpp:1083
ffmpegkit::FFmpegKitConfig::asyncGetMediaInformationExecute
static void asyncGetMediaInformationExecute(const std::shared_ptr< ffmpegkit::MediaInformationSession > mediaInformationSession, int waitTimeout)
Definition: FFmpegKitConfig.cpp:1111
ffmpegkit::FFmpegKitConfig::getMediaInformationExecute
static void getMediaInformationExecute(const std::shared_ptr< ffmpegkit::MediaInformationSession > mediaInformationSession, const int waitTimeout)
Definition: FFmpegKitConfig.cpp:1031
ffmpegkit::FFmpegKitConfig::parseArguments
static std::list< std::string > parseArguments(const std::string &command)
Definition: FFmpegKitConfig.cpp:1361
ffmpegkit::FFmpegKitConfig::ffprobeExecute
static void ffprobeExecute(const std::shared_ptr< ffmpegkit::FFprobeSession > ffprobeSession)
Definition: FFmpegKitConfig.cpp:1019
ffmpegkit::FFprobeKit::listMediaInformationSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::MediaInformationSession > > > listMediaInformationSessions()
Definition: FFprobeKit.cpp:107
ffmpegkit::FFprobeKit::getMediaInformation
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformation(const std::string path)
Definition: FFprobeKit.cpp:69
ffmpegkit::FFprobeKit::executeWithArgumentsAsync
static std::shared_ptr< ffmpegkit::FFprobeSession > executeWithArgumentsAsync(const std::list< std::string > &arguments, FFprobeSessionCompleteCallback completeCallback)
Definition: FFprobeKit.cpp:39
ffmpegkit::FFprobeKit::getMediaInformationFromCommand
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformationFromCommand(const std::string command)
Definition: FFprobeKit.cpp:97
ffmpegkit::FFprobeKit::executeAsync
static std::shared_ptr< ffmpegkit::FFprobeSession > executeAsync(const std::string command, FFprobeSessionCompleteCallback completeCallback)
Definition: FFprobeKit.cpp:57
ffmpegkit::FFprobeKit::executeWithArguments
static std::shared_ptr< ffmpegkit::FFprobeSession > executeWithArguments(const std::list< std::string > &arguments)
Definition: FFprobeKit.cpp:33
ffmpegkit::FFprobeKit::listFFprobeSessions
static std::shared_ptr< std::list< std::shared_ptr< ffmpegkit::FFprobeSession > > > listFFprobeSessions()
Definition: FFprobeKit.cpp:103
ffmpegkit::FFprobeKit::execute
static std::shared_ptr< ffmpegkit::FFprobeSession > execute(const std::string command)
Definition: FFprobeKit.cpp:51
ffmpegkit::FFprobeKit::getMediaInformationAsync
static std::shared_ptr< ffmpegkit::MediaInformationSession > getMediaInformationAsync(const std::string path, MediaInformationSessionCompleteCallback completeCallback)
Definition: FFprobeKit.cpp:83
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
fftools_ffmpeg.h
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