Jump to content

How do I make uploaded videos be transcoded.

Okay so I am creating a video streaming website and I need the videos to have different resolutions. Now this would not be a problem if I didn't care about security/DRM and whatnot, however I am using Wowza on a Windows server (I know... but it is much easier to manage) and I also have a Ubuntu server running NGINX and PHP. I want to be able to upload videos through my Ubuntu web server (I don't care if I have to switch languages), transcode it through something like FFmpeg and then somehow get it to my Windows server. I do not want to use Wowza's transcoding because it slows the server down by a lot and I want a actual file in the format of VIDEOID_1080.mp4 or something. 

Link to comment
Share on other sites

Link to post
Share on other sites

Write a php script that constantly queries a table in a database to see if there are new videos uploaded which have to be converted in various resolutions.

When new upload is detected, transfer the file to your linux machine (if you don't already host the website on that machine), mark that record in database as "processing"  then run multiple conversions in series or in parallel to create your different formats.

When you're done, mark your record in the table as done so you won't re-process the file.

Use Wowza API or whatever to transfer back the newly created files in the right places for wowza to stream them.

 

Your upload form then only needs to add a record in that database table that's monitored by your script and make the original file available through some means (for example a  ftp server listening on a separate internal network , if you use 2 network cards on your servers)

 

seems like a no-brainer to me.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

34 minutes ago, mariushm said:

Write a php script that constantly queries a table in a database to see if there are new videos uploaded which have to be converted in various resolutions.

When new upload is detected, transfer the file to your linux machine (if you don't already host the website on that machine), mark that record in database as "processing"  then run multiple conversions in series or in parallel to create your different formats.

When you're done, mark your record in the table as done so you won't re-process the file.

Use Wowza API or whatever to transfer back the newly created files in the right places for wowza to stream them.

 

Your upload form then only needs to add a record in that database table that's monitored by your script and make the original file available through some means (for example a  ftp server listening on a separate internal network , if you use 2 network cards on your servers)

 

seems like a no-brainer to me.

 

 

Thanks, i'll try that.

Link to comment
Share on other sites

Link to post
Share on other sites

On ‎20‎/‎05‎/‎2017 at 7:24 PM, mariushm said:

Write a php script that constantly queries a table in a database to see if there are new videos uploaded which have to be converted in various resolutions.

When new upload is detected, transfer the file to your linux machine (if you don't already host the website on that machine), mark that record in database as "processing"  then run multiple conversions in series or in parallel to create your different formats.

When you're done, mark your record in the table as done so you won't re-process the file.

Use Wowza API or whatever to transfer back the newly created files in the right places for wowza to stream them.

 

Your upload form then only needs to add a record in that database table that's monitored by your script and make the original file available through some means (for example a  ftp server listening on a separate internal network , if you use 2 network cards on your servers)

 

seems like a no-brainer to me.

 

 

why transfer anything? say the the files where uploaded to the windows server just share that folder, the Linux machine can just process it and move on to the next. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, vorticalbox said:

why transfer anything? say the the files where uploaded to the windows server just share that folder, the Linux machine can just process it and move on to the next. 

True, I hadn't thought of that... I can try that now, thanks!

Link to comment
Share on other sites

Link to post
Share on other sites

my answer was as generic as possible.

 

For example, website could be made out of multiple light servers that only read the transcoded files from a NAS of some sort and stream them to users.

Such light servers could be dual/quad cores with 4-8 gb of memory, just enough for some light file caching and ability to handle a lot of concurrent downloads ( ex 200 x 3-5 mbps)

Such servers wouldn't have the processing power to also transcode and it would make sense to copy the big file that needs to be transcoded locally instead of transferring it over the network multiple times.

For ex. you have a 20 GB 4K file, you transfer it only once to transcoding machine (optionally through a separate 1-10gbps private network),  then maybe extract audio from file to reduce seeking through file and make it easier to encode audio in parallel while video is transcoded... then transcode to 1080p, 720p,360p for video h264 or vp9, opus / aac / mp3 for audio (let ogg vorbis die already) and when all encodes are done mux them in containers if you don't stream them separately like Youtube does with dash.

 

for low resolution, you could also queue video transcodes in parallel.. for ex with x264 sweetspot for 720p encodings is 10-12 threads, any higher could actually cause tiny loss of quality - so for example if you have a ryzen 8/16 threads you may want to limit 720p transcode to ~10 threads and do the 360p encode in parallel with ~6-8 threads.

 

pretty much all audio encoders are single threaded, so it's ok to transcode audio in parallel with video as audio will only use 1-2 threads.

 

// wrote on phone, sorry for spelling/typos/etc

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, mariushm said:

-snip-

Thanks for that. I really appreciate all the help. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×