Recherche avancée

Médias (2)

Mot : - Tags -/documentation

Autres articles (33)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour 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 (...)

Sur d’autres sites (4287)

  • FFmpeg Wasm, error while creating video from canvas

    12 octobre 2023, par NineCattoRules

    I'm using ffmpeg.wasm in my Next.JS app.

    


    Here my specs :

    


    "@ffmpeg/ffmpeg": "^0.12.5",
"@ffmpeg/util": "^0.12.0",
"next": "^13.0.6",
"react": "^18.2.0",


    


    I want to simply record a 5s video from a canvas, so I tried :

    


    &#x27;use client&#x27;&#xA;&#xA;import React, { useEffect, useRef, useState } from &#x27;react&#x27;;&#xA;import { FFmpeg } from &#x27;@ffmpeg/ffmpeg&#x27;;&#xA;import { fetchFile } from &#x27;@ffmpeg/util&#x27;;&#xA;&#xA;const CanvasVideoRecorder = () => {&#xA;    const canvasRef = useRef(null);&#xA;    const videoChunksRef = useRef([]);&#xA;    const ffmpegRef = useRef(new FFmpeg({ log: true }));&#xA;    const [loaded, setLoaded] = useState(false);&#xA;    const [videoUrl, setVideoUrl] = useState(null);&#xA;&#xA;    const load = async () => {&#xA;        await ffmpegRef.current.load({&#xA;            coreURL: &#x27;/js/ffmpeg-core.js&#x27;,&#xA;            wasmURL: &#x27;/js/ffmpeg-core.wasm&#x27;,&#xA;        });&#xA;        setLoaded(true);&#xA;    };&#xA;&#xA;    useEffect(() => {&#xA;        const ctx = canvasRef.current.getContext(&#x27;2d&#x27;);&#xA;        function drawFrame(timestamp) {&#xA;            ctx.fillStyle = `rgb(${(Math.sin(timestamp / 500) * 128) &#x2B; 128}, 0, 0)`;&#xA;            ctx.fillRect(0, 0, canvasRef.current.width, canvasRef.current.height);&#xA;            requestAnimationFrame(drawFrame);&#xA;        }&#xA;        requestAnimationFrame(drawFrame);&#xA;    }, []);&#xA;&#xA;    const startRecording = async () => {&#xA;        const videoStream = canvasRef.current.captureStream(30);&#xA;        const videoRecorder = new MediaRecorder(videoStream, { mimeType: &#x27;video/webm&#x27; });&#xA;&#xA;        videoRecorder.ondataavailable = (event) => {&#xA;            if (event.data.size > 0) {&#xA;                videoChunksRef.current.push(event.data);&#xA;            }&#xA;        };&#xA;&#xA;        videoRecorder.start();&#xA;        setTimeout(() => videoRecorder.stop(), 5000);&#xA;&#xA;        videoRecorder.onstop = async () => {&#xA;            try {&#xA;                await ffmpegRef.current.writeFile(&#x27;recorded.webm&#x27;, await fetchFile(new Blob(videoChunksRef.current, { type: &#x27;video/webm&#x27; })));&#xA;&#xA;                await ffmpegRef.current.exec(&#x27;-y&#x27;, &#x27;-i&#x27;, &#x27;recorded.webm&#x27;, &#x27;-an&#x27;, &#x27;-c:v&#x27;, &#x27;copy&#x27;, &#x27;output_copy.webm&#x27;);&#xA;&#xA;                const data = await ffmpegRef.current.readFile(&#x27;output_copy.webm&#x27;);&#xA;                const url = URL.createObjectURL(new Blob([data.buffer], { type: &#x27;video/webm&#x27; }));&#xA;&#xA;                setVideoUrl(url);&#xA;            } catch (error) {&#xA;                console.error("Error during processing:", error);&#xA;            }&#xA;        };&#xA;    };&#xA;&#xA;    return (&#xA;        <div>&#xA;            <canvas ref="{canvasRef}" width="640" height="480"></canvas>&#xA;&#xA;            {loaded ? (&#xA;                &lt;>&#xA;&#xA;                    <button>Start Recording</button>&#xA;                    {videoUrl &amp;&amp; <video controls="controls" src="{videoUrl}"></video>}&#xA;                >&#xA;            ) : (&#xA;                <button>Load FFmpeg</button>&#xA;            )}&#xA;        </div>&#xA;    );&#xA;};&#xA;&#xA;export default CanvasVideoRecorder;&#xA;

    &#xA;

    I don't know why but it catch an error :

    &#xA;

    ErrnoError: FS error&#xA;

    &#xA;

    This error occurs when I do this :

    &#xA;

    await ffmpegRef.current.exec(&#x27;-y&#x27;, &#x27;-i&#x27;, &#x27;recorded.webm&#x27;, &#x27;-an&#x27;, &#x27;-c:v&#x27;, &#x27;copy&#x27;, &#x27;output_copy.webm&#x27;);&#xA;const data = await ffmpegRef.current.readFile(&#x27;output_copy.webm&#x27;);&#xA;

    &#xA;

    The recorded.webm file is written correctly and I can read it, ffmpegRef.current is well defined, so what's wrong with my logic, why the exec command doesn't work ?

    &#xA;

  • FFmpeg zoompan animation results in zig-zag pattern [closed]

    2 février 2024, par kregus

    please assist, as I am pulling my hair out !

    &#xA;

    The goal is for a user to specify a zoomPoint in a video as follows :

    &#xA;

    {&#xA;   "scale":4,        # Scale factor, here x4&#xA;   "offset":0,       # Start zooming in after 0ms&#xA;   "duration":5000,  # Stay zoomed in for 5000ms&#xA;   "marginX":80,     # Zoom x to 80% of video width &#xA;   "marginY":10      # Zoom y to 10% of video height&#xA;}&#xA;

    &#xA;

    I am running the following, simplified FFmpeg command :

    &#xA;

    ffmpeg -i "/tmp/input.mp4" -c:v libx264 -r 30 -vf "scale=iw*2:ih*2,zoompan=fps=30:z=&#x27;if(gte(it,0.0)*lt(it,5.0), min(pzoom&#x2B;0.2, 4),if(gte(it,5.0)*lt(it,5.5), max(pzoom-0.2, 1), 1))&#x27;:d=1:s=1512x982:x=&#x27;(iw - iw/4)*(80/100)&#x27;:y=&#x27;(ih - ih/4)*(10/100)&#x27;" /tmp/output.mp4&#xA;

    &#xA;

    The animation duration is 0.5s, the video framerate is 30fps, and so there are 0.5 / (1/30) = 15 animation frames.

    &#xA;

    Zoom distance is scale - 1 = 3 in this case, which makes the zoom increment 3 / 15 = 0.2.

    &#xA;

    This results in the following example video : click here

    &#xA;

    While the zoom animation ends in the correct position, you will notice it arrives at that position in a zig-zag pattern, where it starts by zooming into the top-right corner, before changing direction towards the correct position.

    &#xA;

    I cannot seem to figure out how to get it to animate the zoom in a straight line to the specified x/y position.

    &#xA;

    Any tips are welcome, thanks !

    &#xA;

  • Problems decoding a gstreamer pipeline into images using node.js

    18 septembre 2023, par JK2018

    I have this Gstreamer pipeline that launches a test video , encodes it in h264 and sends it via udp on localhost 5000.

    &#xA;

    gst-launch-1.0 -v videotestsrc ! videoconvert ! x264enc tune=zerolatency ! h264parse ! queue ! rtph264pay ! udpsink host=127.0.0.1 port=5000&#xA;

    &#xA;

    I run this pipeline in my terminal.

    &#xA;

    Then I have a minimalistic node.js server that is suposed to receive the udp stream coming from the gstreamer pipeline, decode the video into images.&#xA;Finally I emit each image (not a fragment of an image) over a socket.

    &#xA;

    I have tried several approaches unsuccessfully.&#xA;My first attempt was using a node gstreamer library and use gstreamer to decode the udp and re encode as images.

    &#xA;

    My second attempt was using ffmpeg library.&#xA;Here is the code below :

    &#xA;

    const express = require("express");&#xA;const http = require("http");&#xA;const { Server } = require("socket.io");&#xA;const socketIO = require("socket.io");&#xA;const cors = require("cors");&#xA;const app = express();&#xA;const server = http.createServer(app);&#xA;const dgram = require("dgram");&#xA;const ffmpeg = require("fluent-ffmpeg");&#xA;&#xA;const io = socketIO(server, {&#xA;  cors: {&#xA;    origin: "http://localhost:3001",&#xA;    methods: ["GET", "POST"],&#xA;  },&#xA;});&#xA;&#xA;app.use(&#xA;  cors({&#xA;    origin: "http://localhost:3001",&#xA;    methods: ["GET", "POST"],&#xA;  })&#xA;);&#xA;&#xA;const udpServer = dgram.createSocket("udp4");&#xA;&#xA;io.on("connection", (socket) => {&#xA;  console.log("A client connected");&#xA;&#xA;  socket.on("disconnect", () => {&#xA;    console.log("A client disconnected");&#xA;  });&#xA;});&#xA;&#xA;// Function to decode an H.264 video frame&#xA;function decodeH264Video(inputData, callback) {&#xA;  const command = ffmpeg()&#xA;    .input(inputData)&#xA;    .inputFormat("h264")&#xA;    .inputOptions(["-c:v h264"])&#xA;    .toFormat("image2")&#xA;    .on("end", () => {&#xA;      console.log("Decoding complete");&#xA;    })&#xA;    .on("error", (err) => {&#xA;      console.error("Error decoding video:", err);&#xA;    })&#xA;    .pipe();&#xA;&#xA;  callback(command);&#xA;}&#xA;&#xA;// Function to convert a decoded video frame to an image (JPEG format)&#xA;function convertVideoFrameToImage(decodedData, callback) {&#xA;  const imageStream = decodedData.pipe();&#xA;  const imageBuffer = [];&#xA;&#xA;  imageStream.on("data", (chunk) => {&#xA;    imageBuffer.push(chunk);&#xA;  });&#xA;&#xA;  imageStream.on("end", () => {&#xA;    const imageData = Buffer.concat(imageBuffer);&#xA;    callback(imageData);&#xA;  });&#xA;}&#xA;&#xA;udpServer.on("message", (message) => {&#xA;  // Decode the UDP packet containing H.264 encoded video&#xA;  decodeH264Video(message, (decodedVideo) => {&#xA;    // Process the decoded video frame and convert it to an image&#xA;    convertVideoFrameToImage(decodedVideo, (imageData) => {&#xA;      // Send the image data to connected clients&#xA;      io.sockets.emit("image", { imageData: imageData.toString("base64") });&#xA;    });&#xA;  });&#xA;});&#xA;&#xA;udpServer.bind(5000);&#xA;&#xA;server.listen(3000, () => {&#xA;  console.log("Server is running on port 3000");&#xA;});&#xA;

    &#xA;

    Any help is more than welcome

    &#xA;