Giter Club home page Giter Club logo

Comments (5)

keikoro avatar keikoro commented on June 4, 2024

Please always include your specs like we ask for in our issue templates – MoviePy version, platform used etc. – to help pinpoint what causes your problem, thanks.

from moviepy.

NiKiTjAOFF avatar NiKiTjAOFF commented on June 4, 2024

Please always include your specs like we ask for in our issue templates – MoviePy version, platform used etc. – to help pinpoint what causes your problem, thanks.

They're already in there

from moviepy.

NiKiTjAOFF avatar NiKiTjAOFF commented on June 4, 2024

After I ran the following code on collab:

from moviepy.editor import *
clip =VideoFileClip("2024-02-25 23-53-31.mp4")
clip.write_gif("2024-02-25 23-53-31.gif")

It gave me this warn:

MoviePy - Building file 2024-02-25 23-53-31.gif with imageio.
t: 100%|█████████▉| 2322/2324 [00:09<00:00, 277.26it/s, now=None]WARNING:py.warnings:/usr/local/lib/python3.10/dist-packages/moviepy/video/io/ffmpeg_reader.py:123: UserWarning: Warning: in file 2024-02-25 23-53-31.mp4, 691200 bytes wanted but 0 bytes read,at frame 2323/2324, at time 38.72/38.72 sec. Using the last valid frame instead.
  warnings.warn("Warning: in file %s, "%(self.filename)+

from moviepy.

NiKiTjAOFF avatar NiKiTjAOFF commented on June 4, 2024

Problem solved. Make sure ffmpeg.exe is in PATH, so that the following code could work.
This code not only converts all the mp4 videos inside of a folder, but also changes the speed of a video, it's fps and res without loosing any quality. Also you can turn on lantzoc filtering.

from moviepy.editor import *
from typing import List
import os

def list_image_files(directory: str) -> List[str]:
    image_extensions = [".mp4"]
    image_files = [f for f in os.listdir(directory) if os.path.splitext(f)[1].lower() in image_extensions]
    return image_files

SOURCE_DIRECTORY_PATH = r"videos"
list = list_image_files(SOURCE_DIRECTORY_PATH)
print(list)
height = "640"
speedX = 0.5
duration = 2
lanczos_is_off = False
for video_name_with_extension in list:
    video_name = video_name_with_extension.split('.')[0]
    video_path = SOURCE_DIRECTORY_PATH + "\\" + video_name_with_extension
    gif_path = SOURCE_DIRECTORY_PATH + "\\" + video_name + ".gif"
    print(video_path)
    print(gif_path)
    video = VideoFileClip(video_path)
    fps = video.duration / duration
    if lanczos_is_off:
        command = f'ffmpeg -i "{video_path}" -vf "fps={fps},setpts={speedX}*PTS,scale={height}:-1" -c:v gif "{gif_path}" -y'
    else :
        command = f'ffmpeg -i "{video_path}" -vf "fps={fps},setpts={speedX}*PTS,scale={height}:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse=dither=none" -c:v gif "{gif_path}" -y'
    os.system(command)

from moviepy.

keikoro avatar keikoro commented on June 4, 2024

They're already in there

Thanks, I didn't see that because I scan for them at the bottom of an issue when I tag it.

Problem solved.

If this means this issue is solved, please don't forget to close it. Thank you.

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.