
Recherche avancée
Autres articles (67)
-
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
Sur d’autres sites (11780)
-
How to Correctly Implement ffmpeg Complex Filters in Node.js for Image Processing ?
24 janvier 2024, par LukeProblem :


I am trying to add filters and transitions between my image slideshow array, and am struggling to apply the proper filters. For example, I get errors like this :


{
 "errorType": "Error",
 "errorMessage": "ffmpeg exited with code 234: Failed to set value 'fade=type=in:start_time=0:duration=1,zoompan=z=zoom+0.002:d=120:x=if(gte(zoom,1.2),x,x+1):y=if(gte(zoom,1.2),y,y+1)' for option 'filter_complex': Invalid argument\nError parsing global options: Invalid argument\n",
 "trace": [
 "Error: ffmpeg exited with code 234: Failed to set value 'fade=type=in:start_time=0:duration=1,zoompan=z=zoom+0.002:d=120:x=if(gte(zoom,1.2),x,x+1):y=if(gte(zoom,1.2),y,y+1)' for option 'filter_complex': Invalid argument",
 "Error parsing global options: Invalid argument",
 "",
 " at ChildProcess.<anonymous> (/opt/nodejs/node_modules/fluent-ffmpeg/lib/processor.js:182:22)",
 " at ChildProcess.emit (node:events:517:28)",
 " at ChildProcess._handle.onexit (node:internal/child_process:292:12)"
 ]
}
</anonymous>


Lambda Function Code :


async function concat(bucketName, imageKeys) {
 const imageStreams = await Promise.all(
 imageKeys.map(async (key, i) => {
 const command = new GetObjectCommand({ Bucket: bucketName, Key: key });
 const response = await s3.send(command);
 // Define the temporary file path based on the index
 const tempFilePath = `/tmp/${i}.png`;
 
 // Write the image data to the temporary file
 await fs.writeFile(tempFilePath, response.Body);
 
 // Return the file path to be used later
 return tempFilePath;
 })
 );
 
 // Create a file list content with durations
 let fileContent = "";
 for (let i = 0; i < imageStreams.length; i++) {
 fileContent += `file '${imageStreams[i]}'\nduration 1\n`;
 
 // Check if it's the last image, and if so, add it again
 if (i === imageStreams.length - 1) {
 fileContent += `file '${imageStreams[i]}'\nduration 1\n`;
 }
 }
 
 // Define the file path for the file list
 const fileListPath = "/tmp/file_list.txt";
 
 // Write the file list content to the file
 await fs.writeFile(fileListPath, fileContent);
 
 try {
 await fs.writeFile(fileListPath, fileContent);
 } catch (error) {
 console.error("Error writing file list:", error);
 throw error;
 }
 
 // Create a complex filter to add zooms and pans
 // Simplified filter example
 let complexFilter = [
 // Example of a fade transition
 {
 filter: 'fade',
 options: { type: 'in', start_time: 0, duration: 1 },
 inputs: '0:v', // first video stream
 outputs: 'fade0'
 },
 // Example of dynamic zoompan
 {
 filter: 'zoompan',
 options: {
 z: 'zoom+0.002',
 d: 120, // duration for this image
 x: 'if(gte(zoom,1.2),x,x+1)', // dynamic x position
 y: 'if(gte(zoom,1.2),y,y+1)' // dynamic y position
 },
 inputs: 'fade0',
 outputs: 'zoom0'
 }
 // Continue adding filters for each image
 ];

 let filterString = complexFilter
 .map(
 (f) =>
 `${f.filter}=${Object.entries(f.options)
 .map(([key, value]) => `${key}=${value}`)
 .join(":")}`
 )
 .join(",");
 
 let filterString = complexFilter
 .map(
 (f) =>
 `${f.filter}=${Object.entries(f.options)
 .map(([key, value]) => `${key}=${value}`)
 .join(":")}`
 )
 .join(",");
 
 console.log("Filter String:", filterString);
 
 return new Promise((resolve, reject) => {
 ffmpeg()
 .input(fileListPath)
 .complexFilter(filterString)
 .inputOptions(["-f concat", "-safe 0"])
 .outputOptions("-c copy")
 .outputOptions("-c:v libx264")
 .outputOptions("-pix_fmt yuv420p")
 .outputOptions("-r 30")
 .on("end", () => {
 resolve();
 })
 .on("error", (err) => {
 console.error("Error during video concatenation:", err);
 reject(err);
 })
 .saveToFile("/tmp/output.mp4");
 });
 }



Filter String Console Log :


Filter String: fade=type=in:start_time=0:duration=1,zoompan=z=zoom+0.002:d=120:x=if(gte(zoom,1.2),x,x+1):y=if(gte(zoom,1.2),y,y+1)



Questions :


- 

- What is the correct syntax for implementing complex filters like zoompan and fade in ffmpeg when used in a Node.js environment ?
- How do I ensure the filters are applied correctly to each image in the sequence ?
- Is there a better way to dynamically generate these filters based on the number of images or their content ?








Any insights or examples of correctly implementing this would be greatly appreciated !


-
How do I merge images and an audio file into a single video ?
3 janvier 2024, par AnilI am creating a web application using next js.
I want to create a video by combining three images and an audio track in such a way that each image is displayed for an equal duration that collectively matches the length of the audio. It will all happen locally on the browser.


This is my code for converting images and audio into a video.


import {FFmpeg} from '@ffmpeg/ffmpeg';
import { fetchFile, toBlobURL } from '@ffmpeg/util';


export async function createVideo(ImageFiles, audioFile) {

 try {
 const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.4/dist/umd';
 const ffmpeg = new FFmpeg({ log: true});

 console.log('Loading ffmpeg core');
 await ffmpeg.load({
 corePath: await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
 wasmPath: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
 });
 await ffmpeg.load();
 console.log('Finished loading ffmpeg core');

 for (let i = 0; i < ImageFiles.length; i++) {
 ffmpeg.writeFile(
 `image${i+1}.jpg`,
 await fetchFile(ImageFiles[i].imageUrl)
 );
 }

 ffmpeg.FS('writeFile', 'audio.mp3', await fetchFile(audioFile));


 const durationPerImage = (await getAudioDuration(ffmpeg, 'audio.mp3')) / ImageFiles.length;
 let filterComplex = '';
 for (let i = 0; i < ImageFiles.length - 1; i++) {filterComplex += `[${i}:v]trim=duration=${durationPerImage},setpts=PTS-STARTPTS[v${i}]; `;
 }
 filterComplex += `${ImageFiles.slice(0, -1).map((_, i) => `[v${i}]`).join('')}concat=n=${ImageFiles.length - 1}:v=1:a=0,format=yuv420p[v];`;

 await ffmpeg.run(
 '-framerate', '1', '-loop', '1', '-t', durationPerImage, '-i', 'image%d.jpg', '-i', 'audio.mp3',
 '-filter_complex', filterComplex, '-map', '[v]', '-map', '1:a',
 '-c:v', 'libx264', '-tune', 'stillimage', '-c:a', 'aac', '-b:a', '192k', 'output.mp4'
 );

 const data = ffmpeg.FS('readFile', 'output.mp4');

 const videoURL = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
 return videoURL;
 } catch (error) {
 console.error('Error creating video:', error);
 throw new Error('Failed to create video');
 }
}

async function getAudioDuration(ffmpeg, audioFilename) {
 await ffmpeg.run('-i', audioFilename, '-show_entries', 'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', 'duration.txt');
 const data = ffmpeg.FS('readFile', 'duration.txt');
 const durationString = new TextDecoder().decode(data);
 const duration = Math.floor(parseFloat(durationString.trim())); 
 return duration;
}



I am getting this error :


CreateVideo.js:65 Error creating video: RuntimeError: Aborted(LinkError: WebAssembly.instantiate(): Import #70 module="a" function="qa": function import requires a callable). Build with -sASSERTIONS for more info.



Can someone help me with this ?


-
Black detect ffmpeg and use in a javascript
6 février 2023, par solI had an ffmpeg script that allow me to detect black frames from a video file sample from the bottom.


and i want to create a javascript code that will allow me to do the same function sample from the bottom but its not working.


original code from ffmpeg script :


`ffmpeg -i LKE-BLACK.mp4 -vf "blackdetect=d=0.5:pix_th=0.10" -an -f null - 2>&1 | findstr blackdetect > output.txt


node script :


var fs = require('fs');
const ffmpeg = require("ffmpeg.js");

var createStream = fs.createWriteStream("data.txt");
createStream.end();

const transcode = async ({ target: { files } }) => {
 message.innerHTML = 'Loading ffmpeg-core.js';
 await ffmpeg.load();
 message.innerHTML = 'Start transcoding';
 
 await ffmpeg.transcode('-i', 'LKE-BLACK.mp4', "-vf", "blackdetect=d=0.5:pix_th=0.10", '-an', '-f', 'null - 2>&1', );
 message.innerHTML = 'Complete transcoding';

 fs.writeFile("data.txt", function (err) {
 if (err) throw err;
 console.log('File is created successfully.');
 });
}