NGINX video storage

Forum home -> Tech Talk -> View topic

Post

Posted
Rating:
#532 (In Topic #108)
Avatar
Standard member
Hi,

I've setup my NGINX live streaming server and is working fine.
My question is, after the stream I have a lot of .ts files. My questions are:

1 - What if I need to create a single video file after the live stream? How can I do that?

2 - If I need to give my users to watch .mp4 videos (not live streaming), do I just need to install NGNIX HTTP module and give them the mp4 file path (##https://myip /file.mp4) ?  Or should I use an encoder, create the .ts files and give them a m3u8 path?

I am a teacher and I have a bunch of classes that I need to publish to my students (mp4/avi files), but I want to use my own server. I thought about Digital Ocean spaces instead of my NGNIX server…

What is your suggestion?
Online now: No Back to the top

Post

Posted
Rating:
#533
Avatar
Standard member
Hello!

.ts files are MPEG Transport Stream files.
The "proper" way to concatenate the files, would be with ffmpeg (https://trac.ffmpeg.org/wiki/Concatenate).

There are some good answers in this thread on superuser.com.

In short, you can put the following code (that Francesco Galgani posted) in a bash script and run it in a directory full of .ts files.
#!/bin/bash for i in `ls *.ts | sort -V`; do echo "file $i"; done >> mylist.txt ffmpeg -f concat -i mylist.txt -c copy -bsf:a aac_adtstoasc video.mp4
Explanation of the commands
  1. Execute the following code using BASH
  2. List the files, sort them and print the path to a temporary file called mylist.txt.
  3. Run ffmpeg and tell it to concatenate the files listed in mylist.txt, applying the Concat "protocol"  using the Stream Copy method and the Bit Stream Audio Filter aac_adtstoasc, that will convert the MPEG-2/4 AAC ADTS to an MPEG-4 Audio bitstream and finally output to the file video.mp4
Online now: No Back to the top

Post

Posted
Rating:
#534
Avatar
Standard member
Thanks! I am going to use ffmpeg.

What about the server to play these mp4 files? Can I just put in some folder in my NGNIX or APACHE and give my students the HTTP address?
Online now: No Back to the top

Post

Posted
Rating:
#535
Avatar
Standard member
You can serve the file as a regular file.
Most browsers will be able to start showing the video as soon as they have buffered enough. It might be a good idea to look up information on how to optimize Nginx for that sort of thing.

A potentially better way, would be to set up the server for streaming with RTMP

I would suggest you use a nice frontend, such as MediaGoblin for the best user experience.

If the files are publicly accessible, you might also want to look into LBRY, a peer-to-peer video streaming service, that also has a hosted Youtube like frontend (that uses regular HTTP file hosting).
With LBRY, you will get a free distribution network on top of just the single-server hosting.
Online now: No Back to the top

Post

Posted
Rating:
#536
Avatar
Standard member
Thank you again.
So, I am thinking to upload my classes to my server or S3 (or even Digital Ocean spaces). I can give my students the URL for the video and their browsers will support it.
To use the streaming with RTMP , I need to convert my video files using FFMPEG and create a player for that.

What I am thinking is to use my server on Digital Ocean, and another NGNIX Proxy Server in an unlimited bandwidth datacenter pointing to my server, to avoid high over bandwidth costs.

I need to figure out a way to implement some server security to avoid download of these videos..
Online now: No Back to the top

Post

Posted
Rating:
#537
Avatar
Standard member
That seems reasonable.
Only, I would not recommend you give a direct link to a video, but instead at the very least put an HTML page with a <video> tag on there, so the user will get some proper controls and a nice looking players.
Even better, use one of the nice open source HTML video players out there.

Regarding the prevention of download. That is not possible. Anything the browser can display, it can save, unless you add some sort of messy DRM on top.
For things like HLS, your students will probably need to install an extension like DownloadHelper and its companion app to be able to save them, so it takes a little more work.
Basically, all you can do is annoy your students, not stop them :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.