Amazon s3 and node js video streaming and thumbnails?

I am working in a node.js project in which I need to upload .mp4 files to amazon s3.

I have 2 questions:

QUES 1: I uploaded the mp4 file to a private bucket to say the bucket name is 'videoobucket'. To view the video in a browser, I created its signed URL.

My question is:

It is a ULR signed, which turns out to be different from the URL STREAMED. IF yes, what steps should I follow to create a streaming URL?

QUES 2: I need to create a thumbnail of the video that I am going to upload to amazon s3. How to do this in node.js?

I'm new to amazon and node.

Thank you all in advance!

The code I wrote to upload the files is as follows:

var file = req.files.video;

    var fileName = new Date().getTime() + "_" + file.originalname;

    fs.readFile(file.path, function(err, data) {
        if (err) throw err;
        var s3bucket = new AWS.S3({
            params: {
                Bucket: 'myvideos'
            }
        });
        s3bucket.createBucket(function() {
            var params = {
                Key: fileName, //file.name doesn't exist as a property
                Body: data,
                ContentType: file.type,
            };
            s3bucket.upload(params, function(err, data) {
                fs.unlink(file.path, function(err) {
                    if (err) {
                        console.error(err);
                    }
                });

                if (err) {
                    res.status(500).send(err);
                } else { console.log("file uploaded"); }
        });

 });

});
+4
2

. google.

JW Player Amazon S3:

1: "" - JW Player. .zip . 2: aws https://console.aws.amazon.com/s3/

3: 4: "". 5:

jwplayer.flash.swf

jwplayer.html5.js

jwplayer.js

.mp4 .flv

CloudFront Web RTMP-

CloudFront , - CloudFront JW Player HTML , RTMP- .

1: https://console.aws.amazon.com/cloudfront/

2:

3: , RTMP "".

4: " " Amazon S3, . JW Player Amazon S3. Amazon S3, , .

5:

6. , CloudFront , Status InProgress Deployed. 15 .

, CloudFront , . " " .)

EMBEDDING RTMP MEDIA:

<div id='mediaplayer'>This text will be replaced</div>
<script type="text/javascript">
   jwplayer('mediaplayer').setup({
      'id': 'playerID',
      'width': '720',
      'height': '480',
      'file': 'rtmp://s1cxpk7od1m10r.cloudfront.net/cfx/st/your_streaming_file.mp4',
      'primary':'flash',
      'autostart' : 'true',
   });
</script>
+2

: fluent-ffmpeg https://github.com/fluent-ffmpeg/node-fluent-ffmpeg

var ffmpeg = require('fluent-ffmpeg');
var screenshot = new ffmpeg({source:'./1.mp4'}) // put in the source path of the video
                    .withSize('200x200')
                    .takeScreenshots({count:1,timemarks:['50%'],filename:"screenshot.png",folder:"./"});

ffmpeg:

ffmpeg('/path/to/video.avi')
.screenshots({
    timestamps: ['50%'],
    filename: 'screenshot.png',
    folder: '/path/to/output',
    size: '200x200'
});
+1

Source: https://habr.com/ru/post/1583981/


All Articles