Recherche avancée

Médias (0)

Mot : - Tags -/objet éditorial

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (55)

  • MediaSPIP Core : La Configuration

    9 novembre 2010, par

    MediaSPIP Core fournit par défaut trois pages différentes de configuration (ces pages utilisent le plugin de configuration CFG pour fonctionner) : une page spécifique à la configuration générale du squelettes ; une page spécifique à la configuration de la page d’accueil du site ; une page spécifique à la configuration des secteurs ;
    Il fournit également une page supplémentaire qui n’apparait que lorsque certains plugins sont activés permettant de contrôler l’affichage et les fonctionnalités spécifiques (...)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Les images

    15 mai 2013

Sur d’autres sites (5899)

  • Saving a continuous stream of images from ffmpeg image2pipe using golang

    11 février 2020, par Mina

    I am trying to save a sequence/continuous images from ffmpeg image2pipe in go. The problem with the code below that it does only save the first image in the stream due to the blocking nature of io.Copy since it waits for the reader or the writer to close.

    package main

    import (
       "fmt"
       "io"
       "log"
       "os"
       "os/exec"
       "strconv"
       "time"
    )

    //Trying to get png from stdout pipe

    func main() {
       fmt.Println("Running the camera stream")
       ffmpegCmd := exec.Command("ffmpeg", "-loglevel", "quiet", "-y", "-rtsp_transport", "tcp", "-i", "rtsp://admin:123456@192.168.1.41:554/h264Preview_01_main", "-r", "1", "-f", "image2pipe", "pipe:1")

       ffmpegOut, err := ffmpegCmd.StdoutPipe()
       if err != nil {
           return
       }

       err = ffmpegCmd.Start()

       if err != nil {
           log.Fatal(err)
       }

       count := 0
       for {
           count++
           t := time.Now()
           fmt.Println("writing image" + strconv.Itoa(count))
           filepath := "image-" + strconv.Itoa(count) + "-" + t.Format("20060102150405.png")

           out, err := os.Create(filepath)
           if err != nil {
               log.Fatal(err)
           }
           defer out.Close()

           _, err = io.Copy(out, ffmpegOut)
           if err != nil {
               log.Fatalf("unable to copy to file: %s", err.Error())
           }
       }
       if err := ffmpegCmd.Wait(); err != nil {
           log.Fatal("Error while waiting:", err)
       }
    }

    I implemented my own save and copy function based on the io.Copy code https://golang.org/src/io/io.go

    func copyAndSave(w io.Writer, r io.Reader) error {
       buf := make([]byte, 1024, 1024)
       for {
           n, err := r.Read(buf[:])
           if n == 0 {

           }
           if n > 0 {
               d := buf[:n]
               _, err := w.Write(d)
               if err != nil {
                   return err
               }
           }
           if err != nil {
               return err
           }

       }
       return nil
    }

    then I updated the for loop in my main function to the below block but still I am only getting the first image in the sequence. due to r.Read(buf[:]) is being a blocking call.

    for {
           count++
           t := time.Now()
           fmt.Println("writing image" + strconv.Itoa(count))
           filepath := "image-" + strconv.Itoa(count) + "-" + t.Format("20060102150405.png")

           out, err := os.Create(filepath)
           if err != nil {
               log.Fatal(err)
           }
           defer out.Close()

           err = copyAndSave(out, ffmpegOut)
           if err != nil {
               if err == io.EOF {
                   break
               }
               log.Fatalf("unable to copy to file: %s", err.Error())
               break
           }
       }

    Any help is appreciated and sorry for in typos in advance :)

  • From time to time ffmpeg makes my computer unable to restart

    6 juin 2022, par principal-ideal-domain

    I'm doing very time consuming ffmpeg video editing. That's why I put my commands into a .bat file and run them over night. Usually that works fine but from time to time when I look at the next moring a see an error message of this kind :

    


    enter image description here

    


    From that state on I didn't find any good way to close the console. When I press the x in the top right corner, it freezes. When I try to kill it using the task manager nothing happens. Even explorer.exe can't be closed using the task manager. A shutdown won't do anything. During the last month I had this problem about three times and the only way I could close it was to long press the power button of the computer until it was turned off this hard way.

    


    Any ideas what to in such situations ? Or even better : Any ideas how to prevent those situations ? What is the reason for the error ? Do you understand the message ? By the way, when the computer is started again then at the next morining and I run the same bat file again everything works fine. So the same error does not repeat and the video is edited nicely.

    


    Edit : Now, about one week after posting this question the problem occurred many more times. It is very annoying. I guess it has to do with the external hard drive connected by USB. Sometimes it randomly interrupts the connection. That might be the reason for the behavior. However that be, I want to learn a solution how to deal with this in future. I don't want to always push the reset button of my computer. I want a proper way to shut it down.

    


  • Piping frames to ffmpeg with Node

    6 janvier 2020, par DeeBo

    I’ve got some NodeJS that’s generating images, and passes me an array called sceneData, which is an array with the format : [ ['./frame1.jpg', 0.25], ['./frame2.jpg', 0.5] ] (framePath, secondsToShowFor). I want to stream the frame data off disk and into ffmpeg for however many frames are required for that amount of seconds.

    I’ve written this so far, but it doesn’t work. The script doesn’t close and I’m left with a 0 byte mp4 file. Anyone have any ideas for how to pipe frames into ffmpeg from disk with node ?

    const { spawn } = require('child_process')
    const fs = require('fs')

    function getFfmpeg (framerate, outputFilename = './test.mp4') {
     const args = `-f image2pipe -vcodec mjpeg -s 1920x1080 -i - -f mp4 -r ${framerate} ${outputFilename}`.split(' ')
     const ffmpeg = spawn('ffmpeg', args)

     ffmpeg.stdout.pipe(process.stdout)
     ffmpeg.stderr.pipe(process.stderr)

     return ffmpeg
    }

    // In the form of [framePath, duractionInSeconds]
    async function generateVideo (sceneData, framerate = 24) {
     const ffmpeg = getFfmpeg(framerate)

     for (const sD of sceneData) {
       // # of frames it'll be shown for
       const frames = Math.ceil(framerate * sD[1])

       for (let i = 0; i < frames; i++) {
         const readStream = fs.createReadStream(sD[0])
         readStream.pipe(ffmpeg.stdin, { end: false })
         readStream.close()
       }
     }
    }

    module.exports = {
     generateVideo
    }