Hi, I would like to know how I get the duration of a video on django. I will show you what I have so they know what I have tried
I've tried using these examples: link
but you can not because those codes receive the name of the file as a string and if the file is in another directory you should also pass it all together: ../ example / hello.mp4
as it seems the files before being saved are saved temporarily I have the path and the name of the file but nothing happens, I do not know what to try
def clean_archivo_video(self):
file_f = self.cleaned_data['archivo_video']
mime = magic.from_buffer(file_f.read(), mime=True)
if mime != 'video/mp4':
raise forms.ValidationError('Sube un archivo de MP4.')
ff = UploadedFile(file_f)
yy = ff._get_name()
fff = TemporaryUploadedFile(ff._get_name(), ff.content_type, ff.size, ff.charset)
uu = fff.temporary_file_path()
www = str(uu+'/'+yy)
print www
video_file_path = www
print duration(video_file_path)
return file_f
with the above code I get the name of the file (not the one that I will save in the database but with the one that is saved in the temporary directory) and the place where the file is located but nothing happens.
Try the other solutions for the other answers but none works on django, except django works perfectly. Out of django I pass the name of the file as a string as a parameter and it works well the problem is that it does not work inside django.