1

我正在尝试使用moviepy模块在视频上添加徽标此模块在我的PC(windows)上正常工作,但是当我在我购买的远程主机(linux)上运行以下代码时出现错误。

代码 :

import random
import moviepy.editor as mp
import requests


def video_watermark(url):
    corners = [("right", "top"), ("left", "top"), ("right", "bottom"), ("left", "bottom")]
    response = requests.get(url)
    with open("media/videos/raw_video.mp4", "wb") as file:
        file.write(response.content)

    video = mp.VideoFileClip("./media/videos/raw_video.mp4")

    logo = (mp.ImageClip("./media/bold_logo.png")
            .set_duration(video.duration)
            .resize(height=50)  # if you need to resize...
            .margin(right=8, top=8, opacity=0)  # (optional) logo-border padding
            .set_pos(random.choice(corners)))

    final = mp.CompositeVideoClip([video, logo])
    final.write_videofile("./media/videos/ready_video.mp4")

video_watermark("url")

错误 :

OSError: [Errno 32] Broken pipe
 
MoviePy error: FFMPEG encountered the following error while writing
file ./media/videos/ready_video.mp4:
 
b'Error initializing output stream 0:0 -- Error while opening encoder
for output stream #0:0 - maybe incorrect parameters such as bit_rate,
rate, width or height\n'

请帮我解决这个问题

4

0 回答 0