Search code examples
pythondockerubuntuubuntu-20.04moviepy

I can't concatenate mkv clips on Ubuntu 20.04 with MoviePy


I'm on a Docker container with Ubuntu 20.04 and I want to concatenate a set of videoclips from a mkv file with MoviePy

This is my code:

combinated_video = concatenate_videoclips(clips)

video_name, extension = os.path.splitext(self.video_path)
combinated_video_path = video_name + "_combinated" + extension

combinated_video.write_videofile(combinated_video_path, codec="libx264", audio_codec="mp3")

clips is a list like this:

[<moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f07eff86400>, <moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f07eff86670>, <moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f07eff86940>, <moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f07eff86c10>, <moviepy.video.io.VideoFileClip.VideoFileClip object at 0x7f07eff86100>]

I tried it on my local machine with Windows 11 and it worked, but it doesn't on Ubuntu 20.04

This is the error i get:

MoviePy couldn't find the codec associated with the filename. Provide the 'codec' parameter in write_videofile.

This is the Dockerfile used:

# syntax=docker/dockerfile:1

FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04

ENV TZ=Europe/Madrid
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y \
    python3.8 \
    python3-pip \
    python3-dev \
    ffmpeg \
    libsm6 \
    libxext6

RUN echo 'alias [python](https://saturncloud.io/glossary/python)="python3" ' >> ~/.bashrc
RUN echo 'alias pip="pip3" ' >> ~/.bashrc

WORKDIR /app

COPY requirements.txt .
COPY app.py .

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5555

CMD ["python3", "app.py"]

Solution

  • The problem was the decorator library version. I have changed the version of that library to 4.4.2 and it works.

    pip install --upgrade decorator==4.4.2