I would like to convert video into mp4 using ffmpeg
and celery
for the asynchronous task. When user uploads a video, it will be for the original_video
and save it. After that I want celery to convert it into a different version for the mp4_720
field. However I am confused on how to apply that logic using celery.
class Video(models.Model):
title = models.CharField(max_length=75)
pubdate = models.DateTimeField(default=timezone.now)
original_video = models.FileField(upload_to=get_upload_file_name)
mp4_720 = models.FileField(upload_to=get_upload_file_name, blank=True, null=True)
converted = models.BooleanField(default=False)
def upload_video(request):
if request.POST:
form = VideoForm(request.POST, request.FILES)
if form.is_valid():
video = form.save(commit=False)
video.save()
// Celery to convert the video
convert_video.delay(video)
return HttpResponseRedirect('/')
else:
form = VideoForm()
return render(request, 'upload_video.html', {
'form':form
})
@app.task
def convert_video(video):
// Convert the original video into required format and save it in the mp4_720 field using the following command:
//subprocess.call('ffmpeg -i (path of the original_video) (video for mp4_720)')
// Change the converted boolean field to True
// Save
Basically my question is how to save the converted video in mp4_720. Your help and guidance will be very much appreciated. Thank you.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei3nZcbL5REM75Q1DVgoQud5oUMf%3Dhv3qLxuzJT1EiJ4wg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1J%2BGf_hRB7ERLonXpT_jhDqX8NkEYtV5qnftyMgKvJ0OA%40mail.gmail.com.