greetings! I'm trying to implement a video streaming application in django. the consumer of the video will be a mobile application which would stream and display the video. My requirement is to ensure that I stream the video (like in youtube), rather than downloading the video file and playing it on the device.
I did go through the various resources available. I have the following implemented currently.
urls.py
from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from .views import video_stream
urlpatterns = [
path('admin/', admin.site.urls),
path(r'videos/', video_stream, name='v_stream'),
#url(r'^media/', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
views.py
import os, mimetypes
from django.http import HttpResponseNotFound
from ranged_response import RangedFileResponse
from django.core.files.storage import default_storage
from django.http import HttpResponse
from django.core.files.storage import FileSystemStorage
from django.conf import settings
import urllib, mimetypes
from django.http import HttpResponse, Http404, StreamingHttpResponse, FileResponse
import os
from django.conf import settings
from wsgiref.util import FileWrapper
import requests
def video_stream(request):
r = requests.get('http://127.0.0.1:8000/media/watermark.mp4', stream=True)
response = StreamingHttpResponse(streaming_content=r)
return response
when I run the application, I do not get the video playing, however, I get the following:

I tried using the vlc media player's stream from url function. I got the following error.
System check identified no issues (0 silenced).
August 08, 2020 - 17:59:44
Django version 3.0.5, using settings 'streamer.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[08/Aug/2020 18:00:29] "GET /media/watermark.mp4 HTTP/1.1" 200 40143859
[08/Aug/2020 18:00:30] "GET /videos/ HTTP/1.1" 200 40143859
[08/Aug/2020 18:00:30] "GET /videos/ HTTP/1.1" 200 324736
[08/Aug/2020 18:00:30] "GET /media/watermark.mp4 HTTP/1.1" 200 3604480
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
Traceback (most recent call last):
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
[08/Aug/2020 18:00:31] "GET /videos/ HTTP/1.1" 500 59
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63778)
[08/Aug/2020 18:00:31] "GET /media/watermark.mp4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63779)
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 119, in handle_error
super().handle_error()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 279, in write
self._write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 775, in write
self._sock.sendall(b)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 119, in handle_error
super().handle_error()
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 172, in handle
self.handle_one_request()
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 197, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
Traceback (most recent call last):
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 114, in close
super().close()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 639, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\socketserver.py", line 696, in __init__
self.handle()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 172, in handle
self.handle_one_request()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 197, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\handlers.py", line 144, in run
self.close()
----------------------------------------
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\servers\basehttp.py", line 114, in close
super().close()
File "C:\Users\win10\AppData\Local\Programs\Python\Python36-32\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
I basically want to serve media files from my django application. and from a mobile application consume and stream the video file in an application.
I am using Xamarin forms for mobile application development.
Any help/guidance is deeply appreciated.