Skip to content

Commit

Permalink
ffmpeg trick
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpetrov authored and OdapX committed Dec 10, 2023
1 parent 384a5e1 commit fad3827
Show file tree
Hide file tree
Showing 17 changed files with 3,837 additions and 14,572 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const options: DatsourceOption[] = [
{
type: DatasourceType.file,
label: 'File',
description: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel',
description:
'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel, Audio',
disabled: false,
},
{
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/components/DatasourceForms/FileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ function Nested() {
Select or Drop file
</Button>
<Typography level="body-xs" textAlign={'center'} mt={2}>
PDF, PowerPoint, Excel, Word, Text, Markdown,
PDF, PowerPoint, Excel, Word, Text, Markdown and
<span className="font-bold"> Audio !</span>
</Typography>
<UsageLimitModal
isOpen={state.isUsageLimitModalOpen}
Expand Down
25 changes: 25 additions & 0 deletions apps/dashboard/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ const nextConfig = {
bullmq: 'commonjs bullmq',
});

config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, '../../packages/lib/ffmpeg/index.js'),
to: path.resolve(
__dirname,
'../../packages/lib/node_modules/fluent-ffmpeg'
),
toType: 'dir',
force: true, // Overwrite the existing index.js
},
],
})
);

config.plugins.push(
new CopyWebpackPlugin({
patterns: [
Expand Down Expand Up @@ -263,6 +279,15 @@ const nextConfig = {
);
},
},
{
from: path.resolve(__dirname, '../../packages/lib/ffmpeg/index.js'),
to: path.resolve(
__dirname,
'../../packages/lib/node_modules/fluent-ffmpeg'
),
toType: 'dir',
force: true, // Overwrite the existing index.js
},
],
})
);
Expand Down
7 changes: 5 additions & 2 deletions packages/lib/audio-helpers/ffmpegSlicer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { path as ffmpegPath } from '@ffmpeg-installer/ffmpeg';
import ffmpeg from 'fluent-ffmpeg';
import { PassThrough, Readable } from 'stream';

import ffmpeg from '../fluent-ffmpeg';

interface Args {
res: Readable;
startTime: number;
duration: number;
}

// pass the binary path to ffmpeg.
ffmpeg.setFfmpegPath(ffmpegPath);

async function sliceAudioStream({ res, startTime, duration }: Args) {
return new Promise((resolve, reject) => {
const bufferStream = new PassThrough();
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/ffmpeg/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// used to override the default fluent-ffmpeg entry file.
module.exports = require('./lib/fluent-ffmpeg');
Loading

0 comments on commit fad3827

Please sign in to comment.