I'm using MoviePy to save a frame from an uploaded video (the specific function in MoviePy is save_frame()
source). This works successfully, however I want the image to save in my media
folder (Django's conventional folder for saving uploaded files). At the moment it saves in the project root (where manage.py
is). There doesn't seem to be a settings
file so I'm not sure how to change this. Any suggestions appreciated.
Asked
Active
Viewed 931 times
0

Zorgan
- 8,227
- 23
- 106
- 207
1 Answers
0
This is the main idea to achieve that, maybe you have to make little adjustments:
# Your target directory
destination_dir = os.path.join(settings.BASE_DIR, 'site_media', 'media', 'video_thumbs')
# Full path to file to open, I took the file path from filefield
origin_file = os.path.join(settings.MEDIA_ROOT, model.filefield.path)
# Get thumbnail
clip = VideoFileClip(origin_file)
# Save thumbnail on target directory
clip.save_frame(os.path.join(destination_dir, "thumbnail.jpg"), t=1.00)

Kevin Ramirez Zavalza
- 1,629
- 1
- 22
- 34