Code Monkey home page Code Monkey logo

thumbsupply's People

Contributors

kj800x avatar ryanafrish7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

thumbsupply's Issues

mime.replace is not a function

When using the following code:

thumbsupply.generateThumbnail(filepath)

I get the error

mime.replace is not a function

edit: the file is named about 10 different numbers (with no file extension)

Lookup time is longer than expected

It takes a considerable amount of time when hashing files. Video files are usually big and this adds a serious bottleneck to the entire design.

Thumbnail size issue

I am getting landscape thumbnails for all videos. (Even if a video is a portrait).

please help me out with this.

Incorrect thumbnail aspect ratios for some videos

Certain video resolutions cause thumbsupply to create thumbnails with a different aspect ratio than the source video.

The resolution that I've experienced this with is 852x480.

Steps to reproduce:

  • Download a sample of big buck bunny at 1280x720 (eg. from here: https://sample-videos.com/)
  • Use ffmpeg to resize the video to 852x480: ffmpeg -i sample-video-1280.mp4 -vf scale=852:480 sample-video-852.mp4
  • Run thumbsupply on both the 1280 version and the 852 version.
  • Expected: The thumbnail of the 852 video has a resolution of roughly 480x270 (same aspect ratio as 852x480, just scaled down so that the largest dimension is 480).
  • Actual: The thumbnail of the 852 video has a resolution of 480x480. This is a square image, while the source video was not square.

I suspect that it's an integer division issue in getOptimalThumbnailResolution: https://github.com/RyanAfrish7/thumbsupply/blob/master/thumbs/video-thumb.js#L55

s3 getObject -> generateThumbnail -> s3.putObject workflow

I'm running a Node app on a server and using S3 for all the file storage. When uploading a video file, it's sent directly from the browser to the S3 store, and then I run a Node function to generate the thumbnail, reading the file from S3 to Node, generating the thumbnail and writing the resulting file back to S3 without ever saving it locally on the app server.

I'm trying to use thumbsupply to generate previews for video files, but can't get the syntax right for returning the thumb as a buffer that can be passed into the s3.putObject function.

I'm not sure if the error being returned is from the input to thumbsupply being in the wrong form, or the resulting generated thumb not being the right form (a Buffer) for s3.putObject.

  s3.getObject({ Bucket: myBucket, Key: sourceFilename })
    .promise()
    .then(data => thumbsupply.generateThumbnail(data.body,
      {
        size: thumbsupply.ThumbSize.MEDIUM,
        mimetype: "video/mp4"
      })
    )
    .then(buffer => s3.putObject({
      Body: buffer,
      Bucket: myBucket,
      ContentType: 'image/jpeg',
      Key: destinationFilename,
      ACL: 'public-read-write'
    })

Can you shed some light on what I'm missing here?
Thanks!

Weird aspect ratio for videos with different sample_aspect_ratio and display_aspect_ratio

I haven't been able to dig too deep into this yet, but it seems like for certain videos the aspect ratio of the generated thumbnails is off. For example, I have a landscape video with an aspect ratio of 4:3 (landscape) but the generated thumbnail has ratio of 2:3 (portrait).

I'd share the video but that would be a violation of copyright. I'll see if I can find a sample creative commons video soon that has this issue.

Looking at the output of the the ffprobe call for the video I have, I see different values for sample_aspect_ratio and display_aspect_ratio which I suspect might be causing this issue.

   { streams:
      [ { index: 0,
          codec_name: 'h264',
          codec_long_name: 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
          profile: 'High',
          codec_type: 'video',
          codec_time_base: '1/60',
          codec_tag_string: 'avc1',
          codec_tag: '0x31637661',
          width: 320,
          height: 480,
          coded_width: 320,
          coded_height: 480,
          has_b_frames: 2,
          sample_aspect_ratio: '2:1',
          display_aspect_ratio: '4:3',
          pix_fmt: 'yuv420p',
          level: 21,
          color_range: 'unknown',
          color_space: 'unknown',
          color_transfer: 'unknown',
          color_primaries: 'unknown',
          chroma_location: 'left',
          field_order: 'unknown',
          timecode: 'N/A',
          refs: 1,
          is_avc: 'true',
          nal_length_size: 4,
          id: 'N/A',
          r_frame_rate: '30/1',
          avg_frame_rate: '30/1',
          time_base: '1/15360',
          start_pts: 0,
          start_time: 0,
          duration_ts: 2664453,
          duration: 173.466992,
          bit_rate: 304836,
          max_bit_rate: 'N/A',
          bits_per_raw_sample: 8,
          nb_frames: 5204,
          nb_read_frames: 'N/A',
          nb_read_packets: 'N/A',
          tags: { language: 'und', handler_name: 'VideoHandler' },
          disposition:
           { default: 1,
             dub: 0,
             original: 0,
             comment: 0,
             lyrics: 0,
             karaoke: 0,
             forced: 0,
             hearing_impaired: 0,
             visual_impaired: 0,
             clean_effects: 0,
             attached_pic: 0,
             timed_thumbnails: 0 } },
        { index: 1,
          codec_name: 'aac',
          codec_long_name: 'AAC (Advanced Audio Coding)',
          profile: 'LC',
          codec_type: 'audio',
          codec_time_base: '1/44100',
          codec_tag_string: 'mp4a',
          codec_tag: '0x6134706d',
          sample_fmt: 'fltp',
          sample_rate: 44100,
          channels: 2,
          channel_layout: 'stereo',
          bits_per_sample: 0,
          id: 'N/A',
          r_frame_rate: '0/0',
          avg_frame_rate: '0/0',
          time_base: '1/44100',
          start_pts: 970,
          start_time: 0.021995,
          duration_ts: 7699683,
          duration: 174.595986,
          bit_rate: 119746,
          max_bit_rate: 128000,
          bits_per_raw_sample: 'N/A',
          nb_frames: 7519,
          nb_read_frames: 'N/A',
          nb_read_packets: 'N/A',
          tags: { language: 'und', handler_name: 'SoundHandler' },
          disposition:
           { default: 1,
             dub: 0,
             original: 0,
             comment: 0,
             lyrics: 0,
             karaoke: 0,
             forced: 0,
             hearing_impaired: 0,
             visual_impaired: 0,
             clean_effects: 0,
             attached_pic: 0,
             timed_thumbnails: 0 } } ],

Tests don't pass on master

> [email protected] test /home/kevin/Desktop/thumbsupply
> mocha



  thumbsupply
    #generateThumbnail()
      ✓ should be creating the thumbnail (300ms)
      1) should be creating the thumbnail as specified
    #lookupThumbnail()
      ✓ should lookup and fetch the thumbnail
      ✓ should not lookup and fetch the expired thumbnail


  3 passing (711ms)
  1 failing

  1) thumbsupply
       #generateThumbnail()
         should be creating the thumbnail as specified:

      AssertionError [ERR_ASSERTION]: 136 == 135
      + expected - actual

      -136
      +135
      
      at testResolution (test/test.js:16:16)
      at thumbsupply.generateThumbnail.then.thumbnail (test/test.js:49:21)
      at process.internalTickCallback (internal/process/next_tick.js:77:7)



npm ERR! Test failed.  See above for more details.

It looks like maybe the assertion value is simply wrong?

Make cacheDir configurable

It would be great if it were possible to configure the cacheDir that thumbsupply uses. The default ~/.cache/thumbsupply is good in most cases, but it would be great for me to be able to have the data on my hard drive partition where the rest of my application is stored from instead of in my home directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.