
Recherche avancée
Médias (91)
-
Les Miserables
9 décembre 2019, par
Mis à jour : Décembre 2019
Langue : français
Type : Textuel
-
VideoHandle
8 novembre 2019, par
Mis à jour : Novembre 2019
Langue : français
Type : Video
-
Somos millones 1
21 juillet 2014, par
Mis à jour : Juin 2015
Langue : français
Type : Video
-
Un test - mauritanie
3 avril 2014, par
Mis à jour : Avril 2014
Langue : français
Type : Textuel
-
Pourquoi Obama lit il mes mails ?
4 février 2014, par
Mis à jour : Février 2014
Langue : français
-
IMG 0222
6 octobre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Image
Autres articles (41)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...) -
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...)
Sur d’autres sites (8893)
-
Problem with FFmpeg breaking when streaming the entire screen and switching tabs
2 octobre 2024, par Ibad AhmadI'm working on a screen recording and streaming setup where the user records their entire screen and streams it to Twitch. The setup works fine initially, but when I switch tabs during recording, the stream breaks on the backend, and I get the following FFmpeg errors :


FFmpeg STDERR: [matroska,webm @ 0x7f9dcb904580] EBML header parsing failed
[in#0 @ 0x7f9dcb904380] Error opening input: Invalid data found when processing input
Error opening input file -.
Error opening input files: Invalid data found when processing input



My frontend code captures the screen and microphone and streams it via a WebSocket to the backend, where FFmpeg processes the stream. Below is my relevant frontend code :


const startRecording = async () => {
 try {
 const screenStream = await navigator.mediaDevices.getDisplayMedia({
 preferCurrentTab: true,
 systemAudio: 'include',
 surfaceSwitching: 'include',
 monitorTypeSurfaces: 'include',
 video: {
 displaySurface: 'browser',
 height: 720,
 width: 1280,
 frameRate: { ideal: 24, max: 30 },
 },
 });

 screenStream.getVideoTracks()[0].onended = () => {
 console.log('Screen sharing ended. Stopping the recorder.');
 stopRecording();
 };

 const micStream = await navigator.mediaDevices.getUserMedia({
 audio: true,
 });

 const combinedStream = new MediaStream([
 ...screenStream.getVideoTracks(),
 ...micStream.getAudioTracks(),
 ]);

 const recorder = new MediaRecorder(combinedStream, {
 mimeType: 'video/webm; codecs=vp8,opus',
 videoBitsPerSecond: 3 * 1024 * 1024,
 });

 const timeslice = 1000;

 recorder.ondataavailable = async (event) => {
 if (socket?.current?.connected && event.data.size > 0) {
 console.log('Sending chunk data:', socket.current.id);
 socket?.current.send(event.data);
 recordedChunks.current.push(event.data);
 } else if (!socket?.current?.connected) {
 handleSocketDisconnection();
 }
 };

 mediaRecorder.current = recorder;
 recorder.start(timeslice);
 setIsRecording(true);
 } catch (error) {
 console.log('Error starting screen recording:', error);
 toast.error('Failed to start screen recording: ' + error);
 }
};

const stopRecording = () => {
 if (socket?.current && mediaRecorder) {
 mediaRecorder?.current?.stop();
 socket.current.close();
 setIsRecording(false);
 downloadRecordedVideo();
 }
};




And here’s my backend code with FFmpeg settings for Twitch streaming :


const inputSettings = [
 '-f', 'webm', '-i', '-', '-v', 'error', '-analyzeduration', '1000000', '-probesize', '5000000',
];

const twitchSettings = (twitch) => {
 return [
 '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency',
 '-g', '60', '-b:v', '2500k', '-maxrate', '3000k', '-bufsize', '8000k',
 '-r', '30', '-vf', 'tpad=stop_mode=clone:stop_duration=2',
 '-c:a', 'aac', '-ar', '44100', '-b:a', '96k',
 '-use_wallclock_as_timestamps', '1', '-async', '1',
 '-err_detect', 'ignore_err', '-reconnect', '1',
 '-reconnect_streamed', '1', '-reconnect_delay_max', '5',
 '-y', '-f', 'flv', twitch,
 ];
};




Problem : When switching tabs during screen sharing, it seems like the frame rate drops or the stream gets interrupted, leading to FFmpeg errors like
EBML header parsing failed
andInvalid data found when processing input
. I suspect this happens because the browser deprioritizes resources when the tab is not active, which might lead to corrupt chunks being sent to FFmpeg.

Questions :


- 

- Could switching tabs during screen capture be causing the issue by disrupting the frame rate or dropping frames ?
- Is there a way to ensure FFmpeg doesn’t break due to these interruptions ?
- Any suggestions on handling the stream more reliably when switching tabs or optimizing the FFmpeg setup for this scenario ?








I tried adjusting the bitrate, frame rate, and buffer size but still experienced the same issue. I'm trying to figure out if the issue is related to how browsers handle screen capture when tab switching or something specific with FFmpeg handling the video stream.


Any insights would be greatly appreciated.
Thanks in advance !


-
Try to concatenate videos using FFmpeg Package. My videos concatenate correctly but those that i record from fornt camera rotate 90' in concatenate
24 avril 2024, par Ahmad AkramHere is my code where I pass a list of image paths that concatenate. I am facing an issue with the front camera video. When concatenated completely some videos rotate 90 degrees.


Future<void> mergeVideos(List<string> videoPaths) async {
 VideoHelper.showInSnackBar('Videos merged Start', context);
 String outputPath = await VideoHelper.generateOutputPath();
 FlutterFFmpeg flutterFFmpeg = FlutterFFmpeg();

 // Create a text file containing the paths of the videos to concatenate
 String fileListPath =
 '${(await getTemporaryDirectory()).path}/fileList.txt';
 File fileList = File(fileListPath);
 await fileList
 .writeAsString(videoPaths.map((path) => 'file \'$path\'').join('\n'));

 // Run FFmpeg command to concatenate videos
 // String command = '-f concat -safe 0 -i $fileListPath -c copy $outputPath';

 String command =
 '-f concat -safe 0 -i $fileListPath -vf "transpose=1" -c:a copy $outputPath';

 VideoHelper.showInSnackBar('command Start', context);
 await flutterFFmpeg.execute(command).then((value) {
 if (value == 0) {
 print("Output Path : $outputPath");
 VideoHelper.showInSnackBar('Videos merged successfully', context);
 Navigator.push(
 context,
 MaterialPageRoute(
 builder: (context) => VideoPlayerScreen(
 videoFile: XFile(outputPath),
 )));
 } else {
 VideoHelper.showInSnackBar(
 'Error merging videos ::::: returnCode=== $value ', context);
 }
 });
 }
</string></void>


-
FFmpeg to RTMP - no audio on output [closed]
25 mars 2022, par John Mergene ArellanoFrom my client side, I am sending a stream using the Socket.IO library. I captured the video and audio using getUserMedia API.


navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
 window.videoStream = video.srcObject = stream;
 let mediaRecorder = new MediaRecorder(stream, {
 videoBitsPerSecond : 3 * 1024 * 1024
 });
 mediaRecorder.addEventListener('dataavailable', (e) => {
 let data = e.data;
 socket.emit('live', data);
 });
 mediaRecorder.start(1000);
});



Then my server will receive the stream and write it to FFmpeg.


client.on('live', (stream)=>{
 if(ffmpeg)
 ffmpeg.stdin.write(stream);
});



I tried watching the live video in VLC media player. There is a 5 seconds delay and no audio output.


Please see below for FFmpeg options I used :


ffmpeg = this.CHILD_PROCESS.spawn("ffmpeg", [
 '-f',
 'lavfi',
 '-i', 'anullsrc',
 '-i','-',
 '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency',
 '-c:a', 'aac', '-ar', '44100', '-b:a', '64k',
 '-y', //force to overwrite
 '-use_wallclock_as_timestamps', '1', // used for audio sync
 '-async', '1', // used for audio sync
 '-bufsize', '1000',
 '-f',
 'flv',
 `rtmp://127.0.0.1:1935/live/stream` ]);



What is wrong with my setup ?


I tried removing some of the options but failed. I am expecting to have an output of video and audio from the getUserMedia API.