fb-upload-video-api

    1.0.2 • Public • Published

    facebook-api-video-upload

    Upload a video in chunk on the facebook api. more info

    Install

    $ npm i fb-upload-video-api --save
    

    Tested on OS X and Linux.

    Usage

    const fs = require('fs');
    const MovieUpload = require('fb-upload-video-api');
     
    const emitter = new MovieUpload();
     
    const args = {
      token: "YOURTOKEN",  // with the permission to upload
      id: "YOURID",       //The id represent {page_id || user_id || event_id || group_id}
      videoSize: size    // integer
    };
     
    (async ()=>{
      try{
        // Recieve start_offset and end_offset of facebook init and upload_chunk api
        emitter.on('slice_chunk', (start, end)=>{
          const chunkStream = fs.createReadStream('./fixture.mp4', {
            start: Number(start), //integer
            end: Number(end)     // integer
          });
          // Emit chunk to upload
          emitter.emit('chunk', chunkStream)
        })
     
        // Show percent of uploading
        emitter.on('upload', (percent)=>{
          console.log(percent);
        })
     
        const video_id = await emitter.uploadToFB(args);
        console.log(video_id);
     
      }catch(err){
        console.error(err)
      }
    })()

    Features

    • Support upload videos larger than 2gb (maximun size of buffer in nodejs)
    • Don't need to load all video into buffer

    License

    MIT © MrdotB

    Install

    npm i fb-upload-video-api

    DownloadsWeekly Downloads

    6

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.53 kB

    Total Files

    5

    Last publish

    Collaborators

    • thanhdinh98