🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

gatsby-video

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-video

Gatsby video plugin that consumes video from gatsby-transformer-ffmpeg

0.2.0
latest
Source
npm
Version published
Weekly downloads
13
62.5%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-video

A basic video component that consumes gatsby-transformer-ffmpeg locally hosted videos.

Install

npm install --save gatsby-video gatsby-transformer-ffmpeg gatsby-plugin-ffmpeg

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [`gatsby-transformer-ffmpeg`],
}

Create a pageQuery or static query to grab the video you're interested in.

export const pageQuery = graphql`
  {
    file(relativePath: { eq: "features/arc-init.mov" }) {
      childVideoFfmpeg {
        webm: transcode(
          outputOptions: ["-crf 20", "-b:v 0"]
          maxWidth: 900
          maxHeight: 480
          fileExtension: "webm"
          codec: "libvpx-vp9"
        ) {
          width
          src
          presentationMaxWidth
          presentationMaxHeight
          originalName
          height
          fileExtension
          aspectRatio
        }
        mp4: transcode(
          maxWidth: 900
          maxHeight: 480
          fileExtension: "mp4"
          codec: "libx264"
        ) {
          width
          src
          presentationMaxWidth
          presentationMaxHeight
          originalName
          height
          fileExtension
          aspectRatio
        }
      }
    }
  }
`

Grab the data in your component and then pass it to the video component.


import { Video } from 'gatsby-video'
import poster_image from './poster.png'

const MainPageVideo = props => {
  const videos = props.data.file.childVideoFfmpeg

  return (
    <Video
      poster={poster_image}
      autoPlay
      muted
      loop
      sources={[videos.webm, videos.mp4]}
    />
  )
}

Thanks

The video and aspect ratio components are based on these:

https://github.com/simonyiszk/konferencia-web-2018/

Keywords

gatsby

FAQs

Package last updated on 03 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts