Recherche avancée

Médias (1)

Mot : - Tags -/ogg

Autres articles (47)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (8328)

  • How to change resolution without compromising video quality using ffmpeg ?

    20 mars 2024, par blake banker

    I'm trying to develop a simple video transcoding system.
When you upload a video,
After extracting the video and audio separately,
I want to encode them at 360, 720, and 1080p resolutions respectively and then merge them to create three final mp4 files.
At this time, I have two questions.

    


      

    1. Is there a big difference between encoding the video and audio separately in the original video file and encoding the original video file as is ? In a related book, it is said that a system is created by separating video and audio, and I am curious as to why.

      


    2. 


    3. I want to change the resolution without compromising the original image quality. At this time, the resolution of the uploaded file can be known at the time of upload. As a test, I created files according to each resolution, and found that the image quality was damaged. If I want to change only the resolution while keeping the original image quality, I would like to know how to adjust each ffmpeg option. We plan to change it to 360, 720, and 1080p.

      


    4. 


    


  • how to download portion of video which was uploaded into AWS s3 bucket, though Nodejs SDKs

    22 février 2024, par rama rangeswara reddy

    I have uploaded a 1GB .mp4 file to an AWS S3 bucket. Using the AWS-SDK provided by the npm package, I am able to download the entire video. However, I have a specific requirement to generate a thumbnail at the 6-second mark of the video. Currently, I download the entire 1GB video to my local machine and then generate the thumbnail at the desired duration.

    


    To optimize server resources and reduce disk load, I plan to download only the first 10 seconds of the video, which should be approximately 10MB or less in size. By doing so, I can significantly reduce download time and server load while still fulfilling my requirement of generating the thumbnail at the 6-second mark. Therefore, instead of downloading the entire 1GB video, I aim to download only the 10MB segment corresponding to the first 10 seconds of the video.

    


    I am using nodejs, expressJS, as backed Technologies.

    


    `

    


    `async function downloadS3FileToLocalDirAndReturnPath(videoKey) {
    return new Promise(async (resolve, reject) => {
        try {
            AWS.config.update({
                accessKeyId: config.AWS.KEYS.accessKeyId,
                secretAccessKey: config.AWS.KEYS.secretAccessKey,
                region: config.AWS.KEYS.region,
                httpOptions: config.AWS.KEYS.httpOptions
            });
            const s3 = new AWS.S3();

            // Specify the local file path where you want to save the downloaded video
            const localFilePath = `${os.tmpdir()}/${Date.now()}_sre.mp4`;

            // Configure the parameters for the S3 getObject operation
            const params = {
                Bucket: config.AWS.S3_BUCKET,
                Key: videoKey
            };

            const result = await s3.getObject(params).promise();
            const fileContent = result.Body;
            fs.writeFileSync(localFilePath, fileContent);
            resolve(localFilePath);
        } catch (error) {
            reject(error);
        }
    });
}`


    


    this code was working fine to download the whole video , but i need to download only first 10 seconds duration

    


    S3 : How to do a partial read / seek without downloading the complete file ?

    


    I tried this ,before posting this question with above post, video was downloading , it was not playing , by throwing this error , the file contains no playable streams

    


    async function generateThumbnails(videoKey) {

const s3 = new AWS.S3();

const params = {
    Bucket: KEYS.bucket,
    Key: videoKey, // Specify the key of the video file in S3
    Range: `bytes=0-${1024 * 800}`, // Specify the range of bytes you want to retrieve
};

const file = fs.createWriteStream(`/tmp/${Date.now()}_rama.mp4`);

const s3Stream = s3.getObject(params).createReadStream();

s3Stream.pipe(file);

s3Stream.on("error", (error) => {
    console.log("Error Occured while File downloading!! ");
});

s3Stream.on("finish", () => {
    console.log("File downloaded Successfully ");
});


    


    }

    


  • Execute my PowerShell script does not work via my C# application

    15 février 2024, par Nixir

    I'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 !