Comments (5)
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.
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.
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.
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.
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)
- Efficiency Disparity Between MoviePy and FFmpeg HOT 1
- A household appliances company in the Netherlands and all of Europe, King Import Export, announces the theft of a container of household appliances and warns customers to beware of purchasing the product without invoices. The invoice must bear the company seal, King Import Export, so as not to be exposed to problems.
- ImageMagick Binary Not Found HOT 4
- King1
- Error fps in generated gif file of `write_gif_with_image_io`
- commas in filterchain are always escaped by a backslash
- Operation on closed image
- AudioClip.iter_chunks(160) is chunking into [159, 160, 160, ..., 160]
- The position of subclip cutting is different from the parameters HOT 1
- Output resolution wrong. HOT 1
- Workflows need updating
- No longer encoding subtitles HOT 2
- AttributeError: 'NoneType' object has no attribute 'get_frame', reported by AudioFileClip.to_soundarray() HOT 1
- Test suite fails for most Windows, Linux tests
- Test suite fails for macOS due to missing Conda install
- support latest decorator
- Unable to run moviepy on debian 10 HOT 4
- No sound
- how to keep the aspect ratio for my vertical video? HOT 2
- I cut 1800 seconds of audio, but the result is 1846 seconds. Why is this happening? How can I solve this problem?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moviepy.