
Recherche avancée
Médias (91)
-
Head down (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Echoplex (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Discipline (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
Letting you (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
1 000 000 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
-
999 999 (wav version)
26 septembre 2011, par
Mis à jour : Avril 2013
Langue : English
Type : Audio
Autres articles (104)
-
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Keeping control of your media in your hands
13 avril 2011, parThe vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)
Sur d’autres sites (11910)
-
Write EPIPE after upgrade Node.js
30 juillet, par RougherI am using this code for detecting audio replay gain. It was working well with Node.js 16, but after upgrading to Node.js 22, it started crashing a few times in an hour with this error :


write EPIPE
 at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19) {
 errno: -32,
 code: 'EPIPE',
 syscall: 'write'
}



My original code was


static getReplayGainVolume(audioData: Buffer) {
 // Calculate the mean volume of the audio file at the given filePath
 var ffmpeg = spawn('ffmpeg', [
 '-i', '-',
 '-af', 'replaygain',
 '-f', 'null', '/dev/null',
 '-hide_banner', '-nostats'
 ]);

 var output = '';

 ffmpeg.stdin.write(audioData);
 ffmpeg.stdin.end();

 return new Promise((resolve,reject)=>{
 ffmpeg.on('error', function (err: any) {
 reject(err);
 });
 
 ffmpeg.on('close', function (_code: any) {
 // [Parsed_replaygain_0 @ 0000000002a2b5c0] track_gain = +6.53 dB
 if (!output.includes("track_gain")) {
 reject(output);

 return;
 }

 const gainWithDb = output.split("track_gain = ")[1];
 if (!gainWithDb) {
 reject(output);

 return;
 }

 const gain = gainWithDb.split(" dB")[0];
 if (!gain) {
 reject(output);

 return;
 }

 resolve(parseFloat(gain));
 });
 
 ffmpeg.stderr.on('data', function (data: any) {
 // ffmpeg sends all output to stderr. It is not a bug, it is a feature :)
 var tData = data.toString('utf8');
 output += tData;
 });
 });
 }



Then after search in forums and Google, I improved (I hope I improved it with cleanups)


static getReplayGainVolume(audioData: Buffer): Promise<number> {
 return new Promise((resolve, reject) => {
 const FFMPEG_PATH = 'ffmpeg'; // Adjust this if ffmpeg is not in system PATH
 const FFMPEG_TIMEOUT_MS = 30 * 1000; // 30 seconds timeout for FFmpeg execution

 let ffmpeg: ChildProcessWithoutNullStreams;
 let output = ''; // Accumulate all stderr output

 // Timeout for the FFmpeg process itself
 const ffmpegTimeout = setTimeout(() => {
 log.error(`[FFmpeg] FFmpeg process timed out after ${FFMPEG_TIMEOUT_MS / 1000} seconds. Killing process.`);
 if (ffmpeg && !ffmpeg.killed) {
 ffmpeg.kill('SIGKILL'); // Force kill
 reject(new Error(`FFmpeg process timed out and was killed.`));
 }
 }, FFMPEG_TIMEOUT_MS);

 // --- Define cleanup function to be called on process exit/error ---
 const cleanup = (shouldReject = false, error?: Error | string) => {
 clearTimeout(ffmpegTimeout); // Ensure timeout is cleared

 // Remove all listeners to prevent leaks
 // This is CRITICAL for long-running bots that spawn many child processes
 ffmpeg.stdin.removeAllListeners();
 ffmpeg.stdout.removeAllListeners();
 ffmpeg.stderr.removeAllListeners();
 ffmpeg.removeAllListeners(); // Remove process listeners

 if (ffmpeg && !ffmpeg.killed) { // Ensure ffmpeg process is killed if still alive
 ffmpeg.kill(); // Graceful kill (SIGTERM), then wait for exit. If not, then SIGKILL.
 }

 if (shouldReject) {
 reject(error instanceof Error ? error : new Error(String(error)));
 }
 };

 try {
 ffmpeg = spawn(FFMPEG_PATH, [
 '-i', 'pipe:0', // Read input from stdin (pipe:0)
 '-af', 'replaygain',
 '-f', 'null', '/dev/null', // Write output to null device (discard audio output)
 '-hide_banner', '-nostats' // Suppress ffmpeg's initial info and progress stats
 ], { stdio: ['pipe', 'pipe', 'pipe'] }); // Explicitly pipe stdin, stdout, stderr

 // --- CRITICAL: Event Handlers for ffmpeg process ---

 // 1. Handle errors during spawning or execution (e.g., ffmpeg not found)
 ffmpeg.on('error', (err: any) => {
 log.error(`[FFmpeg] Failed to spawn or execute FFmpeg process:`, err);
 cleanup(true, new Error(`FFmpeg process error: ${err.message}`));
 });

 // 2. Accumulate stderr output (where replaygain results and ffmpeg errors are printed)
 ffmpeg.stderr.on('data', (data: Buffer) => {
 output += data.toString('utf8');
 });

 // 3. Handle process exit (success or failure)
 ffmpeg.on('close', (code: number) => { // 'close' indicates process has exited
 log.debug(`[FFmpeg] FFmpeg process exited with code: ${code}.`);
 if (code !== 0) { // Non-zero exit code means failure
 log.error(`[FFmpeg] FFmpeg process exited with non-zero code ${code}. Output:\n${output}`);
 cleanup(true, new Error(`FFmpeg process failed with exit code ${code}. Output: ${output}`));
 return;
 }

 // If successful exit (code 0), parse the output
 if (!output.includes("track_gain")) {
 log.error(`[FFmpeg] 'track_gain' not found in FFmpeg output (exit code 0). Output:\n${output}`);
 cleanup(true, new Error(`'track_gain' not found in FFmpeg output. Output: ${output}`));
 return;
 }

 try {
 // Regex to parse track_gain (e.g., "+6.53 dB" or "-12.00 dB")
 const gainMatch = output.match(/track_gain\s*=\s*([+-]?\d+\.?\d*)\s*dB/);
 if (gainMatch && gainMatch[1]) {
 const gain = parseFloat(gainMatch[1]);
 log.debug(`[FFmpeg] Replay gain volume: ${gain} dB.`);
 cleanup(); // Clean up on success
 resolve(gain);
 } else {
 log.error(`[FFmpeg] Failed to parse gain from FFmpeg output. Output:\n${output}`);
 cleanup(true, new Error(`Failed to parse gain from FFmpeg output. Output: ${output}`));
 }
 } catch (parseError: any) {
 log.error(`[FFmpeg] Error parsing FFmpeg replay gain output:`, parseError);
 cleanup(true, new Error(`Error parsing FFmpeg output: ${parseError.message}. Output: ${output}`));
 }
 });

 // 4. Write audio data to ffmpeg's stdin
 // This is the only write operation that could throw EPIPE in this function.
 try {
 ffmpeg.stdin.write(audioData);
 ffmpeg.stdin.end(); // Close stdin to signal end of input
 } catch (stdinError: any) {
 log.error(`[FFmpeg] Error writing audioData to FFmpeg stdin:`, stdinError);
 // This error means ffmpeg's stdin pipe closed unexpectedly.
 // This is the direct equivalent of an EPIPE (Broken Pipe) at the child process level.
 cleanup(true, new Error(`Failed to pipe audio data to FFmpeg stdin: ${stdinError.message}`));
 }

 } catch (spawnError: any) { // Catch errors from the spawn call itself (e.g., FFMPEG_PATH is invalid)
 log.error(`[FFmpeg] Error spawning FFmpeg:`, spawnError);
 cleanup(true, new Error(`Failed to spawn FFmpeg process: ${spawnError.message}`));
 }
 });
 }
</number>


But unfortunately I still get the same error. Has anyone encountered this problem ? How can I solve it ?


I use ffmpeg version 4.2.7-0ubuntu0.1


-
Write EPIPE after upgrade NodeJS
28 juillet, par RougherI am using this code for detecting audio replay gain. It was working well with NodeJs 16, but after upgrading to NodeJs 22, it started crashing a few times in an hour with this error :


write EPIPE
 at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19) {
 errno: -32,
 code: 'EPIPE',
 syscall: 'write'
}



My original code was


static getReplayGainVolume(audioData: Buffer) {
 // Calculate the mean volume of the audio file at the given filePath
 var ffmpeg = spawn('ffmpeg', [
 '-i', '-',
 '-af', 'replaygain',
 '-f', 'null', '/dev/null',
 '-hide_banner', '-nostats'
 ]);

 var output = '';

 ffmpeg.stdin.write(audioData);
 ffmpeg.stdin.end();

 return new Promise((resolve,reject)=>{
 ffmpeg.on('error', function (err: any) {
 reject(err);
 });
 
 ffmpeg.on('close', function (_code: any) {
 // [Parsed_replaygain_0 @ 0000000002a2b5c0] track_gain = +6.53 dB
 if (!output.includes("track_gain")) {
 reject(output);

 return;
 }

 const gainWithDb = output.split("track_gain = ")[1];
 if (!gainWithDb) {
 reject(output);

 return;
 }

 const gain = gainWithDb.split(" dB")[0];
 if (!gain) {
 reject(output);

 return;
 }

 resolve(parseFloat(gain));
 });
 
 ffmpeg.stderr.on('data', function (data: any) {
 // ffmpeg sends all output to stderr. It is not a bug, it is a feature :)
 var tData = data.toString('utf8');
 output += tData;
 });
 });
 }



Then after search in forums and Google, I improved (I hope I improved it with cleanups)


static getReplayGainVolume(audioData: Buffer): Promise<number> {
 return new Promise((resolve, reject) => {
 const FFMPEG_PATH = 'ffmpeg'; // Adjust this if ffmpeg is not in system PATH
 const FFMPEG_TIMEOUT_MS = 30 * 1000; // 30 seconds timeout for FFmpeg execution

 let ffmpeg: ChildProcessWithoutNullStreams;
 let output = ''; // Accumulate all stderr output

 // Timeout for the FFmpeg process itself
 const ffmpegTimeout = setTimeout(() => {
 log.error(`[FFmpeg] FFmpeg process timed out after ${FFMPEG_TIMEOUT_MS / 1000} seconds. Killing process.`);
 if (ffmpeg && !ffmpeg.killed) {
 ffmpeg.kill('SIGKILL'); // Force kill
 reject(new Error(`FFmpeg process timed out and was killed.`));
 }
 }, FFMPEG_TIMEOUT_MS);

 // --- Define cleanup function to be called on process exit/error ---
 const cleanup = (shouldReject = false, error?: Error | string) => {
 clearTimeout(ffmpegTimeout); // Ensure timeout is cleared

 // Remove all listeners to prevent leaks
 // This is CRITICAL for long-running bots that spawn many child processes
 ffmpeg.stdin.removeAllListeners();
 ffmpeg.stdout.removeAllListeners();
 ffmpeg.stderr.removeAllListeners();
 ffmpeg.removeAllListeners(); // Remove process listeners

 if (ffmpeg && !ffmpeg.killed) { // Ensure ffmpeg process is killed if still alive
 ffmpeg.kill(); // Graceful kill (SIGTERM), then wait for exit. If not, then SIGKILL.
 }

 if (shouldReject) {
 reject(error instanceof Error ? error : new Error(String(error)));
 }
 };

 try {
 ffmpeg = spawn(FFMPEG_PATH, [
 '-i', 'pipe:0', // Read input from stdin (pipe:0)
 '-af', 'replaygain',
 '-f', 'null', '/dev/null', // Write output to null device (discard audio output)
 '-hide_banner', '-nostats' // Suppress ffmpeg's initial info and progress stats
 ], { stdio: ['pipe', 'pipe', 'pipe'] }); // Explicitly pipe stdin, stdout, stderr

 // --- CRITICAL: Event Handlers for ffmpeg process ---

 // 1. Handle errors during spawning or execution (e.g., ffmpeg not found)
 ffmpeg.on('error', (err: any) => {
 log.error(`[FFmpeg] Failed to spawn or execute FFmpeg process:`, err);
 cleanup(true, new Error(`FFmpeg process error: ${err.message}`));
 });

 // 2. Accumulate stderr output (where replaygain results and ffmpeg errors are printed)
 ffmpeg.stderr.on('data', (data: Buffer) => {
 output += data.toString('utf8');
 });

 // 3. Handle process exit (success or failure)
 ffmpeg.on('close', (code: number) => { // 'close' indicates process has exited
 log.debug(`[FFmpeg] FFmpeg process exited with code: ${code}.`);
 if (code !== 0) { // Non-zero exit code means failure
 log.error(`[FFmpeg] FFmpeg process exited with non-zero code ${code}. Output:\n${output}`);
 cleanup(true, new Error(`FFmpeg process failed with exit code ${code}. Output: ${output}`));
 return;
 }

 // If successful exit (code 0), parse the output
 if (!output.includes("track_gain")) {
 log.error(`[FFmpeg] 'track_gain' not found in FFmpeg output (exit code 0). Output:\n${output}`);
 cleanup(true, new Error(`'track_gain' not found in FFmpeg output. Output: ${output}`));
 return;
 }

 try {
 // Regex to parse track_gain (e.g., "+6.53 dB" or "-12.00 dB")
 const gainMatch = output.match(/track_gain\s*=\s*([+-]?\d+\.?\d*)\s*dB/);
 if (gainMatch && gainMatch[1]) {
 const gain = parseFloat(gainMatch[1]);
 log.debug(`[FFmpeg] Replay gain volume: ${gain} dB.`);
 cleanup(); // Clean up on success
 resolve(gain);
 } else {
 log.error(`[FFmpeg] Failed to parse gain from FFmpeg output. Output:\n${output}`);
 cleanup(true, new Error(`Failed to parse gain from FFmpeg output. Output: ${output}`));
 }
 } catch (parseError: any) {
 log.error(`[FFmpeg] Error parsing FFmpeg replay gain output:`, parseError);
 cleanup(true, new Error(`Error parsing FFmpeg output: ${parseError.message}. Output: ${output}`));
 }
 });

 // 4. Write audio data to ffmpeg's stdin
 // This is the only write operation that could throw EPIPE in this function.
 try {
 ffmpeg.stdin.write(audioData);
 ffmpeg.stdin.end(); // Close stdin to signal end of input
 } catch (stdinError: any) {
 log.error(`[FFmpeg] Error writing audioData to FFmpeg stdin:`, stdinError);
 // This error means ffmpeg's stdin pipe closed unexpectedly.
 // This is the direct equivalent of an EPIPE (Broken Pipe) at the child process level.
 cleanup(true, new Error(`Failed to pipe audio data to FFmpeg stdin: ${stdinError.message}`));
 }

 } catch (spawnError: any) { // Catch errors from the spawn call itself (e.g., FFMPEG_PATH is invalid)
 log.error(`[FFmpeg] Error spawning FFmpeg:`, spawnError);
 cleanup(true, new Error(`Failed to spawn FFmpeg process: ${spawnError.message}`));
 }
 });
 }
</number>


But unfortunately I still get the same error. Has anyone encountered this problem ? How can I solve it ?


I use ffmpeg version 4.2.7-0ubuntu0.1


Thanks.


-
FFmpeg-wasm unpredictable errors with next js
21 juillet, par hjtomiI use ffmpeg-wasm in next-js.


Whenever I execute an ffmpeg command it has a chance that it throws a runtime error "memory access out of bounds". In this case I created a page that has an file selection html element and a button that converts each image to
.jpeg
format with the following command :

await ffmpeg.exec(['-i', originalFileName, '-q:v', '5', convertedFileName]);



I have tried the same process with different images, extensions, sizes, restarting the application, restarting the computer, different browsers, mobile/desktop and sometimes it works, sometimes it doesn't. I feel like there is something that is out of my control.


Maybe something that has to do with webassembly itself.


In each runtime it has a 50-50 chance that ffmpeg will work or not.


I have tried changing the target extension to different types.


I have tried changing the ffmpeg command entirely to make it do something else.


Writing the files to the virtual file system works as expected.


I am on windows 10 using next-js version 15.3.5 and ffmpeg version 0.12.10


'use client';

import * as React from 'react';
import { FFmpeg } from '@ffmpeg/ffmpeg'; // Import FFmpeg
import { fetchFile, toBlobURL } from '@ffmpeg/util'; // Import fetchFile

export default function Page() {
 const [files, setFiles] = React.useState([]);
 const [error, setError] = React.useState<string null="null">(null);

 // FFmpeg related states and ref
 const ffmpegRef = React.useRef<ffmpeg null="null">(null);
 const [ffmpegLoaded, setFFmpegLoaded] = React.useState(false);
 const [isConvertingImages, setIsConvertingImages] = React.useState(false);
 const [videoGenerationProgress, setVideoGenerationProgress] = React.useState<string>('');

 // --- Load FFmpeg on component mount ---
 React.useEffect(() => {
 const loadFFmpeg = async () => {
 const baseURL = "https://unpkg.com/@ffmpeg/core@0.12.10/dist/umd";
 try {
 const ffmpeg = new FFmpeg();
 // Set up logging for FFmpeg progress
 ffmpeg.on('log', ({ message }) => {
 if (message.includes('frame=')) {
 setVideoGenerationProgress(message);
 }
 });
 await ffmpeg.load({
 coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
 wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
 });
 ffmpegRef.current = ffmpeg;
 setFFmpegLoaded(true);
 console.log('FFmpeg loaded successfully!');
 } catch (err) {
 console.error('Failed to load FFmpeg:', err);
 setError('Failed to load video processing tools.');
 }
 };

 loadFFmpeg();
 }, []);

 // --- Internal file selection logic ---
 const handleFileChange = (e: React.ChangeEvent<htmlinputelement>) => {
 if (e.target.files && e.target.files.length > 0) {
 const newFiles = Array.from(e.target.files).filter(file => file.type.startsWith('image/')); // Only accept images
 setFiles(newFiles);
 setError(null);
 }
 };

 // --- Handle Image conversion ---
 const handleConvertImages = async () => {
 if (!ffmpegLoaded || !ffmpegRef.current) {
 setError('FFmpeg is not loaded yet. Please wait.');
 return;
 }
 if (files.length === 0) {
 setError('Please select images first to generate a video.');
 return;
 }

 setIsConvertingImages(true);
 setError(null);
 setVideoGenerationProgress('');

 try {
 const ffmpeg = ffmpegRef.current;
 const targetExtension = 'jpeg'; // <--- Define your target extension here (e.g., 'png', 'webp')
 const convertedImageNames: string[] = [];

 // Convert all uploaded images to the target format
 for (let i = 0; i < files.length; i++) {
 const file = files[i];
 // Give the original file a unique name in FFmpeg's VFS
 const originalFileName = `original_image_${String(i).padStart(3, '0')}.${file.name.split('.').pop()}`;
 // Define the output filename with the target extension
 const convertedFileName = `converted_image_${String(i).padStart(3, '0')}.${targetExtension}`;
 convertedImageNames.push(convertedFileName);

 // Write the original file data to FFmpeg's virtual file system
 await ffmpeg.writeFile(`${originalFileName}`, await fetchFile(file));
 console.log(`Wrote original ${originalFileName} to FFmpeg FS`);

 setVideoGenerationProgress(`Converting ${file.name} to ${targetExtension.toUpperCase()}...`);

 await ffmpeg.exec(['-i', originalFileName, '-q:v', '5', convertedFileName]); // <------

 console.log(`Converted ${originalFileName} to ${convertedFileName}`);

 // Delete the original file from VFS to free up memory
 await ffmpeg.deleteFile(originalFileName);
 console.log(`Deleted original ${originalFileName} from FFmpeg FS`);
 }

 setFiles([]);

 setVideoGenerationProgress(`All images converted to ${targetExtension.toUpperCase()}.`);
 } catch (err) {
 console.error('Error converting images:', err);
 setError(`Failed to convert images: ${err instanceof Error ? err.message : String(err)}`);
 } finally {
 setIsConvertingImages(false);
 }
 };

 return (
 <div classname="min-h-screen bg-gray-100 flex items-center justify-center p-4 relative overflow-hidden">
 <div classname="bg-white p-8 rounded-lg shadow-xl w-full max-w-md z-10 relative"> {/* Ensure content is above overlay */}
 <h2 classname="text-2xl font-semibold text-gray-800 mb-6 text-center">Select your images</h2>

 {/* Regular File Input Area (still needed for click-to-select) */}
 > document.getElementById('file-input')?.click()}
 >
 
 
 <svg classname="mx-auto h-12 w-12 text-gray-400" fill="none" viewbox="0 0 24 24" stroke="currentColor">
 <path strokelinecap="round" strokelinejoin="round" strokewidth="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
 </svg>
 <p classname="mt-2 text-sm text-gray-600">
 <span classname="font-medium text-blue-600">Click to select</span>
 </p>
 <p classname="text-xs text-gray-500">Supports multiple formats</p>
 </div>

 {/* Selected Files Display */}
 {files.length > 0 && (
 <div data-testid="selected-files-display" classname="selected-files-display mt-4 p-3 bg-blue-50 border border-blue-200 rounded-md text-sm text-blue-800">
 <p classname="font-semibold mb-2">Selected Files ({files.length}):</p>
 <ul classname="max-h-40 overflow-y-auto">
 {files.map((file) => (
 <li key="{file.name}" classname="flex items-center justify-between py-1">
 <span>{file.name}</span>
 </li>
 ))}
 </ul>
 </div>
 )}

 {/* Error Message */}
 {error && (
 <div classname="mt-4 p-3 bg-red-50 border border-red-200 rounded-md text-sm text-red-800">
 {error}
 </div>
 )}

 {/* Image conversion Progress/Status */}
 {isConvertingImages && (
 <div classname="mt-4 p-3 bg-purple-50 border border-purple-200 rounded-md text-sm text-purple-800 text-center">
 <p classname="font-semibold">Converting images</p>
 <p classname="text-xs mt-1">{videoGenerationProgress}</p>
 </div>
 )}
 {!ffmpegLoaded && (
 <div classname="mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-sm text-yellow-800 text-center">
 Loading video tools (FFmpeg)... Please wait.
 </div>
 )}

 {/* Convert images button */}
 
 Convert images
 
 </div>
 
 );
}
</htmlinputelement></string></ffmpeg></string>


The next js page above