
Recherche avancée
Autres articles (11)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...) -
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 ;
Sur d’autres sites (3408)
-
FFmpeg - ducking music for voiceover (sidechain)
7 décembre 2023, par kaushalI am trying to duck the background music from a voiceover input file using FFmpeg (I tried doing this using pydub with no success).


The below command is predominantly working, except that it is truncating my background music file (main.mp3, over 3 min long) to the length of the voiceover file (taekwondo.mp3, about a min long). Any idea or suggestion on what can I change in below command so that the output file is full 3 min long, with background music ducked when the voiceover is playing. Once the voiceover completes, background music continues to play as normal.


In below complex filter, this is what I'm doing :
adelay filter : to start voiceover playing after 5 seconds into background music
volume filter : Since my background music is too loud and voiceover is too low, I'm increasing voiceover volume by 1.5 times, and lowering background music volume to 0.7 times
sidechaincompress filter : Then I'm applying sidechain filter to duck background music whenever voiceover is playing, with usual threshold, ratio & release filters


I've tried both amix & amerge, but results in same behaviour.


ffmpeg -i main.mp3 -i taekwondo.mp3 -filter_complex "[1:a]adelay=5000|5000,volume=1.5[a];[0:a]volume=0.7[b];[a]asplit=2[sc][mix];[b][sc]sidechaincompress=threshold=0.05:ratio=20:level_sc=1:release=500:attack=1[compr];[compr][mix]amix" output.mp3



-
ffmpeg avformat_open_input() function causes memory leak when receiving live stream
12 septembre 2023, par george_dI have live streams (can be UDP or HLS, video codec is H264), from which I grab frames for further processing.


For this purpose, I use ffmpeg + nvjpeg + cuda libraries.


However I noticed memory leak - memory usage periodically (every 10-20 seconds) is increased by 100-400 KB, the amount and period may vary.


After disabling pieces of code one by one, I realized that it is
avformat_open_input()
which causes memory leak.

No matter which buffer settings (https://ffmpeg.org/ffmpeg-protocols.html#udp) I choose for UDP, the leak still persists. Same goes for HLS streams.


I tried to find anything related to this problem, but all the sources I found claimed that this problem took place in the past and has been fixed.


Is there some mysterious setting I am missing, so that memory could be freed properly ?


Or is this memory supposed to be freed when processing frames (i.e. using
av_read_frame()
andav_packet_unref()
, etc) ?

Minimal example of code to reproduce the problem :


avformat_example.cpp


#include 
extern "C" {
 #include <libavformat></libavformat>avformat.h>
 #include <libavcodec></libavcodec>avcodec.h>
}

int main(int argc, char *argv[]){
 if (argc < 2) {
 return 1;
 }

 char* inputSource = argv[1];
 AVFormatContext *ctx = NULL;

 if (avformat_open_input(&ctx, inputSource, NULL, NULL) != 0) {
 av_log(NULL,
 AV_LOG_ERROR,
 "Cannot open '%s'",
 inputSource);
 return 1;
 }

 /*
 This loop is placed here to demonstrate
 avformat_open_input() causing leak.
 Actually, instead of noop loop there is logic of getting and processing frames,
 but it doesn't matter now.
 As loop goes on, the amount of leaked memory increases.
 */
 while(true) {
 sleep(1);
 }

 return 0;
}



Compile with :


g++ avformat_example.cpp -lavcodec -lavutil -lavformat -I/usr/include/ffmpeg-cuda -o avformat_open_input_example



Run :


./avformat_open_input_example "udp://127.0.0.1:5000?reuse=1&pkt_size=1316&buffer_size=1310720&fifo_size=40000"



Version of ffmpeg underlying libraries :


libavutil 58. 7.100 / 58. 7.100
libavcodec 60. 11.100 / 60. 11.100
libavformat 60. 5.100 / 60. 5.100
libavdevice 60. 2.100 / 60. 2.100
libavfilter 9. 8.100 / 9. 8.100
libswscale 7. 2.100 / 7. 2.100
libswresample 4. 11.100 / 4. 11.100



-
Dynamically record parts of a video stream using ffmpeg based on incoming events
12 septembre 2023, par ganjimSay I have a RTSP stream running on some server.


I want to record parts of this video stream based on some events that will come up on my machine.
My goal is to record 10 seconds before up to 10 seconds after the PTS in any received event. Consider that I have a way to synchronize the PTS between the sender and the receiver, but by the time I receive the events, its already streamed and is in the past.
So I either need to have the ffmpeg command running already, or to have buffered streaming video in my memory.


I just added some code with comments as a way to simulate the situation, it is not complete as I still don't have a working solution. But I'm looking to understand if ffmpeg has capabilities for dealing with rtsp streams suitable for this situation.


const { spawn } = require('child_process');

function processEvent(event){
 
 let startTime = event.pts - 10
 let endTime = event.pts + 10

 const ffmpegArgs = [
 '-i', "rtspUrl",
 '-ss', startTime.toString(),
 '-to', endTime.toString(),
 '-c', 'copy',
 '-f', 'mp4',
 `output_${startTime}_${endTime}.mp4` // Output filename
 ];
 // Here it is obviously not possible to give ffmpeg a negative startTime.
 // We either have to have spawned the ffmpeg command and somehow give it a starting time for recording on demand or have a buffering system in place.
 // Having a buffer to store every raw frame and then attach them after endTime is also considerably CPU and memory intensive.
 // Looking for alternative ways to achieve the same output.

 const ffmpegProcess = spawn('ffmpeg', ffmpegArgs, {
 stdio: 'inherit'
 });
}

// Code to simulate the events:
// imagine these pts to be relative to Date.now(), so using negative PTS to show the events are going to be in the past by the time we receive them.
setTimeout(() => {
 const event1= { pts: -30 };
 processEvent(event1);
}, 1000);

setTimeout(() => {
 const event2 = { pts: -20 };
 processEvent(event2);
}, 5000);