I want a user to be able to upload a video from their computer or record it right from their webcam, then fill out other information with a form. I'm writing this app with Django.
Recording directly from the web cam is not as simple as uploading an existing video file. You may need to look into one of the many video streaming protocols and handle that via a server such as red5. This approach would require the use of Flash or something similar.
The Django documentation should be able to help you handle file uploads:
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
Additionaly have a look at jquery uploadify. It's pretty useful for large file uploads because it display the progress of the download.
Related
I want to create a file sharing website in with pynecone. Is there a go-to way to upload files and save them on the server?
The documentation says to use React components if there aren't any Pynecone specific components, but I wanted to know if Pynecone can handle files uploads on its own.
This is not available yet, but is a high priority feature to add. There is an open ticket here. It should be available soon.
I would like to make a web application where a user can:
click a button on a webpage to create a **random video (with moviepy)
play that video back on the webpage
click the button again to create a new **random video that replaces the existing one
** The random video will be created with a python/moviepy script that downloads a bunch of random video clips from the internet to a directory on my computer. It then compiles them into one video (.mp4 file).
I've done the python script bit already which successfully creates the video file.
To make the web app bit I have been recommended django and that's where I'm stuck!
So far I have installed django and got to grips with the basics .. I have a home page that says "Hello world".
My question is where do I go from here?
How do I connect my python/moviepy script with django?
What steps, apps, components etc, within django should I look into to make this thing?
I'm new to coding and looking for some guidance.
Thanks!
If you create a model with FileField then your moviepy script should upload videos into that field, that field can save the video in a specified directory in MEDIA_ROOT(you can store your post based on date) then that field will store the URL to it (you need to specify MEDIA_URL in settings.py). You can define some sort of IDs to them, if video privacy is not important, then you can use the model IDs. These IDs can be obtained trough Path converters .
At the client-side, javascript is needed. Simply running the script in view is possible, but then the user will need to wait for the response (and the browser should run into time-out).
You should look at server-sent events. With Vue.js you can easily display a loading element while waiting for the event (a video to be generated) and then download and switch to the video (see Django CRUD application tutorials). The python script can run asynchronously (you call it in the view).
It is a lot, I know.
Actually I'm going to learn these now, sorry for mistakes.
As I see, Django is for complex sites, you should look for Flask instead.
(I am learning Django and I know nothing about Flask, so I`ll go with it)
Here is the needed setup:
define the urlpatterns for handling the URLs
create a model for storing your video
create a django template for your page (html)
define a view for rendering out the template (passing the video)
maybe some css to design it
You can run your video generator(in the view) at every reload and override existing video(in this case you don't even need a model) or you can save the generated videos and capture the IDs in the URLs (for example: https://yoursite.com/1), in this case, the videos remain shareable.
If you go with the first option and sharing videos is not important for you then you could write a simple html page with a video and a button. The button can trigger a javascript function to run the video generator python script and refresh the page(the video is overridden), you may need to wait to the script otherwise the old video can load.
Restful API is a more advanced way to refresh the video, without reloading the page.
After these, you can deploy your page using an Apache server for example.
I tried to give you some guidelines (I am learning this on my own)
Hope that it helped :) There are tutorials for these.
I see various bits of information in the docs, but I can't seem to form the complete picture.
I wish to hold various text, audio and video files on the server. At the moment I'm not planning to add user upload support but it would be nice to expand to that in the future.
I just don't understand where to start and what to do. Where do I save those files on the server? What is the best way for django to interact with those files?
I hope that you can help me with the confusion :)
I have found a very nice algorithm for image classification (https://everypixel.com/aesthetics) and was wondering if its possible to upload image files to the webpage with python. They are using a drag and drop system for the image files. Because the algorithm tags those uploaded pictures, the possibility of automatic upload would be very nice.
Python is just a language and not a framework. This means it is not sufficient to be a web server(something that will accept a request and respond to it).
So you need to use a server like flask to accept the request and implement your algorithm there.To attach a file you need to implement a frontend as well.
I'm developing a Django site which allows users to upload PDF, image and video files. Django is able to serve the pdf and image files comfortably for my purposes but cannot cope with the video downloads. Is there a way to load video files via Django but them serve them using a different server?
Is there a way to load video files via Django but them serve them
using a different server?
You should define what you mean by "different server". but I assume, you mean different project that is not written in Django.
Since video files land in file system ( if you design so), you can access them as you want if different project is running on the same server. otherwise you would need some file sync between servers. if you want to distinguish which video file belongs to which object in db, I would insert the object name into filepath.
if I didnot fully answer your question, let me know below