title: How to get the thumbnail of base64 encoded video file in Nodejs?
body: <p>I am developing a web application using Nodejs. I am using Amazon S3 bucket to store files. What I am doing now is that when I upload a video file (mp4) to the S3 bucket, I will get the thumbnail photo of the video file from the lambda function. For fetching the thumbnail photo of the video file, I am using this package - <a href="https://www.npmjs.com/package/ffmpeg" rel="nofollow noreferrer">https://www.npmjs.com/package/ffmpeg</a>. I tested the package locally on my laptop and it is working. </p>
  
  <p>Here is my code tested on my laptop</p>
  
  <pre><code>var ffmpeg = require('ffmpeg');
  
  module.exports.createVideoThumbnail = function(req, res)
  {
      try {
          var process = new ffmpeg('public/lalaland.mp4');
          process.then(function (video) {
  
              video.fnExtractFrameToJPG('public', {
                  frame_rate : 1,
                  number : 5,
                  file_name : 'my_frame_%t_%s'
              }, function (error, files) {
                  if (!error)
                      console.log('Frames: ' + files);
                  else
                      console.log(error)
              });
  
          }, function (err) {
              console.log('Error: ' + err);
          });
      } catch (e) {
          console.log(e.code);
          console.log(e.msg);
      }
      res.json({ status : true , message: "Video thumbnail created." });
  }
  </code></pre>
  
  <p>The above code works well. It gave me the thumbnail photos of the video file (mp4). Now, I am trying to use that code in the AWS lambda function. The issue is the above code is using video file path as the parameter to fetch the thumbnails. In the lambda function, I can only fetch the base 64 encoded format of the file. I can get id (s3 path) of the file, but I cannot use it as the parameter (file path) to fetch the thumbnails as my s3 bucket does not allow public access.</p>
  
  <p>So, what I tried to do was that I tried to save the base 64 encoded video file locally in the lambda function project itself and then passed the file path as the parameter for fetching the thumbnails. But the issue was that AWS lamda function file system is read-only. So I cannot write any file to the file system. So what I am trying to do right now is to retrieve the thumbnails directly from the base 64 encoded video file. How can I do it?</p>