Suppose a server is hosting a video file. Why is it that sometimes, it requires a full download before playing. Sometimes, I can stream it? - apache

Someone told me that some servers configure it that allow streaming of a file.
OR
Is it a file-encoding problem, not a server configuration problem?
Given a link of the video file, how do I check if that person allows streaming (or play only once downloaded) ? Headers?

In order for a file to be streamable, all of the information necessary to initialize the decode and playback engines must be at the beginning of the file. Not all file formats are designed in that way. (for instance, with AVI files usually the index is at the end).
But the server must also be configured to stream. Transferring a file over HTTP or FTP is a different protocol than streaming the file.
So it's both, for streaming to work everything has to be setup correctly, the server and the file must support it. If either one is not set up correctly, then transferring the file usually works. Transferring the file is the conservative or fallback solution.

As long as the encoding format is such that the information in the file is chronological with respect to the video frames, there is no theoretical possible way for a server to allow downloading but not playing. Think about it. If you have the data, and it's playable after downloading, that portion is playable before downloading is complete.

Related

Nanoframework webserver download/upload file

I've searched a lot but couldn't find an example.
I want to use nanorframework as a webserver where I can upload and download e.g. a JSON file from the browser which holds all my settings. Is this possible?
Otherwise if I want to change some settings I have to rebuild the whole solution and uploat it.
Thanks in advance
You can use the Storage libraries to store that Json file. The actual storage can support by flash (using SPIFFs), SD card or USB mass storage device. This depends on the hardware platform that you are using. Check the Storage samples in our samples repo here.
Downloading a file is pretty straightforward you just need to serve the respective HTTP request. Check the HTTP samples in our samples repo here.
Uploading a file it's a matter of handling the POST request and grabbing the data being sent by the client browser.

make it impossible to download the audio files

So guys, how do I prevent users from downloading audio files on my web app (running springboot in backend) by accessing the s3 url !
I want to make it impossible to download the audio files in my website ! Any suggestions pls ?
I assume you mean that you want to make it impossible to download the audio files, but still allow streaming them for playback.
You can't.
If it can be played, it can be downloaded. Simple as that.
At best, you can sign your S3 URLs so that they expire after a short period of time. This gives you control over who accesses your audio files, and prevents them from showing up in searches, or linked to from other sites. You can also look into Encrypted Media Extensions, but it's not all that useful for audio since audio is trivially digitally captured on the output.

How to get Apache to cache video files in memory?

I'm hosting an HLS stream with XAMPP / Apache, which basically means I have a folder in my document root that contains a couple of incrementally numbered 10-second video files.
Every 10 seconds, a new video file is saved into the folder and the oldest video file in the folder is deleted.
Apart from these video files, the document root also contains some other files, such as PHP scripts and playlist files.
My server has plenty of RAM and a pretty fast CPU, but is using a comparatively slow hard disk.
Given the fact that the constant downloading of these video files is likely what's going to make or break the server performance, it seems like a good idea to cache these files in memory.
If Apache were to keep all video files (with a .ts extension) that're downloaded by a user's video player, in it's memory for about 60 seconds, the next user would then be able to download the file much faster. Apache could rely on the files not changing after the first open and on the fact that the files won't be requested anymore after those 60 seconds.
All other files do not (necessarily) have to be cached, since they're rather small and are regularly modified.
Is anyone able to give me directions on how to get started?
Modern operating systems already cache accessed files in memory. The whole process is managed by the kernel automatically.
Apache in-memory caching won't help you since it needs all the files at start-up.
If you want some level of control over the caching you could use vmtouch. Check the manual.

Show content of a zip file in a browser, rather than downloading it

I have a log server, where users upload archives and view their content online when needed. Currently the server unzips files, right after receiving them. Unfortunately, my peers consumed all the drive space I had. I can free up a lot of space, if there's a way of storing ZIP archives, but feeding them to users as HTML page (same as default Apache's file browser).
I know there are solutions relying on JS, like:
http://gildas-lormeau.github.io/zip.js/demos/demo2.html
https://stuk.github.io/jszip/
or I can unzip them on demand at server side and provide link to a temporary folder. However, some time ago I've heard a browser can view an archive content if proper headers are sent from Apache/nginx. Apache's mod-deflate doesn't help much here and I can't find other docs - perhaps it's not possible after all?
Cheers.

Programmatically add meta data for MP4

I have a server from where a single consumer me download MP4 files. I would like to add the username to the meta-data of the file at the time the user clicks "download". Amazon does something like this for the MP3 files.
Now, a slight variation to this is how would I do the same thing if the files are on Amazon Cloudfront.
Thanks!
You would have to route your request through your web server.
Logged-in user clicks
Web server downloads the MP4 file from S3 to its file system.
Web server uses an MP4 editor to add the correct MP4 metadata to the file.
Web server serves the MP4 file back to the customer as a download.
S3 is dumb file storage, so you can't do any on-the-fly editing or processing. Any such work must occur on a machine with a CPU.
As such, the question you posed could not be accomplished in any meaningful way using CloudFront, since the traffic needs to route back through your server for post-processing anyway.