Skip to content

Commit 2379312

Browse files
committed
revert ffmpeg thread, until i found some way better like taskset (package)
Signed-off-by: anasty17 <e.anastayyar@gmail.com>
1 parent 0ad6964 commit 2379312

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

bot/helper/ext_utils/media_utils.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ async def take_ss(video_file, ss_nb) -> bool:
138138
"1",
139139
"-frames:v",
140140
"1",
141+
"-threads",
142+
f"{max(1, cpu_no // 2)}",
141143
output,
142144
]
143145
cap_time += interval
@@ -176,6 +178,8 @@ async def get_audio_thumbnail(audio_file):
176178
"-an",
177179
"-vcodec",
178180
"copy",
181+
"-threads",
182+
f"{max(1, cpu_no // 2)}",
179183
output,
180184
]
181185
try:
@@ -217,6 +221,8 @@ async def get_video_thumbnail(video_file, duration):
217221
"1",
218222
"-frames:v",
219223
"1",
224+
"-threads",
225+
f"{max(1, cpu_no // 2)}",
220226
output,
221227
]
222228
try:
@@ -260,6 +266,8 @@ async def get_multiple_frames_thumbnail(video_file, layout, keep_screenshots):
260266
"1",
261267
"-f",
262268
"mjpeg",
269+
"-threads",
270+
f"{max(1, cpu_no // 2)}",
263271
output,
264272
]
265273
try:
@@ -438,6 +446,8 @@ async def convert_video(self, video_file, ext, retry=False):
438446
"libx264",
439447
"-c:a",
440448
"aac",
449+
"-threads",
450+
f"{max(1, cpu_no // 2)}",
441451
output,
442452
]
443453
if ext == "mp4":
@@ -460,6 +470,8 @@ async def convert_video(self, video_file, ext, retry=False):
460470
"0",
461471
"-c",
462472
"copy",
473+
"-threads",
474+
f"{max(1, cpu_no // 2)}",
463475
output,
464476
]
465477
if self._listener.is_cancelled:
@@ -505,6 +517,8 @@ async def convert_audio(self, audio_file, ext):
505517
"pipe:1",
506518
"-i",
507519
audio_file,
520+
"-threads",
521+
f"{max(1, cpu_no // 2)}",
508522
output,
509523
]
510524
if self._listener.is_cancelled:
@@ -583,6 +597,8 @@ async def sample_video(self, video_file, sample_duration, part_duration):
583597
"libx264",
584598
"-c:a",
585599
"aac",
600+
"-threads",
601+
f"{max(1, cpu_no // 2)}",
586602
output_file,
587603
]
588604

@@ -646,6 +662,8 @@ async def split(self, f_path, file_, parts, split_size):
646662
"-2",
647663
"-c",
648664
"copy",
665+
"-threads",
666+
f"{max(1, cpu_no // 2)}",
649667
out_path,
650668
]
651669
if not multi_streams:

0 commit comments

Comments
 (0)