
Recherche avancée
Autres articles (106)
-
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 (...) -
Amélioration de la version de base
13 septembre 2013Jolie sélection multiple
Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...)
Sur d’autres sites (12381)
-
Can i limit CPU usafe of my Scrypt ? Raspberry pi cpu crashing
2 novembre 2024, par Mateus CoelhoI have a scrypt, in pyhton, that converts a video of 11mb, 30fps, 1080p. the code puts 4 imagens into it, with overlay, and rotates 90.
When i run the crypt into the raspberry pi, it goes off CPU, all the 4 threads go to 100% and it suently reboots.


Raspberry pi 4 b 4gb


I want to limit the cpu to like 60% to the scypt... its not a problems to be longer in time.


import subprocess
import sys
import time
import psutil
import os

def overlay_images_on_video(input_file, image_files, output_file, positions, image_size=(100, 100), opacity=0.7):
 start_time = time.time()
 process = psutil.Process(os.getpid())

 inputs = ['-i', input_file]
 for image in image_files:
 if image:
 inputs += ['-i', image]
 filter_complex = "[0:v]transpose=2[rotated];"
 current_stream = "[rotated]"
 for i, (x_offset, y_offset) in enumerate(positions):
 filter_complex += f"[{i+1}:v]scale={image_size[0]}:{image_size[1]},format=rgba,colorchannelmixer=aa={opacity}[img{i}];"
 filter_complex += f"{current_stream}[img{i}]overlay={x_offset}:{y_offset}"
 if i < len(positions) - 1:
 filter_complex += f"[tmp{i}];"
 current_stream = f"[tmp{i}]"
 else:
 filter_complex += ""
 command = ['ffmpeg', '-threads', '1'] + inputs + ['-filter_complex', filter_complex, output_file]
 
 try:
 subprocess.run(command, check=True)
 print(f"Vídeo processado com sucesso: {output_file}")
 except subprocess.CalledProcessError as e:
 print(f"Erro ao processar o vídeo: {e}")
 
 # Monitoramento de tempo, memória e CPU
 elapsed_time = time.time() - start_time
 memory_info = process.memory_info()
 cpu_usage = process.cpu_percent(interval=1)
 print(f"Tempo de execução: {elapsed_time:.2f} segundos")
 print(f"Memória usada: {memory_info.rss / (1024 * 1024):.2f} MB")
 print(f"Uso de CPU: {cpu_usage}%")
 
 # Monitoramento de GPU (se disponível)
 try:
 gpu_usage = subprocess.check_output(
 ["nvidia-smi", "--query-gpu=utilization.gpu", "--format=csv,noheader,nounits"]
 ).decode("utf-8").strip()
 print(f"Uso de GPU: {gpu_usage}%")
 except FileNotFoundError:
 print("GPU não detectada ou `nvidia-smi` não está disponível.")

if __name__ == "__main__":
 input_video = sys.argv[1]
 image_files = sys.argv[2:5]
 output_video = sys.argv[5]
 
 positions = [(10, 10), (35, 1630), (800, 1630)]
 overlay_images_on_video(input_video, image_files, output_video, positions, image_size=(250, 250), opacity=0.8)
 ```




-
How to accurately detect the start of the main beat and soundtracks in diverse audio tracks ?
18 juin 2024, par SnoofFloofI'm working on a project where I need to edit soundtracks. The challenge is to detect when the main beat and melody of any given soundtrack is properly developed. I am certain there is better terminology to describe what I am aiming for, but ideally, I want to skip the "build-up" and immediately have the song starting at the "main part". This needs to work for various songs across different genres, which often have different structures and onset patterns, making it difficult to streamline the process.


For example :


https://www.youtube.com/watch?v=P77CNtHrnmI -> I would want to my code to identify the onset at 0:24


https://www.youtube.com/watch?v=OOsPCR8SyRo -> Onset detection at 0:12


https://www.youtube.com/watch?v=XKiZBlelIzc -> Onset detection at 0:19


I've tried using librosa to analyze the onset strength and detect beats, but the current implementation either detects the very beginning of the song or fails to consistently identify when the beat is fully developed.


This was my approach ;


def analyze_and_edit_audio(input_file, output_file):
 y, sr = librosa.load(input_file)
 tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
 beat_times = librosa.frames_to_time(beat_frames, sr=sr)
 main_beat_start = beat_times[0]



I have very little experience with librosa/audio editing, so I would appreciate any suggestions you might have !


-
FFmpeg Error : Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_amix_54
25 mai 2024, par Josh LawsonI'm working on a project to generate a click track using React.js and FFmpeg. The project includes an Express.js backend where I construct an FFmpeg command to combine multiple audio files (count-ins, vocal cues, and click sounds) into a single track. The final output should be an MP3 file.


However, I'm encountering an error when running the FFmpeg command :


Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_amix_54



How can I correctly construct the FFmpeg command to avoid the "Cannot find a matching stream for unlabeled input pad" error and ensure all inputs are properly processed and mixed ?


Here is the relevant part of my server.js code :


const express = require('express');
const bodyParser = require('body-parser');
const { exec } = require('child_process');
const path = require('path');
const fs = require('fs');
const ffmpegPath = require('ffmpeg-static');
const cors = require('cors');

const app = express();
app.use(cors());
app.use(bodyParser.json());

app.post('/generate-click-track', (req, res) => {
 const { tempo, timeSignature, clickSound, subdivisions, sections } = req.body;
 const clickSoundPath = path.join(__dirname, 'public', 'click-sounds');
 const vocalCuesPath = path.join(__dirname, 'public', 'vocal-cues');

 const beatsPerBar = parseInt(timeSignature.split('/')[0]);
 const beatsPerMinute = tempo;
 let totalBeats = 0;
 const sectionStarts = [];

 sections.forEach((section, index) => {
 if (index > 0) {
 sectionStarts.push(totalBeats);
 }
 totalBeats += section.length * beatsPerBar;
 });

 const outputFilePath = path.join(__dirname, 'output', 'click-track.mp3');
 const tempDir = path.join(__dirname, 'temp');

 if (!fs.existsSync(tempDir)) {
 fs.mkdirSync(tempDir);
 }

 const countInFiles = Array.from({ length: beatsPerBar }, (_, i) => path.join(vocalCuesPath, 'count-ins', `${i + 1}.wav`));

 let ffmpegCommand = '';

 // Add count-in files
 countInFiles.forEach(file => {
 ffmpegCommand += `-i "${file}" `;
 });

 // Add section vocal cues and click sounds
 sections.forEach((section, index) => {
 const vocalCueFile = path.join(vocalCuesPath, `${section.name}.wav`);
 ffmpegCommand += `-i "${vocalCueFile}" `;

 for (let i = 0; i < section.length * beatsPerBar; i++) {
 const clickFile = i % beatsPerBar === 0 ? `${clickSound}-accents.mp3` : `${clickSound}.mp3`;
 ffmpegCommand += `-i "${path.join(clickSoundPath, clickFile)}" `;
 }
 });

 ffmpegCommand += `-filter_complex "`;

 let inputCount = 0;
 countInFiles.forEach((_, index) => {
 ffmpegCommand += `[${inputCount}:0]adelay=${index * (60 / beatsPerMinute) * 1000}|${index * (60 / beatsPerMinute) * 1000}[a${inputCount}]; `;
 inputCount++;
 });

 sections.forEach((section, index) => {
 const delay = (sectionStarts[index] ? sectionStarts[index] : 0) * (60 / beatsPerMinute) * 1000;
 ffmpegCommand += `[${inputCount}:0]adelay=${delay}|${delay}[a${inputCount}]; `;
 inputCount++;

 for (let i = 0; i < section.length * beatsPerBar; i++) {
 const delay = (sectionStarts[index] ? sectionStarts[index] : 0) * (60 / beatsPerMinute) * 1000 + (i * 60 / beatsPerMinute) * 1000;
 ffmpegCommand += `[${inputCount}:0]adelay=${delay}|${delay}[a${inputCount}]; `;
 inputCount++;
 }
 });

 ffmpegCommand += `amix=inputs=${inputCount}:duration=longest" -codec:a libmp3lame -b:a 192k -y "${outputFilePath}"`;

 console.log(`Executing ffmpeg command: ${ffmpegCommand}`);

 exec(`${ffmpegPath} ${ffmpegCommand}`, (error, stdout, stderr) => {
 if (error) {
 console.error(`Error generating click track: ${error.message}`);
 res.status(500).send('Error generating click track');
 return;
 }

 res.download(outputFilePath, 'click-track.mp3', (err) => {
 if (err) {
 console.error(`Error sending file: ${err.message}`);
 }

 // Clean up temp directory
 fs.readdir(tempDir, (err, files) => {
 if (err) throw err;
 for (const file of files) {
 fs.unlink(path.join(tempDir, file), err => {
 if (err) throw err;
 });
 }
 });
 });
 });
});

app.listen(3001, () => {
 console.log('Server running on http://localhost:3001');
});



I can't include the full error messge as it is too long, but if anyone needs it, I'm happy to link to a text file that includes it.


What I have tried :


- 

- Verified all file paths and ensured they exist.
- Escaped file paths to handle spaces in filenames.
- Logged the constructed FFmpeg command and ran it manually, which still produced the same error.








Environment


- 

- React.js : v18.3.1
- Node.js : v22.2.0
- Express : v4.19.2
- FFmpeg : static build via ffmpeg-static (v5.2.0)