Recherche avancée

Médias (1)

Mot : - Tags -/epub

Autres articles (21)

  • Soumettre améliorations et plugins supplémentaires

    10 avril 2011

    Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
    Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

Sur d’autres sites (4835)

  • Revision 30244 : On mets à jour le script d’encodage pour tester l’encodage multiple (plus ...

    26 juillet 2009, par kent1@… — Log

    On mets à jour le script d’encodage pour tester l’encodage multiple (plus uniquement en flv)

  • acces to data stream (KLV) with windows media-foundation

    20 février 2023, par hacenesh

    Is there any way to acces data stream with Windows Media Foundation ?

    


    I have a video stream that contains tree streams : Audio, video and Data stream
When I opend the file with ffmpeg I can access the three stream :

    


      

    • AVMEDIA_TYPE_AUDIO
    • 


    • AVMEDIA_TYPE_VIDEO
    • 


    • AVMEDIA_TYPE_DATA
    • 


    


    This image show more details about the data stream I wanted to retrieve.
enter image description here

    


    With windows media-foundation I can only see audio and video streams.

    


    IMFMediaSource* pVideoSource = NULL;
IMFSourceReader* pVideoReader = NULL;           
....
....
while (pVideoReader->GetStreamSelection(stmIndex, &isSelected) == S_OK) {
      printf("Stream %d is selected %d.\n", stmIndex, isSelected);

      CHECK_HR(pVideoReader->GetCurrentMediaType(stmIndex, &pStmMediaType), "Failed to get media type for selected stream.");

      std::cout << "Media type: " << GetMediaTypeDescription(pStmMediaType) << std::endl;

      GUID majorMediaType;
      pStmMediaType->GetGUID(MF_MT_MAJOR_TYPE, &majorMediaType);
      if (majorMediaType == MFMediaType_Audio) {
          std::cout << "Source audio stream index is " << stmIndex << "." << std::endl;
      }
      else if (majorMediaType == MFMediaType_Video) {
          std::cout << "Video stream index is " << stmIndex << "." << std::endl;
      }
      stmIndex++;
      SAFE_RELEASE(pStmMediaType);
  }



    


    **Output **

    


    


    Stream 0 is selected 1.
Media type : MFMediaType_Audio : MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16031, MF_MT_AUDIO_BLOCK_ALIGNMENT=1, 33026EE0-E387-4582-AE0A-34A2AD3BAA18=1, MF_MT_AUDIO_NUM_CHANNELS=2, MF_MT_MAJOR_TYPE=MFMediaType_Audio, MF_MT_AUDIO_SAMPLES_PER_SECOND=48000, MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION=254, MF_MT_AUDIO_PREFER_WAVEFORMATEX=1, MF_MT_USER_DATA=, MF_MT_FIXED_SIZE_SAMPLES=1, MF_MT_AAC_PAYLOAD_TYPE=1, MF_MT_ALL_SAMPLES_INDEPENDENT=1, MF_MT_SAMPLE_SIZE=1, MF_MT_SUBTYPE=MFAudioFormat_AAC,
Source audio stream index is 0.
Stream 1 is selected 1.
Media type : MFMediaType_Video : MF_MT_FRAME_SIZE=W:1920 H : 1080, MF_MT_MPEG_SEQUENCE_HEADER=, MF_MT_MAJOR_TYPE=MFMediaType_Video, MF_MT_AM_FORMAT_TYPE=E06D80E3-DB46-11CF-B4D1-00805F6CBBEA, MF_MT_MPEG2_LEVEL=41, MF_MT_MPEG2_PROFILE=66, MF_MT_FIXED_SIZE_SAMPLES=1, MF_MT_FRAME_RATE=25/1, MF_MT_PIXEL_ASPECT_RATIO=1:1, MF_MT_SAMPLE_SIZE=1, MF_MT_INTERLACE_MODE=2, MF_MT_SUBTYPE=3F40F4F0-5622-4FF8-B6D8-A17A584BEE5E,
Video stream index is 1.
Source media type count : 1, is first stream selected 1.
Default output media type for source reader :
MFMediaType_Video : MF_MT_FRAME_SIZE=W:1920 H : 1080, MF_MT_MPEG_SEQUENCE_HEADER=, MF_MT_MAJOR_TYPE=MFMediaType_Video, MF_MT_AM_FORMAT_TYPE=E06D80E3-DB46-11CF-B4D1-00805F6CBBEA, MF_MT_MPEG2_LEVEL=41, MF_MT_MPEG2_PROFILE=66, MF_MT_FIXED_SIZE_SAMPLES=1, MF_MT_FRAME_RATE=25/1, MF_MT_PIXEL_ASPECT_RATIO=1:1, MF_MT_SAMPLE_SIZE=1, MF_MT_INTERLACE_MODE=2, MF_MT_SUBTYPE=3F40F4F0-5622-4FF8-B6D8-A17A584BEE5E,

    


    


    I also looked on the sample metadata. I didn't find anything.
MFSampleExtension_CaptureMetadata

    


     HRESULT hr = videoSample->GetUnknown(MFSampleExtension_CaptureMetadata, IID_IMFAttributes, (void**)&pAttributes);


    


    Result

    


    


    hr = 0xc00d36e6 : The requested attribute was not found.
access to data stream with media-foundation

    


    


  • How to install ffmpeg on a Windows Dockerhub image ?

    18 janvier, par Youssef Kharoufi

    I have a program that executes a ffmpeg command to a video input, copies this video and pastes is in an output directory.

    


    Here is my code in case you would want to duplicate it :

    


        using Renderer.Models;&#xA;using System;&#xA;using System.IO;&#xA;using System.Text.Json;&#xA;using System.Threading.Tasks;&#xA;&#xA;public class Program&#xA;{&#xA;    public static async Task Main(string[] args)&#xA;    {&#xA;        var result = new DockerTaskResult();&#xA;        try&#xA;        {&#xA;            // Path to the JSON input file&#xA;            string jsonInputPath = @"C:\Users\ykharoufi\source\repos\Renderer\Renderer\Json\task.json";&#xA;&#xA;            // Check if the JSON file exists&#xA;            if (!File.Exists(jsonInputPath))&#xA;            {&#xA;                throw new FileNotFoundException($"JSON input file not found at path: {jsonInputPath}");&#xA;            }&#xA;&#xA;            // Read the JSON content&#xA;            string jsonContent = File.ReadAllText(jsonInputPath);&#xA;&#xA;            try&#xA;            {&#xA;                // Deserialize the JSON into a DockerTask object&#xA;                DockerTask task = JsonSerializer.Deserialize<dockertask>(jsonContent);&#xA;                if (task == null)&#xA;                {&#xA;                    throw new Exception("Failed to deserialize the task from JSON.");&#xA;                }&#xA;&#xA;                // Validate the input paths&#xA;                if (string.IsNullOrEmpty(task.InputFileRepoPath) || !File.Exists(task.InputFileRepoPath))&#xA;                {&#xA;                    throw new Exception($"Input file path is invalid or does not exist: {task.InputFileRepoPath}");&#xA;                }&#xA;&#xA;                if (string.IsNullOrEmpty(task.OutputFileRepoPath) || !Directory.Exists(task.OutputFileRepoPath))&#xA;                {&#xA;                    throw new Exception($"Output directory path is invalid or does not exist: {task.OutputFileRepoPath}");&#xA;                }&#xA;&#xA;                // Initialize the Docker worker and run the task&#xA;                var worker = new DockerWorker();&#xA;                var success = await worker.RunDockerTaskAsync(task);&#xA;&#xA;                if (success.Success)&#xA;                {&#xA;                    result.Success = true;&#xA;                    result.Message = "Command executed successfully!";&#xA;&#xA;                    // Check the output directory for files&#xA;                    if (Directory.Exists(task.OutputFileRepoPath))&#xA;                    {&#xA;                        result.OutputFiles = Directory.GetFiles(task.OutputFileRepoPath);&#xA;                    }&#xA;                }&#xA;                else&#xA;                {&#xA;                    result.Success = false;&#xA;                    result.Message = "Failed to execute the command.";&#xA;                    result.ErrorDetails = success.ErrorDetails;&#xA;                }&#xA;            }&#xA;            catch (JsonException)&#xA;            {&#xA;                // Handle invalid JSON format&#xA;                result.Success = false;&#xA;                result.Message = "Invalid JSON format.";&#xA;                result.ErrorDetails = "Invalid data entry";&#xA;            }&#xA;        }&#xA;        catch (Exception ex)&#xA;        {&#xA;            result.Success = false;&#xA;            result.Message = "An error occurred during execution.";&#xA;            result.ErrorDetails = ex.Message;&#xA;        }&#xA;        finally&#xA;        {&#xA;            // Serialize the result to JSON and write to console&#xA;            string outputJson = JsonSerializer.Serialize(result, new JsonSerializerOptions { WriteIndented = true });&#xA;            Console.WriteLine(outputJson);&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;    using System;&#xA;using System.Collections.Generic;&#xA;using System.IO;&#xA;using System.Text.Json;&#xA;using System.Threading.Tasks;&#xA;using Docker.DotNet;&#xA;using Docker.DotNet.Models;&#xA;using Renderer.Models;&#xA;&#xA;public class DockerWorker&#xA;{&#xA;    private readonly DockerClient _dockerClient;&#xA;&#xA;    public DockerWorker()&#xA;    {&#xA;        Console.WriteLine("Initializing Docker client...");&#xA;        _dockerClient = new DockerClientConfiguration(&#xA;            new Uri("npipe://./pipe/docker_engine")) // Windows Docker URI&#xA;            .CreateClient();&#xA;        Console.WriteLine("Docker client initialized.");&#xA;    }&#xA;&#xA;    public async Task<dockertaskresult> RunDockerTaskAsync(DockerTask task)&#xA;    {&#xA;        var result = new DockerTaskResult();&#xA;&#xA;        try&#xA;        {&#xA;            Console.WriteLine("Starting Docker task...");&#xA;            Console.WriteLine($"Image: {task.ImageNaming}");&#xA;            Console.WriteLine($"Container: {task.ContainerNaming}");&#xA;            Console.WriteLine($"Input Path: {task.InputFileRepoPath}");&#xA;            Console.WriteLine($"Output Path: {task.OutputFileRepoPath}");&#xA;            Console.WriteLine($"Command: {task.CommandDef}");&#xA;&#xA;            // Ensure the Docker image exists&#xA;            Console.WriteLine("Checking if Docker image exists...");&#xA;            var imageCheckResult = await EnsureImageExists(task.ImageNaming);&#xA;            if (!imageCheckResult.Success)&#xA;            {&#xA;                result.Success = false;&#xA;                result.Message = imageCheckResult.Message;&#xA;                result.ErrorDetails = imageCheckResult.ErrorDetails;&#xA;                return result;&#xA;            }&#xA;            Console.WriteLine("Docker image verified.");&#xA;&#xA;            // Determine platform&#xA;            var platform = await GetImagePlatform(task.ImageNaming);&#xA;            Console.WriteLine($"Detected image platform: {platform}");&#xA;&#xA;            // Translate paths&#xA;            string inputVolume, outputVolume;&#xA;            if (platform == "linux")&#xA;            {&#xA;                inputVolume = $"{task.InputFileRepoPath.Replace("C:\\", "/mnt/c/").Replace("\\", "/")}:/app/input";&#xA;                outputVolume = $"{task.OutputFileRepoPath.Replace("C:\\", "/mnt/c/").Replace("\\", "/")}:/app/output";&#xA;            }&#xA;            else if (platform == "windows")&#xA;            {&#xA;                string inputDir = Path.GetFullPath(Path.GetDirectoryName(task.InputFileRepoPath)).TrimEnd(&#x27;\\&#x27;);&#xA;                string outputDir = Path.GetFullPath(task.OutputFileRepoPath).TrimEnd(&#x27;\\&#x27;);&#xA;&#xA;                if (!Directory.Exists(inputDir))&#xA;                {&#xA;                    throw new Exception($"Input directory does not exist: {inputDir}");&#xA;                }&#xA;                if (!Directory.Exists(outputDir))&#xA;                {&#xA;                    throw new Exception($"Output directory does not exist: {outputDir}");&#xA;                }&#xA;&#xA;                inputVolume = $"{inputDir}:C:\\app\\input";&#xA;                outputVolume = $"{outputDir}:C:\\app\\output";&#xA;&#xA;                Console.WriteLine($"Input volume: {inputVolume}");&#xA;                Console.WriteLine($"Output volume: {outputVolume}");&#xA;            }&#xA;            else&#xA;            {&#xA;                throw new Exception($"Unsupported platform: {platform}");&#xA;            }&#xA;&#xA;            // Create container&#xA;            Console.WriteLine("Creating Docker container...");&#xA;            var containerResponse = await _dockerClient.Containers.CreateContainerAsync(new CreateContainerParameters&#xA;            {&#xA;                Image = task.ImageNaming,&#xA;                Name = task.ContainerNaming,&#xA;                HostConfig = new HostConfig&#xA;                {&#xA;                    Binds = new List<string> { inputVolume, outputVolume },&#xA;                    AutoRemove = true&#xA;                },&#xA;                Cmd = new[] { platform == "linux" ? "bash" : "cmd.exe", "/c", task.CommandDef }&#xA;            });&#xA;&#xA;            if (string.IsNullOrEmpty(containerResponse.ID))&#xA;            {&#xA;                throw new Exception("Failed to create Docker container.");&#xA;            }&#xA;            Console.WriteLine($"Container created with ID: {containerResponse.ID}");&#xA;&#xA;            // Start container&#xA;            Console.WriteLine("Starting container...");&#xA;            bool started = await _dockerClient.Containers.StartContainerAsync(containerResponse.ID, new ContainerStartParameters());&#xA;            if (!started)&#xA;            {&#xA;                throw new Exception($"Failed to start container: {task.ContainerNaming}");&#xA;            }&#xA;&#xA;            // Wait for container to finish&#xA;            Console.WriteLine("Waiting for container to finish...");&#xA;            var waitResponse = await _dockerClient.Containers.WaitContainerAsync(containerResponse.ID);&#xA;&#xA;            if (waitResponse.StatusCode != 0)&#xA;            {&#xA;                Console.WriteLine($"Container exited with error code: {waitResponse.StatusCode}");&#xA;                await FetchContainerLogs(containerResponse.ID);&#xA;                throw new Exception($"Container exited with non-zero status code: {waitResponse.StatusCode}");&#xA;            }&#xA;&#xA;            // Fetch logs&#xA;            Console.WriteLine("Fetching container logs...");&#xA;            await FetchContainerLogs(containerResponse.ID);&#xA;&#xA;            result.Success = true;&#xA;            result.Message = "Docker task completed successfully.";&#xA;            return result;&#xA;        }&#xA;        catch (Exception ex)&#xA;        {&#xA;            Console.WriteLine($"Error: {ex.Message}");&#xA;            result.Success = false;&#xA;            result.Message = "An error occurred during execution.";&#xA;            result.ErrorDetails = ex.Message;&#xA;            return result;&#xA;        }&#xA;    }&#xA;&#xA;    private async Task<string> GetImagePlatform(string imageName)&#xA;    {&#xA;        try&#xA;        {&#xA;            Console.WriteLine($"Inspecting Docker image: {imageName}...");&#xA;            var imageDetails = await _dockerClient.Images.InspectImageAsync(imageName);&#xA;            Console.WriteLine($"Image platform: {imageDetails.Os}");&#xA;            return imageDetails.Os.ToLower();&#xA;        }&#xA;        catch (Exception ex)&#xA;        {&#xA;            throw new Exception($"Failed to inspect image: {ex.Message}");&#xA;        }&#xA;    }&#xA;&#xA;    private async Task<dockertaskresult> EnsureImageExists(string imageName)&#xA;    {&#xA;        var result = new DockerTaskResult();&#xA;        try&#xA;        {&#xA;            Console.WriteLine($"Pulling Docker image: {imageName}...");&#xA;            await _dockerClient.Images.CreateImageAsync(&#xA;                new ImagesCreateParameters { FromImage = imageName, Tag = "latest" },&#xA;                null,&#xA;                new Progress<jsonmessage>()&#xA;            );&#xA;            result.Success = true;&#xA;            result.Message = "Docker image is available.";&#xA;        }&#xA;        catch (Exception ex)&#xA;        {&#xA;            result.Success = false;&#xA;            result.Message = $"Failed to pull Docker image: {imageName}";&#xA;            result.ErrorDetails = ex.Message;&#xA;        }&#xA;        return result;&#xA;    }&#xA;&#xA;    private async Task FetchContainerLogs(string containerId)&#xA;    {&#xA;        try&#xA;        {&#xA;            Console.WriteLine($"Fetching logs for container: {containerId}...");&#xA;            var logs = await _dockerClient.Containers.GetContainerLogsAsync(&#xA;                containerId,&#xA;                new ContainerLogsParameters { ShowStdout = true, ShowStderr = true });&#xA;&#xA;            using (var reader = new StreamReader(logs))&#xA;            {&#xA;                string logLine;&#xA;                while ((logLine = await reader.ReadLineAsync()) != null)&#xA;                {&#xA;                    Console.WriteLine(logLine);&#xA;                }&#xA;            }&#xA;        }&#xA;        catch (Exception ex)&#xA;        {&#xA;            Console.WriteLine($"Failed to fetch logs: {ex.Message}");&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;    {&#xA;  "ImageNaming": "khuser/windowsimage:latest",&#xA;  "ContainerNaming": "custom-worker-container",&#xA;  "InputFileRepoPath": "C:/Users/user/source/repos/Renderer/Renderer/wwwroot/audio.mp4",&#xA;  "OutputFileRepoPath": "C:/Users/user/Desktop/output/",&#xA;  "CommandDef": "ffmpeg -i C:\\app\\input\\audio.mp4 -c copy C:\\app\\output\\copiedAudio.mp4"&#xA;</jsonmessage></dockertaskresult></string></string></dockertaskresult></dockertask>

    &#xA;

    }. My problem is what I get in the output of my program : Initializing Docker client... Docker client initialized. Starting Docker task... Image: khyoussef/windowsimage:latest Container: custom-worker-container Input Path: C:/Users/ykharoufi/source/repos/Renderer/Renderer/wwwroot/audio.mp4 Output Path: C:/Users/ykharoufi/Desktop/output/ Command: ffmpeg -i C:\app\input\audio.mp4 -c copy C:\app\output\copiedAudio.mp4 Checking if Docker image exists... Pulling Docker image: khyoussef/windowsimage:latest... Docker image verified. Inspecting Docker image: khyoussef/windowsimage:latest... Image platform: windows Detected image platform: windows Input volume: C:\Users\ykharoufi\source\repos\Renderer\Renderer\wwwroot:C:\app\input Output volume: C:\Users\ykharoufi\Desktop\output:C:\app\output Creating Docker container... Container created with ID: 1daca99b3c76bc8c99c1aed7d2c546ae75aedd9aa1feb0f5002e54769390248e Starting container... Waiting for container to finish... Container exited with error code: 1 Fetching logs for container: 1daca99b3c76bc8c99c1aed7d2c546ae75aedd9aa1feb0f5002e54769390248e... @&#x27;ffmpeg&#x27; is not recognized as an internal or external command, !operable program or batch file. Error: Container exited with non-zero status code: 1 { "Success": false, "Message": "Failed to execute the command.", "ErrorDetails": "Container exited with non-zero status code: 1", "OutputFiles": null }, This is the Dockerfile I am working with :

    &#xA;

    `# Use Windows Server Core as the base image&#xA;FROM mcr.microsoft.com/windows/server:ltsc2022&#xA;&#xA;# Set the working directory&#xA;WORKDIR /app&#xA;&#xA;# Install required tools (FFmpeg and Visual C&#x2B;&#x2B; Redistributable)&#xA;RUN powershell -Command \&#xA;    $ErrorActionPreference = &#x27;Stop&#x27;; \&#xA;    # Install Visual C&#x2B;&#x2B; Redistributable&#xA;    Invoke-WebRequest -Uri https://aka.ms/vs/16/release/vc_redist.x64.exe -OutFile vc_redist.x64.exe; \&#xA;    Start-Process -FilePath vc_redist.x64.exe -ArgumentList &#x27;/install&#x27;, &#x27;/quiet&#x27;, &#x27;/norestart&#x27; -NoNewWindow -Wait; \&#xA;    Remove-Item -Force vc_redist.x64.exe; \&#xA;    # Download FFmpeg&#xA;    Invoke-WebRequest -Uri https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n7.1-latest-win64-gpl-7.1.zip -OutFile ffmpeg.zip; \&#xA;    # Extract FFmpeg&#xA;    Expand-Archive -Path ffmpeg.zip -DestinationPath C:\ffmpeg; \&#xA;    Remove-Item -Force ffmpeg.zip; \&#xA;    # Debug step: Verify FFmpeg extraction&#xA;    Write-Output "FFmpeg extracted to C:\\ffmpeg"; \&#xA;    dir C:\ffmpeg; \&#xA;    dir C:\ffmpeg\ffmpeg-n7.1-latest-win64-gpl-7.1\bin&#xA;&#xA;# Add FFmpeg to PATH permanently&#xA;ENV PATH="C:\\ffmpeg\\ffmpeg-n7.1-latest-win64-gpl-7.1\\bin;${PATH}"&#xA;&#xA;# Verify FFmpeg installation&#xA;RUN ["cmd", "/S", "/C", "ffmpeg -version"]&#xA;&#xA;# Copy required files to the container&#xA;COPY ./ /app/&#xA;&#xA;# Default to a PowerShell session&#xA;CMD ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-NoExit"]&#xA;`&#xA;

    &#xA;

    . I did build it using this command : docker build -t khuser/windowsimage:latest -f Dockerfile .

    &#xA;