|
@@ -2,7 +2,6 @@
|
|
|
import subprocess
|
|
|
import time
|
|
|
|
|
|
-from common import Common
|
|
|
|
|
|
|
|
|
class FFmpeg():
|
|
@@ -76,12 +75,17 @@ class FFmpeg():
|
|
|
"""
|
|
|
@classmethod
|
|
|
def get_w_h_size(cls, new_video_path):
|
|
|
- # 获取视频的原始宽高信息
|
|
|
- ffprobe_cmd = f"ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 {new_video_path}"
|
|
|
- ffprobe_process = subprocess.Popen(ffprobe_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
- output, _ = ffprobe_process.communicate()
|
|
|
- height, width = map(int, output.decode().strip().split(','))
|
|
|
- return width, height
|
|
|
+ try:
|
|
|
+ # 获取视频的原始宽高信息
|
|
|
+ ffprobe_cmd = f"ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 {new_video_path}"
|
|
|
+ ffprobe_process = subprocess.Popen(ffprobe_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
|
+ output, _ = ffprobe_process.communicate()
|
|
|
+ output_decoded = output.decode().strip()
|
|
|
+ split_output = [value for value in output_decoded.split(',') if value.strip()]
|
|
|
+ height, width = map(int, split_output)
|
|
|
+ return width, height
|
|
|
+ except ValueError as e:
|
|
|
+ return 1920, 1080
|
|
|
|
|
|
"""
|
|
|
视频裁剪
|
|
@@ -228,7 +232,6 @@ class FFmpeg():
|
|
|
concatenate_videos_url = video_path_url + 'concatenate_videos.mp4'
|
|
|
# 获取视频的原始宽高信息
|
|
|
width, height = cls.get_w_h_size(video_list[0])
|
|
|
- Common.logger("log").info(f"视频宽高{width,height}")
|
|
|
# 拼接视频
|
|
|
VIDEO_COUNTER = 0
|
|
|
FF_INPUT = ""
|