Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gatsby-transformer-video (beta available) #15783

Closed
wants to merge 116 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
cd12bb4
initial code extraction from customer project
axe312ger Jul 10, 2019
acf2358
fix queueing and issues from refactoring
axe312ger Jul 10, 2019
5fdb775
very basic readme
axe312ger Jul 10, 2019
9ffa7d1
make path in public directory configurable
axe312ger Jul 10, 2019
b0066cd
make path to ffmpeg binaries configurable
axe312ger Jul 10, 2019
95604c5
v0.0.2
axe312ger Jul 10, 2019
4a40a62
add missing dependencies
axe312ger Jul 11, 2019
965aa7e
support File nodes as well
axe312ger Jul 11, 2019
e83624c
add simple example how to use and render videos
axe312ger Jul 11, 2019
2328b0b
tweak output options for file size and compatability
axe312ger Jul 11, 2019
c123ea0
configurable crf and preset for mp4 conversion
axe312ger Jul 11, 2019
bab702d
align scaling filter for all conversions
axe312ger Jul 11, 2019
110b8ad
add saturation and properly use ffmpeg complex filter chains
axe312ger Jul 12, 2019
0173ed7
output stdout/stderr to improve debugging experience
axe312ger Jul 12, 2019
9b6af8b
fix imagemin to actually use giflossy
axe312ger Jul 12, 2019
5782cce
set saturation as float instead of boolean
axe312ger Jul 13, 2019
4640dd2
improve debug output verbosity for now
axe312ger Jul 13, 2019
ddda65d
forgot yarn.lock update and some small default config changes
axe312ger Jul 15, 2019
d5596e5
add feature to add overlay/watermark videos
axe312ger Jul 15, 2019
2f150ee
v0.0.3
axe312ger Jul 15, 2019
b4d3dc8
update readme
axe312ger Jul 15, 2019
39fb732
fix contentful integration
axe312ger Jul 15, 2019
52af0b5
do not upscale videos
axe312ger Jul 15, 2019
6ec98f1
use ABR-VBV encoding to control resulting file size
axe312ger Jul 15, 2019
7a96154
v0.0.4
axe312ger Jul 16, 2019
e870205
update demo dependency
axe312ger Jul 16, 2019
80565dc
add misssing .babelrc.js
axe312ger Jul 16, 2019
0600a5c
remove copy pasta from readme
axe312ger Jul 16, 2019
616afb9
adjust default buffer size and max rate
axe312ger Jul 16, 2019
e5eff39
v0.0.5
axe312ger Jul 16, 2019
d1623ae
upgrade gatsby babel preset
axe312ger Aug 13, 2019
9b43e44
add prerequisites to readme
axe312ger Feb 12, 2020
de6eed5
use schema customization and createRemoteFileNode, provide one transf…
axe312ger Feb 13, 2020
6d8f91c
use new createContentDigest
axe312ger Feb 13, 2020
72d7f2e
update example to match new API
axe312ger Feb 13, 2020
b16b738
support file system file nodes again
axe312ger Feb 13, 2020
c0d850d
upgrade babel-preset-gatsby-package
axe312ger Feb 13, 2020
f17cdb9
improve encoding output for streaming
axe312ger Feb 13, 2020
09b649d
add support for VP9 codec
axe312ger Feb 13, 2020
0543a14
use proper audio codecs and optimize for file size
axe312ger Feb 13, 2020
bc6628e
use fast preset for h265 as it is way faster and files are marginally…
axe312ger Feb 13, 2020
66ed701
fix repo fields in package.json
axe312ger Feb 13, 2020
b593991
automatically determine bitrates for VP9
axe312ger Feb 13, 2020
37620bf
v0.1.0
axe312ger Feb 14, 2020
8632e13
recommend lazy loading of preview image
axe312ger Feb 14, 2020
20c13a9
add homebrew note to readme and update other sections
axe312ger Feb 14, 2020
f90d553
refactor to use profiles and clean up logging
axe312ger Feb 14, 2020
883b811
improve logging
axe312ger Feb 14, 2020
4b364b4
v0.1.1
axe312ger Feb 14, 2020
c4dc6d7
add FFMPEG flags to readme and use libfdk_aac for mp4
axe312ger Feb 14, 2020
ad9d055
add config option for custom ffmpeg conversion functions
axe312ger Feb 14, 2020
103b559
switch to high quality aac codec
axe312ger Feb 14, 2020
a6155e8
add screenshots feature
axe312ger Feb 14, 2020
bf43750
v0.1.2
axe312ger Feb 14, 2020
ea9c8c4
cache in node_modules as it is more persistent
axe312ger Feb 15, 2020
ecd7d86
v0.1.3
axe312ger Feb 15, 2020
c693ef5
switch back to better supported aac lib
axe312ger Feb 15, 2020
770c10d
v0.1.4
axe312ger Feb 15, 2020
b76b22e
fix sharp conflicts by depending on gatsby-plugin-sharp
axe312ger Feb 17, 2020
015afbc
v0.1.5
axe312ger Feb 17, 2020
500adc5
add note where the videos are stored for caching
axe312ger Feb 17, 2020
0ecbb6c
download required binaries if they can not be found
axe312ger Feb 17, 2020
64e82ab
v0.1.6
axe312ger Feb 17, 2020
65cc3c3
improve downloading of lib binaries
axe312ger Feb 17, 2020
f5a733c
v0.1.7
axe312ger Feb 17, 2020
a2e47bc
further refactor downloading of binaries
axe312ger Feb 17, 2020
e4b81fa
v0.1.8
axe312ger Feb 17, 2020
2cfb4bc
use downloaded binaries with fluent-ffmpeg
axe312ger Feb 17, 2020
66124d8
v0.1.9
axe312ger Feb 17, 2020
a0313cb
set correct default value for downloadBinaries option
axe312ger Feb 17, 2020
8c3fd2c
v0.1.10
axe312ger Feb 17, 2020
4d00c91
set correct file extension for binaries
axe312ger Feb 17, 2020
b10a8af
v0.1.11
axe312ger Feb 17, 2020
f2020e3
convert videos only once if same file is used for different contentfu…
axe312ger Mar 1, 2020
d80b51e
default to superfast profiles for fast development. quality can be ea…
axe312ger Mar 1, 2020
aa52ea1
v0.1.12
axe312ger Mar 1, 2020
a5b409b
add queue for downloading to avoid request timeouts on gatsby cloud
axe312ger Mar 3, 2020
abd4868
v0.1.13
axe312ger Mar 3, 2020
0eed63f
merge download queue with conversion queue to reduce network request …
axe312ger Mar 3, 2020
25c052b
v0.1.14
axe312ger Mar 3, 2020
068a921
add retry logic to contentful asset download
axe312ger Mar 10, 2020
006a0f1
v0.1.15
axe312ger Mar 10, 2020
1957da8
add logging to ctf asset download
axe312ger Mar 10, 2020
a71adb4
v0.1.16
axe312ger Mar 17, 2020
96d9cb8
add h265 tag for iOS and quicktime
axe312ger Mar 17, 2020
025c5c4
update and restructure dependencies
axe312ger Mar 17, 2020
202eeb4
update readme
axe312ger Mar 17, 2020
5299d0b
v0.1.17
axe312ger Mar 17, 2020
b0d7f90
refactor contentful file downloading and caching
axe312ger Mar 31, 2020
951f51f
v0.1.18
axe312ger Mar 31, 2020
7ee4556
chore: remove debug console.log
axe312ger Mar 31, 2020
2457d17
build: upgrade dependencies
axe312ger Oct 18, 2020
1c21a16
style: reapply eslint
axe312ger Oct 18, 2020
370c0d0
feat: switch to medium preset for h264 and h265 for higher quality, s…
axe312ger Oct 18, 2020
c737173
refactor: update babelrc to use babel-preset-gatsby-package
axe312ger Oct 18, 2020
242e99e
feat: move screenshots to extra videoScreenshots resolver
axe312ger Oct 18, 2020
dd80e1a
feat: use new reporter API
axe312ger Oct 18, 2020
767e75f
feat: move default directory into static folder
axe312ger Oct 26, 2020
4b05c48
feat: slightly increase default quality for h264 and h265
axe312ger Oct 26, 2020
73f67b3
refactor: adjust example to match new screenshots resolver
axe312ger Nov 2, 2020
91d50ec
feat: clean up logging and reporting
axe312ger Nov 2, 2020
8438fcc
docs: mark as beta and link usage example
axe312ger Nov 2, 2020
240eefe
feat: align file naming for files and contentful assets
axe312ger Nov 2, 2020
c61df86
fix: ensure screenshots are queued
axe312ger Nov 2, 2020
53909a2
fix: redownload files if actual file on Contentful changed
axe312ger Nov 2, 2020
e137088
feat: add width, height and aspect ratio to video nodes
axe312ger Nov 2, 2020
a70ea95
feat: add additional information when video could not be analyzed cus…
axe312ger Nov 2, 2020
375f1a0
v0.2.0
axe312ger Nov 2, 2020
43f8323
fix: prevent wget from spaming the logs via -nv
axe312ger Nov 8, 2020
d30461c
v0.2.1
axe312ger Nov 8, 2020
d962cec
fix: remove unused codec subfield and add width, height and aspect ra…
axe312ger Jan 7, 2021
7fec07d
v0.2.2
axe312ger Jan 7, 2021
c9e47b6
fix(binaries): check binary availability via command-exists instead o…
axe312ger Feb 2, 2021
0cc5450
v0.2.3
axe312ger Mar 5, 2021
58caa72
fix: use hash as filename for screenshots as well
axe312ger Mar 5, 2021
56572d8
v0.2.4
axe312ger Mar 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/using-gatsby-transformer-video/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"env": {
"browser": true
},
"globals": {
"graphql": false
}
}
3 changes: 3 additions & 0 deletions examples/using-gatsby-transformer-video/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public
.cache
node_modules
5 changes: 5 additions & 0 deletions examples/using-gatsby-transformer-video/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# using-gatsby-transformer-video

https://using-gatsby-transformer-video.gatsbyjs.org

Stub README description
43 changes: 43 additions & 0 deletions examples/using-gatsby-transformer-video/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `videos`,
path: `${__dirname}/videos/`,
},
},
{
resolve: `gatsby-transformer-video`,
options: {
profiles: {
sepia: {
extension: `mp4`,
converter: function({ ffmpegSession, videoStreamMetadata }) {
const { currentFps } = videoStreamMetadata

const outputOptions = [
`-crf 31`,
`-preset slow`,
`-movflags +faststart`,
`-profile:v high`,
`-bf 2 `,
`-g ${Math.floor(currentFps / 2)}`,
`-coder 1`,
`-pix_fmt yuv420p`,
].filter(Boolean)

return ffmpegSession
.videoCodec(`libx264`)
.videoFilters(
`colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131`
)
.outputOptions(outputOptions)
.noAudio()
},
},
},
},
},
],
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions examples/using-gatsby-transformer-video/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "using-gatsby-transformer-video",
"private": true,
"description": "Gatsby example site using using-gatsby-transformer-video",
"author": "Benedikt Rötsch <opensource@axe312.de>",
"dependencies": {
"gatsby": "latest",
"gatsby-link": "latest",
"gatsby-source-filesystem": "latest",
"gatsby-transformer-video": "latest"
},
"license": "MIT",
"main": "n/a",
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build"
}
}
124 changes: 124 additions & 0 deletions examples/using-gatsby-transformer-video/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import React from "react"
import { graphql } from "gatsby"

import "./styles.css"

function Video({
video: {
name,
videoH264,
videoH265,
previewH264,
previewWebP,
previewGif,
videoSepia,
videoScreenshots,
},
...props
}) {
return (
<div {...props}>
<h2>Example: {name.substring(0, 1).toUpperCase() + name.substring(1)}</h2>
<h3>Screenshots at 1s, 50% and 99%:</h3>
<div className="screenshots">
{videoScreenshots.map(({ publicURL }) => (
<div key="path">
<img src={publicURL} />
</div>
))}
</div>
<h3>
Animated preview via{` `}
<a href="https://css-tricks.com/fallbacks-videos-images/">
picture element
</a>
:
</h3>
<picture>
<source type="video/mp4" srcSet={previewH264.path} />
<source type="image/webp" srcSet={previewWebP.path} />
<img loading="lazy" src={previewGif.path} alt="" />
</picture>
<h3>Video as optimized h264 &amp; h265:</h3>
<video
playsInline
preload="auto"
poster={videoScreenshots[0].publicURL}
controls
>
<source src={videoH265.path} type="video/mp4; codecs=hevc" />
<source src={videoH264.path} type="video/mp4; codecs=avc1" />
</video>
<h3>Custom video converter:</h3>
<video
playsInline
preload="auto"
poster={videoScreenshots[0].publicURL}
controls
>
<source src={videoSepia.path} type="video/mp4; codecs=avc1" />
</video>
</div>
)
}

const Index = ({ data }) => {
const videos = data.allFile.edges.map(({ node }) => node)

return (
<div>
<h1>Using gatsby-transformer-video</h1>
<div className="grid">
{videos.map(video => (
<Video key={video.id} video={video} />
))}
</div>
</div>
)
}

export default Index

export const query = graphql`
query HomePageQuery {
allFile {
edges {
node {
id
name
videoH264(
overlay: "gatsby.png"
overlayX: "end"
overlayY: "start"
overlayPadding: 25
) {
path
}
videoH265(
overlay: "gatsby.png"
overlayX: "end"
overlayY: "start"
overlayPadding: 25
) {
path
}
videoSepia: videoProfile(profile: "sepia", maxWidth: 800) {
path
}
previewH264: videoH264(maxWidth: 600, fps: 4, duration: 2) {
path
}
previewWebP: videoWebP(maxWidth: 600, fps: 4, duration: 2) {
path
}
previewGif: videoGif(maxWidth: 300, fps: 4, duration: 2) {
path
}
videoScreenshots(timestamps: ["1", "50%", "99%"]) {
publicURL
}
}
}
}
}
`
29 changes: 29 additions & 0 deletions examples/using-gatsby-transformer-video/src/pages/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
body {
font-family: sans-serif;
}

picture,
img,
video {
width: 100%;
height: auto;
}

.grid {
display: flex;
flex-wrap: wrap;
}

.grid > * {
flex: 0 1 420px;
padding: 10px;
overflow: hidden;
}

.screenshots {
display: flex;
justify-content: space-between;
}
.screenshots > * {
flex: 0 1 30%;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/gatsby-transformer-video/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["babel-preset-gatsby-package"]]
}
4 changes: 4 additions & 0 deletions packages/gatsby-transformer-video/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*.js
/profiles/*.js
!index.js
yarn.lock
38 changes: 38 additions & 0 deletions packages/gatsby-transformer-video/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
src
.babelrc.js
*.tgz

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
*.un~
yarn.lock
src
flow-typed
coverage
decls
examples
39 changes: 39 additions & 0 deletions packages/gatsby-transformer-video/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#### 0.2.0 (2020-11-02)

##### Build System / Dependencies

- upgrade dependencies ([2457d172](https://github.com/gatsbyjs/gatsby/commit/2457d1722cf26404ac3db33068d202ff1f58df0d))

##### Chores

- remove debug console.log ([7ee4556d](https://github.com/gatsbyjs/gatsby/commit/7ee4556dda9c588896b2b6eb82c156948df95124))

##### Documentation Changes

- mark as beta and link usage example ([8438fccd](https://github.com/gatsbyjs/gatsby/commit/8438fccd67d95cc22550300a91614c380e4c715f))

##### New Features

- add additional information when video could not be analyzed cus of a broken or unsupported file ([a70ea950](https://github.com/gatsbyjs/gatsby/commit/a70ea950f93e5c26a656c6e95f1ef4a381b2d6d0))
- add width, height and aspect ratio to video nodes ([e1370884](https://github.com/gatsbyjs/gatsby/commit/e1370884e875335751eedb697e3eeb5f949ea301))
- align file naming for files and contentful assets ([240eefe9](https://github.com/gatsbyjs/gatsby/commit/240eefe9213ce818e55c26ef88f1324239527482))
- clean up logging and reporting ([91d50ec7](https://github.com/gatsbyjs/gatsby/commit/91d50ec7df9698b80e789e6be167e635a8265167))
- slightly increase default quality for h264 and h265 ([4b05c482](https://github.com/gatsbyjs/gatsby/commit/4b05c4821506defebc9ebd826f5c59324bbdeb63))
- move default directory into static folder ([767e75f9](https://github.com/gatsbyjs/gatsby/commit/767e75f9fd27bbfb348a543117f374a862d676c6))
- use new reporter API ([dd80e1aa](https://github.com/gatsbyjs/gatsby/commit/dd80e1aa50419edf9ff48f8b54e06fbdc3edf38f))
- move screenshots to extra videoScreenshots resolver ([242e99ea](https://github.com/gatsbyjs/gatsby/commit/242e99ea6956b44e782ac24ed9873b3a4542b582))
- switch to medium preset for h264 and h265 for higher quality, smaller size and almost same conversion time ([370c0d07](https://github.com/gatsbyjs/gatsby/commit/370c0d07e2ec546260a6058dfba7a2de4d7bbbe9))

##### Bug Fixes

- redownload files if actual file on Contentful changed ([53909a2e](https://github.com/gatsbyjs/gatsby/commit/53909a2e57fe6055583a15e7e5e8e1aaca8788f6))
- ensure screenshots are queued ([c61df862](https://github.com/gatsbyjs/gatsby/commit/c61df8623f16e94e7f28c9f5fc0a43b80f0da16c))

##### Refactors

- adjust example to match new screenshots resolver ([73f67b33](https://github.com/gatsbyjs/gatsby/commit/73f67b33b5fbb984fd605f41649a3b4a3da6640b))
- update babelrc to use babel-preset-gatsby-package ([c7371733](https://github.com/gatsbyjs/gatsby/commit/c73717330f8f214166ddfcec4b319805683b866f))

##### Code Style Changes

- reapply eslint ([1c21a16f](https://github.com/gatsbyjs/gatsby/commit/1c21a16f5de8e092a795a2bdb1f4bba0e0b00cca))
Loading