A simple node-express API that lets you transcode videos and generate corresponding.hls and .ts files.
uploadvideos to the serverdownloadthe transcoded result- upload the transcoded files to
AWS S3 - access the video through
AWS Cloudfront CDN
- run
npm ito install all project dependencies. - run
npm run devto start the dev server. - v1.0.0:
add video(s) in'./src/videos/rawfolder. For ease, there is already a video and its transcoded files added in./src/videosfolder. All you need to do is open the./index.htmlfile.
- Once you have the project running on localhost, upload a new video file using the
POST /transcode/newendpoint. - Once the video gets uploaded, transcoding starts immediately and just like in v1.0.0, generated output is stored in the
./src/videos/transcodedfolder. - Once transcoding is completed, the uploaded file is removed from the local
fs.
- copy the complete video name, including the file extension, of the file that you want to transcode, say
my-video.mp4. - for
v1.0.0, you can either use your browser or terminal to send aGETrequest tohtp://localhost:4000/transcode/new/my-video.mp4
- in the
./index.htmlfile, change thesrcvalue for the<video></video>element to point to the.hlsfile for your video. - open the
.htmlfile and the network tab (in the dev tools), side by side. - you will be able to see multiple requests being sent for
.tsfiles, which is nothing but the browser requesting for more chunks as the video keeps playing. - stop playback and no more chunks will be fetched.
- skip to a new video position and a new chunk will be fetched.
- jump back to a point in video which has already played and you'll see that the chunk was loaded immediately from
disk cache. thing.