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

Take url as input #1278

Open
Lukkyz opened this issue Jun 6, 2024 · 2 comments
Open

Take url as input #1278

Lukkyz opened this issue Jun 6, 2024 · 2 comments

Comments

@Lukkyz
Copy link

Lukkyz commented Jun 6, 2024

Hello,
I would like to know if it is possible now to take an URL as an input ?

@Lukkyz Lukkyz changed the title Take file url as input Take url as input Jun 6, 2024
@ralyodio
Copy link

ralyodio commented Aug 5, 2024

I'm also wondering this. the example I have doesn't work

async start(url, user = null, pass = null) {
			console.log('Transcoding:', url);
			const headers = {};

			try {
				if (user && pass) {
					const encodedCredentials = Buffer.from(`${user}:${pass}`).toString('base64');
					headers['Authorization'] = `Basic ${encodedCredentials}`;
				}

				// Fetch the video from the URL
				const response = await fetch(url, { headers, redirect: 'follow' });

				if (!response.ok) {
					throw new Error(`Failed to fetch video: ${response.statusText}`);
				}

				// Create a readable stream from the response
				const videoStream = response.body;

				// Create a pass-through stream to handle ffmpeg output
				const stream = new PassThrough();

				// Pipe the video stream through ffmpeg to transcode it to mp4
				ffmpeg(videoStream)
					.format('mp4')
					.videoCodec('libx264')
					.audioCodec('aac')
					.on('error', (err) => {
						console.error('Error:', err.message);
						stream.destroy(err); // destroy the stream in case of error
					})
					.on('end', () => {
						console.log('Transcoding finished');
					})
					.pipe(stream, { end: true }); // ensure the stream ends properly

				return stream;
			} catch (err) {
				throw err;
			}
		}
		```

@ralyodio
Copy link

ralyodio commented Aug 5, 2024

I guess ffmpeg doesn't support Response objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants