Recherche avancée

Médias (1)

Mot : - Tags -/copyleft

Autres articles (41)

  • 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 ;

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

Sur d’autres sites (8693)

  • Not getting partial video content while using ffmpeg

    1er mai 2023, par MI Sabic

    I'm trying to partially send a video using nodejs and fluent-ffmpeg. But it's failing to send the data.

    


    When I send the video using only fs module only, it works fine. Here's the code.

    


    const express = require("express");
const app = express();  
const fs = require("fs");

const VIDEO_PATH = 'video.mp4';

app.get("/", (req, res) => {
  res.sendFile(__dirname + "/index.html");
})

app.get("/video", (req, res) => {
  const range = req.headers.range;
  if(!range) {
    res.status(400).send("Requires range header!");
  }

  const size = fs.statSync(VIDEO_PATH).size;
  const CHUNK_SIZE = 10**6;
  const start = Number(range.replace(/\D/g, ""));
  const end = Math.min(start + CHUNK_SIZE, size - 1);

  const contentLength = end - start + 1;

  const headers = {
    "Content-Range": `bytes ${start}-${end}/${size}`,
    "Accept-Ranges": 'bytes',
    "Content-Length": contentLength, 
    "Content-Type": "video/mp4"
  }

  res.writeHead(206, headers);

  const videoStream = fs.createReadStream(VIDEO_PATH, {start, end});
  videoStream.pipe(res);
})

app.listen(3000, () => {
  console.log("Server is running on port: ", 3000);
})


    


    When I send the video after processing it using fluent-ffmpeg module, it doesn't work. I've simplified the code for understanding. Here's my code.

    


    const express = require("express");
const app = express();  
const fs = require("fs");
const ffmpegStatic = require('ffmpeg-static');
const ffmpeg = require('fluent-ffmpeg');

ffmpeg.setFfmpegPath(ffmpegStatic);

const VIDEO_PATH = 'video.mp4';

app.get("/", (req, res) => {
  res.sendFile(__dirname + "/index.html");
})

app.get("/video", (req, res) => {
  const range = req.headers.range;
  if(!range) {
    res.status(400).send("Requires range header!");
  }

  const size = fs.statSync(VIDEO_PATH).size;
  const CHUNK_SIZE = 10**6;
  const start = Number(range.replace(/\D/g, ""));
  const end = Math.min(start + CHUNK_SIZE, size - 1);

  const contentLength = end - start + 1;

  const headers = {
    "Content-Range": `bytes ${start}-${end}/${size}`,
    "Accept-Ranges": 'bytes',
    "Content-Length": contentLength, 
    "Content-Type": "video/mp4"
  }

  res.writeHead(206, headers);

  const videoStream = fs.createReadStream(VIDEO_PATH, {start, end});

  ffmpeg(videoStream)
    .outputOptions('-movflags frag_keyframe+empty_moov')
    .toFormat('mp4')
    .pipe(res);
})

app.listen(3000, () => {
  console.log("Server is running on port: ", 3000);
})


    


    My index.html

    


    &#xA;&#xA;&#xA;  &#xA;  &#xA;  &#xA;  &#xA;&#xA;&#xA;  <video width="50%" controls="controls">&#xA;    <source src="/video" type="video/mp4">&#xA;  </source></video>&#xA;&#xA;&#xA;

    &#xA;

    Any help would be appreciated. Thanks in advance.

    &#xA;

  • ffmpeg : use vidstabtransform to overlay it over blurred background

    5 novembre 2023, par konewka

    I am using ffmpeg to concatenate multiple video clips taken from the same object over multiple timeframes. To make sure the videos are properly aligned (and therefore show the object in rougly the same position), I manually identify two points in the first frame each clip, and use that to calculate the scaling and positioning necessary for proper alignment. I'm using Python for this, and it also generates the ffmpeg command for me. When it has calculated that the appropriate scale of the video is less than 100%, that means that some parts of the frame will become black. To counter that, I overlay the scaled and positioned video over a blurred version of the original video (like this effect)

    &#xA;

    Now, additionally, some of the video clips are a bit shaky, so my flow now first applies the vidstabdetect and vidstabtransform filters, and uses the transformed stabilized version as input for my final command. However, if the shaking is significant, the vidstabtransform will zoom in and therefore I will either lose some of the details around the edges, or a black border is created around the edge. As I am later including the stabilized version of the video in the concatenation, with the possibility of it shrinking, I would rather perform the vidstabtransform step inside my command, and use the output directly into the overlay over the blurred version. That way, I would want to achieve that the clip rotates across the frame as it is stabilized, and it is shown over the blurred background. Is it possible to achieve this using ffmpeg, or am I trying to stretch it too far ?

    &#xA;

    As a minimal example, these are my commands :

    &#xA;

    ffmpeg -i video1.mp4 -vf vidstabdetect=output=transform.trf -f null - &#xA;&#xA;ffmpeg -i video1.mp4 -vf vidstabtransform=input=transform.trf video1_stabilized.mp4&#xA;&#xA;# same for video2.mp4&#xA;&#xA;ffmpeg -i video1_stabilized.mp4 -i video2_stabilized.mp4 -filter_complex "&#xA;    [0:v]split=2[v0blur][v0scale];&#xA;    [v0blur]gblur=sigma=50[v0blur];  // blur the video&#xA;    [v0scale]scale=round(iw*0.8/2)*2:round(ih*0.8/2)*2[v0scale];  // scale the video&#xA;    [v0blur][v0scale]overlay=x=100:y=200[v0];  // overlay the scaled video over the blur at a specific location&#xA;    [1:v]split=2[v1blur][v1scale];&#xA;    [v1blur]gblur=sigma=50[v1blur];&#xA;    [v1scale]scale=round(iw*0.9/2)*2:round(ih*0.9/2)*2[v1scale];&#xA;    [v1blur][v1scale]overlay=x=150:y=150[v1];&#xA;    [v0][v1]concat=n=2  // concatenate the two clips" &#xA;-c:v libx264 -r 30 out.mp4&#xA;

    &#xA;

    So, I know I can put the vidstabtransform step into the filter_complex-graph (I'll do the detection in a separate step still), but can I also use it such that I can achieve the stabilization over the blurred background and have the clip move around the frame as it is stabilized ?

    &#xA;

    EDIT : so to include vidstabtransform into the filter graph, it would then look like this :

    &#xA;

    ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "&#xA;    [0:v]vidstabtransform=input=transform1.trf[v0stab]&#xA;    [v0stab]split=2[v0blur][v0scale];&#xA;    [v0blur]gblur=sigma=50[v0blur];&#xA;    [v0scale]scale=round(iw*0.8/2)*2:round(ih*0.8/2)*2[v0scale];&#xA;    [v0blur][v0scale]overlay=x=100:y=200[v0];&#xA;    [1:v]vidstabtransform=input=transform2.trf[v1stab]&#xA;    [v1stab]split=2[v1blur][v1scale];&#xA;    [v1blur]gblur=sigma=50[v1blur];&#xA;    [v1scale]scale=round(iw*0.9/2)*2:round(ih*0.9/2)*2[v1scale];&#xA;    [v1blur][v1scale]overlay=x=150:y=150[v1];&#xA;    [v0][v1]concat=n=2"&#xA;-c:v libx264 -r 30 out.mp4&#xA;

    &#xA;

  • Haskell - Converting multiple images into a video file - ffmpeg-lights' frameWriter-function fails

    26 octobre 2017, par oRole

    Situation
    Currently I am working on an application for image-processing that uses ffmpeg-light to fetch all the frames of a given video-file so that the program afterwards can apply grayscaling, as well as edge detection alogrithms to each of the frames.

    With the help of friendly stackoverflowers I was able to set up a method capable of converting several images into one video file using ffmpeg-lights’ frameWriter function.

    Problem
    The application runs fine to the moment it hits the frameWriterfunction and I don’t really know why as there are no errors or exception-messages thrown. (OS : Win 10 64bit)

    What did I try ?
    I tried..

    - different versions of ffmpeg (from 3.2 to 3.4).

    - ffmpeg.exe using the command line to test if there are any codecs missing, but any conversion I tried worked.

    - different EncodingParams-combinations : like.. EncodingParams width height fps (Nothing) (Nothing) "medium"

    Question
    Unfortunately, none of above worked and the web lacks on information to that specific case. Maybe I missed something essential (like ghc flags or something) or made a bigger mistake within my code. That is why I have to ask you : Do you have any suggestions/advice for me ?

    Haskell Packages

    - ffmpeg-light-0.12.0

    - JuicyPixels-3.2.8.3

    Code

    {--------------------------------------------------------------------------------------------
    Applies "juicyToFFmpeg'" and "getFPS" to a list of images and saves the output-video
    to a user defined location.
    ---------------------------------------------------------------------------------------------}    
    saveVideo :: String -> [Image PixelYA8] -> Int -> IO ()
    saveVideo path imgs fps = do
            -- program stops after hitting next line --
            frame &lt;- frameWriter ep path
            ------------------------------------------------
            Prelude.mapM_ (frame . Just) ffmpegImgs
            frame Nothing
            where ep = EncodingParams width height fps (Just avCodecIdMpeg4) (Just avPixFmtGray8a) "medium"
                  width      = toCInt $ imageWidth  $ head imgs
                  height     = toCInt $ imageHeight $ head imgs
                  ffmpegImgs = juicyToFFmpeg' imgs
                  toCInt x   = fromIntegral x :: CInt

    {--------------------------------------------------------------------------------------------
    Converts a single image from JuicyPixel-format to ffmpeg-light-format.
    ---------------------------------------------------------------------------------------------}      
    juicyToFFmpeg :: Image PixelYA8 -> (AVPixelFormat, V2 CInt, Vector CUChar)
    juicyToFFmpeg img = (avPixFmtGray8a, V2 (toCInt width) (toCInt height), ffmpegData)
                     where toCInt   x   = fromIntegral x :: CInt
                           toCUChar x   = fromIntegral x :: CUChar
                           width        = imageWidth img
                           height       = imageHeight img
                           ffmpegData   = VS.map toCUChar (imageData img)

    {--------------------------------------------------------------------------------------------
    Converts a list of images from JuicyPixel-format to ffmpeg-light-format.
    ---------------------------------------------------------------------------------------------}                        
    juicyToFFmpeg' :: [Image PixelYA8] -> [(AVPixelFormat, V2 CInt, Vector CUChar)]
    juicyToFFmpeg' imgs = Prelude.foldr (\i acc -> acc++[juicyToFFmpeg i]) [] imgs

    {--------------------------------------------------------------------------------------------
    Simply calculates the FPS for image-to-video conversion.
    -> frame :: (Double, DynamicImage) where Double is a timestamp of when it got extracted
    ---------------------------------------------------------------------------------------------}
    getFPS :: [(Double, DynamicImage)] -> Int
    getFPS frames = div (ceiling $ lastTimestamp - firstTimestamp) frameCount :: Int
                 where firstTimestamp = fst $ head frames
                       lastTimestamp  = fst $ last frames
                       frameCount     = length frames