My external hard drive is connected to my Raspberry Pi, which itself is connected to my TV via HDMI. I have a bunch of videos on my drive which I usually watch on the TV using omxplayer
, but sometimes I want to be able to watch them on my laptop. I wanted a simple solution without having to make my Pi a full-fledged NAS.
My first attempt was to launch the built-in simple HTTP server of Python into my videos' directory:
python3 -m http.server
And then visit my Pi's local IP in my laptop's browser to get the file listing and let the browser open and read the videos. It works, but it's impossible to seek at arbitrary times inside the videos. Indeed, the server doesn't support the Range
header that the browser sends when seeking at a specific part of a video.
I found out that the Python Twisted project comes with a basic web server that is more powerful than http.server
and does support Range
s. In the end, the solution to my problem was as simple as:
sudo apt-get install python-twisted-web
and then
twistd -no web --path=.
It takes a little more time to start than http.server
but it can seek videos :)