caching - Django Filename Generation Issue -


i have django based media server accepts variety of video formats upload. while uploading large .wmv file, noticed strange behavior. first time uploaded video, took 5 minutes convert , upload. thereafter, sort of caching occurred, , video merely point 1 had uploaded. don't understand why happening. when video uploaded, file name extension checked conversion purposes, , ffmpeg command executed carry out conversion. run asynchronously, using django-celery rabbitmq message broker. don't see reason why ffmpeg conversion command not execute again. here code celery task handles upload. (this initial reasoning, @ edit correct error diagnosis)

@celery.task def handlefileuploadasync(update, m, file_type, video_types):     filename = m.file.name.replace(' ', '\\ ')     if video_types[file_type] == 'wmv':         os.system(             "ffmpeg -i " + media_root + filename + " -strict experimental -vcodec libx264    -profile:v baseline " + media_root + filename.replace(video_types[file_type],'mp4')     )         m.file.name = m.file.name.replace(video_types[file_type], 'mp4')         m.save()          os.remove(m.file.path.replace('mp4', 'wmv'))     elif file_type in video_types.keys():         os.system(          "ffmpeg -i " + media_root + filename + " -vcodec libx264 -profile:v baseline -s 672x576 " + media_root + filename.replace(video_types[file_type],'mp4')         )         m.file.name = m.file.name.replace(video_types[file_type], 'mp4')         m.save()         if video_types[file_type] != 'mp4':             os.remove(m.file.path.replace('mp4', video_types[file_type]))  

edit:

here's problem. when convert videos, want converted .mp4 file, not original upload. django generates filenames file upload field, automatically appending numbers end of existing files (i.e. test.mp4, test_1.mp4, test_2.mp4, etc.). however, when upload video test.wmv, there no file named test.wmv after conversion complete (i delete non-converted file). there way can modify django method generates these filenames??

use upload_to when declaring filefield. maybe use object's primary key filename?


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -