Skip to content

Commit c51b0a8

Browse files
committed
add ffmpeg/threads configuration in codecs.ini
1 parent 9ccb09d commit c51b0a8

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

config/codecs.ini

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ transcode = libx264 -preset ultrafast -crf 22
66
codec_copy = ac3,aac,mp2
77
transcode = aac
88

9+
[ffmpeg]
10+
threads = 0
11+
912
# codec_copy = ac3,aac.48000,mp2
1013
# transcode = mp2 -b:a 224k
1114

ffmpeghandler.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ bool FFmpegHandler::streamVideo(std::string url, std::string position, std::stri
6666
"ffmpeg", "-hide_banner", "-re", "-y", "-referer", referer, "-user_agent", userAgent, "-headers", "Cookie: " + cookies
6767
};
6868

69+
if (transcodeConfig.threads() > 0) {
70+
callStr.emplace_back("-threads");
71+
callStr.emplace_back(std::to_string(transcodeConfig.threads()));
72+
}
73+
6974
// in case of mpeg-dash ignore the seek command
7075
if (!endsWith(url, ".mpd")) {
7176
callStr.emplace_back("-ss");

transcodeconfig.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ std::vector<std::string> strsplit(std::string input, std::string delimiter) {
1616
}
1717

1818
TranscodeConfig::TranscodeConfig() {
19+
ffmpegThread = 0;
1920
}
2021

2122
bool TranscodeConfig::createConfiguration(mINI::INIStructure ini) {
@@ -58,6 +59,11 @@ bool TranscodeConfig::createConfiguration(mINI::INIStructure ini) {
5859
allowedAudioCodecs.clear();
5960
}
6061

62+
std::string ffmpegThreadStr = ini["ffmpeg"]["threads"];
63+
if (!ffmpegThreadStr.empty()) {
64+
ffmpegThread = std::atoi(ffmpegThreadStr.c_str());
65+
}
66+
6167
return true;
6268
}
6369

transcodeconfig.h

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class TranscodeConfig {
1010
std::vector<std::string> videoTranscodeParameter;
1111
std::vector<std::string> audioTranscodeParameter;
1212

13+
int ffmpegThread;
14+
1315
public:
1416
explicit TranscodeConfig();
1517
~TranscodeConfig() = default;
@@ -19,6 +21,8 @@ class TranscodeConfig {
1921
bool isCopyAudio(std::string codec, std::string sample_rate);
2022
bool isCopyVideo(std::string codec);
2123

24+
int threads() { return ffmpegThread; };
25+
2226
std::vector<std::string> getAudioTranscodeParameter();
2327
std::vector<std::string> getVideoTranscodeParameter();
2428
};

0 commit comments

Comments
 (0)