Skip to content

Commit

Permalink
feat: add dependency of ffmpeg + clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilly2fast committed Sep 1, 2024
1 parent 5fd2f2f commit ea86a3b
Show file tree
Hide file tree
Showing 16 changed files with 878 additions and 811 deletions.
428 changes: 208 additions & 220 deletions dev/plugin.spec.ts

Large diffs are not rendered by default.

134 changes: 67 additions & 67 deletions dev/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,75 +39,75 @@ import { OverrideSegments } from './collections/OverrideSegments'
// })

export default buildConfig({
admin: {
user: Users.slug,
bundler: webpackBundler(),
webpack: config => {
const newConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...(config?.resolve?.alias || {}),
react: path.join(__dirname, '../node_modules/react'),
'react-dom': path.join(__dirname, '../node_modules/react-dom'),
payload: path.join(__dirname, '../node_modules/payload'),
},
},
}
return newConfig
admin: {
user: Users.slug,
bundler: webpackBundler(),
webpack: config => {
const newConfig = {
...config,
resolve: {
...config.resolve,
alias: {
...(config?.resolve?.alias || {}),
react: path.join(__dirname, '../node_modules/react'),
'react-dom': path.join(__dirname, '../node_modules/react-dom'),
payload: path.join(__dirname, '../node_modules/payload'),
},
},
}
return newConfig
},
cors: '*',
editor: slateEditor({}),
collections: [Users, Media, Videos],
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL,
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [
abrVideos({
enabled: true,
collections: {
media: {
keepOriginal: false,
},
videos: {
keepOriginal: true,
resolutions: [
{ size: 144, bitrate: 150 },
{ size: 240, bitrate: 250 },
{ size: 300, bitrate: 500 },
],
segmentDuration: 1,
},
},
segmentsOverrides: OverrideSegments,
}),
// cloudStorage({
// collections: {
// media: {
// adapter: adapter,
// prefix: 'test-media',
// disableLocalStorage: true,
// },
// 'override-segments': {
// adapter: adapter,
// prefix: 'segments',
// disableLocalStorage: true,
// },
// },
// }),
],
db: mongooseAdapter({
url: process.env.DATABASE_URI!,
}),
upload: {
limits: {
fileSize: 50000000, // 5MB, written in bytes
},
cors: '*',
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL,
editor: slateEditor({}),
collections: [Users, Media, Videos],
typescript: {
outputFile: path.resolve(__dirname, 'payload-types.ts'),
},
graphQL: {
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
},
plugins: [
abrVideos({
enabled: true,
collections: {
media: {
keepOriginal: false,
},
videos: {
keepOriginal: true,
resolutions: [
{ size: 144, bitrate: 150 },
{ size: 240, bitrate: 250 },
{ size: 300, bitrate: 500 },
],
segmentDuration: 1,
},
},
segmentsOverrides: OverrideSegments,
}),
// cloudStorage({
// collections: {
// media: {
// adapter: adapter,
// prefix: 'test-media',
// disableLocalStorage: true,
// },
// 'override-segments': {
// adapter: adapter,
// prefix: 'segments',
// disableLocalStorage: true,
// },
// },
// }),
],
db: mongooseAdapter({
url: process.env.DATABASE_URI!,
}),
upload: {
limits: {
fileSize: 50000000, // 500MB, written in bytes
},
},
})
22 changes: 11 additions & 11 deletions dev/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ require('dotenv').config()
const app = express()

app.get('/', (_, res) => {
res.redirect('/admin')
res.redirect('/admin')
})

const PORT = 3000
export const start = async (args?: Partial<InitOptions>) => {
await payload.init({
secret: process.env.PAYLOAD_SECRET,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
...(args || {}),
})
await payload.init({
secret: process.env.PAYLOAD_SECRET,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
...(args || {}),
})

return app.listen(PORT)
return app.listen(PORT)
}

if (require.main === module) {
start()
start()
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-adaptive-bitrate-videos",
"version": "1.0.5",
"version": "1.1.0",
"homepage:": "https://github.com/cgilly2fast/plugin-adaptive-bitrate-videos",
"repository": "[email protected]:cgilly2fast/plugin-adaptive-bitrate-videos.git",
"description": "Payload plugin for automatic adaptive bitrate process of videos.",
Expand All @@ -25,11 +25,11 @@
"clean": "rimraf dist && rimraf dev/yarn.lock",
"prepublishOnly": "yarn clean && yarn build && cd dev && yarn test"
},
"author": "Colby Gilbert",
"license": "MIT",
"bugs": {
"url": "https://github.com/cgilly2fast/plugin-adaptive-bitrate-videos/issues"
},
"author": "Colby Gilbert",
"license": "MIT",
"bugs": {
"url": "https://github.com/cgilly2fast/plugin-adaptive-bitrate-videos/issues"
},
"peerDependencies": {
"payload": "^2.0.0"
},
Expand All @@ -55,6 +55,8 @@
"webpack": "^5.90.3"
},
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@ffprobe-installer/ffprobe": "^2.1.2",
"fluent-ffmpeg": "^2.1.3"
}
}
36 changes: 18 additions & 18 deletions src/collections/Segments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ import type { CollectionConfig } from 'payload/types'
import type { PluginOptions } from '../types'

export const generateSegmentsCollection = (pluginOptions: PluginOptions): CollectionConfig => {
const newConfig: CollectionConfig = {
...(pluginOptions?.segmentsOverrides || {}),
slug: pluginOptions?.segmentsOverrides?.slug || 'segments',
access: {
read: () => true,
update: () => false,
...(pluginOptions?.segmentsOverrides?.access || {}),
},
admin: {
...(pluginOptions?.segmentsOverrides?.admin || {}),
},
fields: [...(pluginOptions?.segmentsOverrides?.fields || [])],
hooks: {
...(pluginOptions?.segmentsOverrides?.hooks || {}),
},
upload: true,
}
const newConfig: CollectionConfig = {
...(pluginOptions?.segmentsOverrides || {}),
slug: pluginOptions?.segmentsOverrides?.slug || 'segments',
access: {
read: () => true,
update: () => false,
...(pluginOptions?.segmentsOverrides?.access || {}),
},
admin: {
...(pluginOptions?.segmentsOverrides?.admin || {}),
},
fields: [...(pluginOptions?.segmentsOverrides?.fields || [])],
hooks: {
...(pluginOptions?.segmentsOverrides?.hooks || {}),
},
upload: true,
}

return newConfig
return newConfig
}
10 changes: 0 additions & 10 deletions src/components/AfterDashboard/index.scss

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/AfterDashboard/index.tsx

This file was deleted.

Loading

0 comments on commit ea86a3b

Please sign in to comment.