Then in your task function you can get the file from the video model
instance, trascode it, and store it in the corresponding fields of the
object (mp4_480, mp4_720)

On Fri, Feb 20, 2015 at 10:18 AM, Vijay Khemlani <vkhem...@gmail.com> wrote:

> I would do something like this
>
> video = Video()
> video.original = form.cleaned_data['video']  # Assuming the form field is
> "video"
> video.user = user
> video.title = form.cleaned_data['title']  # Assuming the form field is
> "title"
> video.save()              # You might need to make the mp4_480 and mp4_720
> fields "nullable" on the model
> yourapp.tasks.transcode_video.delay(video)   # Assuming the task is the
> "transcode_video" function.
>
> return HttpResponseRedirect('/')
>
> Then
>
>
> On Fri, Feb 20, 2015 at 10:04 AM, Robin Lery <robinl...@gmail.com> wrote:
>
>> I would like to transcode user uploaded videos using celery. I think
>> first I should upload the video, and spawn a celery task for transcoding.
>>
>> Maybe something like this in the tasks.py:
>>
>>     subprocess.call('ffmpeg -i path/.../original path/.../output')
>>>
>>
>> Just completed First steps with celery
>> <http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#first-steps>,
>> so confused how to do so in the `views.py` and `tasks.py`. Also is it a
>> good solution? I would really appreciate your help and advice. Thank you.
>>
>> models.py:
>>
>>     class Video(models.Model):
>>>         user = models.ForeignKey(User)
>>>         title = models.CharField(max_length=100)
>>>         original = models.FileField(upload_to=get_upload_file_name)
>>>         mp4_480 = models.FileField(upload_to=get_upload_file_name)
>>>         mp4_720 = models.FileField(upload_to=get_upload_file_name)
>>>         privacy = models.CharField(max_length=1,choices=PRIVACY,
>>> default='F')
>>>         pub_date = models.DateTimeField(auto_now_add=True,
>>> auto_now=False)
>>>
>>
>> my incomplete views.py:
>>
>>
>>     @login_required
>>>     def upload_video(request):
>>>         if request.method == 'POST':
>>>             form = VideoForm(request.POST, request.FILES)
>>>             if form.is_valid():
>>>                 if form.cleaned_data:
>>>                     user = request.user
>>>                     #
>>>                     #
>>>                     # No IDEA WHAT TO DO NEXT
>>>                     #
>>>                     #
>>>                     return HttpResponseRedirect('/')
>>>
>>>         else:
>>>             form = VideoForm()
>>>             return render(request, 'upload_video.html', {
>>>                 'form':form
>>>                 })
>>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@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-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CALn3ei0fjxCurSdVufpqj5hpzCGadMq_tQky_POGoXm%2B6GtSfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to