
Recherche avancée
Médias (3)
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Collections - Formulaire de création rapide
19 février 2013, par
Mis à jour : Février 2013
Langue : français
Type : Image
Autres articles (35)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Librairies et logiciels spécifiques aux médias
10 décembre 2010, parPour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...) -
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" ;
Sur d’autres sites (5204)
-
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 !


-
How easy is it to create a YouTube to MP3 application using yt-dlp and ffmpeg ?
26 juin 2022, par fowlisI was thinking I could automate the process of downloading a video and converting it to mp3 (or other formats).

Instead of doing the process myself (which doesn't take that long and isn't too much hassle), which looks something like this :

•yt-dlp https://www.youtube.com/watch?v=dQw4w9WgXcQ

• wait for download then (find and) rename file to something simpler for next command

•ffmpeg -i video.mp4 video.mp3



I thought I could turn it into a simple JS (or other language) program instead, where it :


- 

- Asks for link and what format I want it in
- Downloads the video
- Renames it (not sure how easy this is)
- Turns it into requested format
- Opens file location












If something like this is possible, please let me know some things I should know since I've never written a windows app before, and some general guidance for how I could do this.

I apologise if questions like this aren't exactly allowed on this site, its my first time posting too.

Thanks in advance !

-
Including ffmpeg in c program/application
11 mars 2016, par user14598204I want to make a C program in which I want to directly use actual functions of ffmpeg. Right now I’m using ’system("ffmpeg command")’ to run ffmpeg
command in my C program. This directly or indirectly executes in the terminal of my Ubuntu Linux. However this frequently opens terminal, runs the command and
closes terminal. Thus multiple terminals are working at a time which is not a good solution.I want to include/embed ffmpeg command in my program so shtat I can directly access the actual fumctions which are defined in the ffmpeg source. I’m working
on a C project in which I need to make a complete firmware which runs this single program so that I don’t have to rely on the multiple terminals and can call the
function directly.So how can I achieve my goal to integrate/embed/include ffmpeg in my C program ?
Any useful links, suggestions are gratey appreciated.