
Recherche avancée
Autres articles (93)
-
Qu’est ce qu’un éditorial
21 juin 2013, parEcrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
Vous pouvez personnaliser le formulaire de création d’un éditorial.
Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...) -
Contribute to translation
13 avril 2011You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
MediaSPIP is currently available in French and English (...) -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.
Sur d’autres sites (6391)
-
How to read frames of a video and write them on another video output using FFMPEG and nodejs
29 décembre 2023, par AviatoI am working on a project where I need to process video frames one at a time in Node.js. I aim to avoid storing all frames in memory or the filesystem due to resource constraints. I plan to use the ffmpeg from child processes for video processing.
I tried reading a video file and then output frames of it in the filesystem first for testing purposes :-


const ffmpegProcess = spawn('ffmpeg', [
 '-i', videoFile,
 'testfolder/%04d.png' // Output frames to stdout
]);



and the above code works fine, it saves the video frames as png files in the filesystem. Now instead of saving them in the file system, I want to read the frames on at a time and use a image manipulation library and than write the final edited frames to another video as output


I tried this :-


const ffmpegProcess = spawn('ffmpeg', [
 '-i', videoFile,
 'pipe:1' // Output frames to stdout
]);

const ffmpegOutputProcess = spawn('ffmpeg', [
 '-i', '-',
 'outputFileName.mp4'
 ]);

ffmpegProcess.stdout.on('data', (data) => {
 // Process the frame data as needed
 console.log('Received frame data:');
 ffmpegOutputProcess.stdin.write(data)
});

ffmpegProcess.on('close', (code) => {
 if (code !== 0) {
 console.error(`ffmpeg process exited with code ${code}`);
 } else {
 console.log('ffmpeg process successfully completed');
 
 }
});

// Handle errors
ffmpegProcess.on('error', (err) => {
 console.error('Error while spawning ffmpeg:', err);
});



But when I tried above code and also some other modifications in the input and output suffix in the command I got problems as below :-


- 

- ffmpeg process exited with code 1
- The final output video was corrupted when trying to initializing the filters for commands :-







const ffmpegProcess = spawn('ffmpeg', [
 '-i', videoFile,
 '-f', 'rawvideo',
 '-pix_fmt', 'rgb24',
 'pipe:1' // Output frames to stdout
]);

const ffmpegOutputCommand = [
 '-f', 'rawvideo',
 '-pix_fmt', 'rgb24',
 '-s', '1920x1080',
 '-r', '30',
 '-i', '-',
 '-c:v', 'libx264',
 '-pix_fmt', 'yuv420p',
 outputFileName
];



Thank you so much in advance :)


-
avcodec/libjxl.h : include version.h
23 janvier 2024, par Leo Izenavcodec/libjxl.h : include version.h
This file has been exported since our minimum required version (0.7.0),
but it wasn't documented. Instead it was transitively included by
<jxl/decode.h> (but not jxl/encode.h), which ffmpeg relied on.libjxl broke its API in libjxl/libjxl@66b959239355aef5255 by removing
the transitive include of version.h, and they do not plan on adding
it back. Instead they are choosing to leave the API backwards-
incompatible with downstream callers written for some fairly recent
versions of their API.As a result, we include <jxl/version.h> to continue to build against
more recent versions of libjxl. The version macros removed are also
present in that file, so we no longer need to redefine them.Signed-off-by : Leo Izen <leo.izen@gmail.com>
-
Execute my PowerShell script does not work via my C# application
15 février 2024, par NixirI'm currently working on IP cameras for my job, but I'm just starting out because I've never done anything like this before.
The aim is very simple, to start recording a specific camera via a user action, and to stop the same camera via another user action.
To achieve this, I looked for several solutions and finally decided to use FFMPEG and two Powershell scripts.


The first starts recording using FFMPEG and stores the process PID in a .txt file.


StartRec.ps1


#Paramètres de la caméra IP
$cameraIP = $args[0]
$port = $args[1]
$username = $args[2]
$password = $args[3]

$ipfile = ${cameraIP} -replace "\.", ""
$namefile = "video_"+$ipfile+"_"+(Get-Date -Format "ddMMyyyy_HHmmss") + ".mp4"
$namepidfile = "PID_"+$ipfile+".txt"

# URL du flux vidéo de la caméra (exemple générique, adaptez-le à votre caméra)
$videoStreamUrl = "rtsp://${username}:${password}@${cameraIP}:${port}/videoMain"

# Répertoire de sortie pour la vidéo enregistrée
$outputDirectory = "C:\OutputDirectory"

# Chemin complet du fichier de sortie (nom de fichier avec horodatage actuel)
$outputFile = Join-Path $outputDirectory (${namefile})

# Commande FFmpeg pour enregistrer le flux vidéo en arrière-plan
$ffmpegCommand = "ffmpeg -rtsp_transport tcp -i `"$videoStreamUrl`" -c:v copy `"$outputFile`"" 

# Démarrer FFmpeg en arrière-plan
$process = Start-Process -FilePath "cmd.exe" -ArgumentList "/c $ffmpegCommand" -PassThru

$cheminFichier = Join-Path $outputDirectory $namepidfile

if (-not (Test-Path $cheminFichier)) {
 # Le fichier n'existe pas, créer le fichier
 New-Item -ItemType File -Path $cheminFichier -Force
 Write-Host "Fichier créé : $cheminFichier"
} else {
 Write-Host "Le fichier existe déjà : $cheminFichier"
}

Start-Sleep -Seconds 5

$processId = Get-WmiObject Win32_Process -Filter "Name='ffmpeg.exe'" | Select-Object -ExpandProperty ProcessId

# Enregistrez le PID dans un fichier
$process.Id | Out-File $cheminFichier

Write-Host "Enregistrement démarré. PID du processus : $($processId)"



The second reads the contents of this .txt file, stores it in a variable as a PID and stops the process via its Id, then closes the command window associated with this process (which tells the camera that the recording is finished).


StoptRec.ps1


$cameraIP = $args[0]
$ipfile = ${cameraIP} -replace "\.", ""
$namepidfile = "PID_"+$ipfile+".txt"
$outputDirectory = "C:\OutputDirectory"
$cheminFichier = Join-Path $outputDirectory $namepidfile

$pidcontent = Get-Content $cheminFichier -Raw 
if (-not $pidContent) {
 Write-Host "Erreur : Le fichier PID est vide. Assurez-vous que l'enregistrement est démarré."
 exit
}

$processId = $pidContent.Trim() -as [int]

if (-not $processId) {
 Write-Host "Erreur : Impossible de convertir le contenu du fichier PID en entier."
 exit
}

Get-Process -Id $processId

Stop-Process -Id $processId -PassThru | Foreach-Object { $_.CloseMainWindow() }

Write-Host "Enregistrement arrêté pour le processus PID $processId"
Start-Sleep -Seconds 15



The problem is that they work, except in one case that I'll explain :
First, I tried to run them via PowerShell, the recording starts up and the script works as expected, as does the shutdown. My final file is usable.
I then performed C# actions in my Controller, which calls and executes these scripts :


The action that calls StartRec.ps1


public void startRecordingCam1(string ipAddress)
 {
 string ps1File = @"C:\OutputDirectory\StartRec.ps1";
 string cameraIP = "Camera IP Adress";
 string port = "88";
 string username = "Username";
 string password = "Password";

 Process process = Process.Start(new ProcessStartInfo
 {
 FileName = "powershell.exe",
 Arguments = $"-NoProfile -ExecutionPolicy Bypass -File \"{ps1File}\" \"{cameraIP}\" \"{port}\" \"{username}\" \"{password}\"",
 UseShellExecute = false,
 RedirectStandardInput = true
 //CreateNoWindow = true
 });
 }



The action that calls StopRec.ps1


public void stopRecording(string ipAddress)
 {
 string ps1File = @"C:\Projet Valentin\CameraTest\StopRec_Csharp.ps1";
 string cameraIP = "10.0.1.10";

 ProcessStartInfo startInfo = new ProcessStartInfo()
 {
 FileName = "powershell.exe",
 Arguments = $"-NoProfile -ExecutionPolicy ByPass -File \"{ps1File}\" \"{cameraIP}\" ",
 UseShellExecute = true
 };
 Process.Start(startInfo);
 }



When I run the two scripts via these actions, StartRec.ps1 works well, but StopRec.ps1 doesn't work completely : the process is stopped, but the command window isn't closed, so camera recording continues (despite the end of the process).
As both scripts worked perfectly when launched with Powershell, but not with the C# application, I tried several combinations of "Start-Stop" with "PowerShell/C#".


If I run StartRec.PS1 with the C# application and StopRec.PS1 with PowerShell, it works.
If I run StartRec.PS1 with PowerShell and StopRec.PS1 with the C# application, it works.
If I run StartRec.PS1 with PowerShell and StopRec.PS1 with PowerShell, it works.
The only case that doesn't work is when I run both via the C# application


One thing I can add that I discovered while debugging is that this :

Stop-Process -Id $processId -PassThru | Foreach-Object { $_.CloseMainWindow() }


Returns false in the only case where it doesn't work, and true in all other cases


That's all the details I can give you, thanks for your help !