Recherche avancée

Médias (1)

Mot : - Tags -/publicité

Autres articles (94)

  • Les notifications de la ferme

    1er décembre 2010, par

    Afin d’assurer une gestion correcte de la ferme, il est nécessaire de notifier plusieurs choses lors d’actions spécifiques à la fois à l’utilisateur mais également à l’ensemble des administrateurs de la ferme.
    Les notifications de changement de statut
    Lors d’un changement de statut d’une instance, l’ensemble des administrateurs de la ferme doivent être notifiés de cette modification ainsi que l’utilisateur administrateur de l’instance.
    À la demande d’un canal
    Passage au statut "publie"
    Passage au (...)

  • D’autres logiciels intéressants

    12 avril 2011, par

    On ne revendique pas d’être les seuls à faire ce que l’on fait ... et on ne revendique surtout pas d’être les meilleurs non plus ... Ce que l’on fait, on essaie juste de le faire bien, et de mieux en mieux...
    La liste suivante correspond à des logiciels qui tendent peu ou prou à faire comme MediaSPIP ou que MediaSPIP tente peu ou prou à faire pareil, peu importe ...
    On ne les connais pas, on ne les a pas essayé, mais vous pouvez peut être y jeter un coup d’oeil.
    Videopress
    Site Internet : (...)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

Sur d’autres sites (12353)

  • How to implement live video streaming with ffmpeg without using WebRTC ?

    8 août 2024, par Artem

    Following up on my previous question, I'd like to inquire about alternative methods for live video streaming using ffmpeg (WebRTC is not an option due to certain constraints I prefer not to discuss here).

    


    Context :

    


    I have a Go application where a goroutine launches ffmpeg to process a video stream, which is then delivered to the main goroutine via a chan []byte. I tried using WebSocket, but encountered issues as described in the previous question. HLS also didn't work well due to significant latency and artifacts like green squares on the video.

    


    Based on a comment in the previous question, I attempted to stream the video via a simple GET request. Here's the Go handler I implemented :

    


    func stream(helperApp agent.Helper) func(rw http.ResponseWriter, rr *http.Request) {
   a := atomic.Bool{}
   return func(rw http.ResponseWriter, rr *http.Request) {
      if !a.CAS(false, true) {
         http.Error(rw, "already running", http.StatusInternalServerError)
         return
      }

      rw.Header().Set("Access-Control-Allow-Origin", "*")
      rw.Header().Set("Content-Type", "video/mp2t")

      out := make(chan []byte)

      // create StreamParam
      go ScreenCaptureForLiveStream(StreamParam, out) // ffmpeg process starts inside

      r, w := io.Pipe()
      go func() {
         for data := range out {
            w.Write(data)
            fmt.Println(len(data))
         }
      }()
      io.Copy(rw, r)
   }
}



    


    On the client side (HTML) :

    


    <video muted="muted" src="http://localhost:8080/stream" controls="controls"></video>&#xA;

    &#xA;

    In the browser console, I can see data being received, but the video doesn't play.

    &#xA;

    FFmpeg is executed with these parameters :

    &#xA;

    -loglevel error -f avfoundation -framerate 5 -capture_cursor 1 -capture_mouse_clicks 1 -i 1 -c:v libx264 -pix_fmt yuv420p -vf pad=&#x27;ceil(iw/2)*2:ceil(ih/2)*2&#x27; -threads 0 -preset veryfast -bf 2 -f mpegts pipe:1&#xA;&#xA;

    &#xA;

    For validation, I ran :

    &#xA;

    ffmpeg -i http://localhost:8080/stream -c copy out.mp4&#xA;&#xA;

    &#xA;

    The video was successfully saved and plays.

    &#xA;

    Question :&#xA;What alternative methods exist to implement live video streaming with ffmpeg, aside from WebRTC ? Why does the current approach of streaming video via HTTP GET request not function correctly in the browser, and how can this be resolved ?

    &#xA;

  • How to stop FFMPEG without stop application in Golang ?

    23 juillet 2022, par Tammam

    I'm making a WEB-based screen record application (if the link is accessed then the record will run) using FFMPEG, but I still haven't found a way to stop the record without stopping the web application (Now still pressing Ctrl+C to stop the recording process and the application will stop too). How do I do that when I click a link (eg host/record/stop) the record will stop without stopping the application

    &#xA;

    here my code

    &#xA;

    //Handler to create room/start record&#xA;func RoomCreate(c *fiber.Ctx) error {&#xA;    fileName := "out.mp4"&#xA;    fmt.Println(fileName)&#xA;    if len(os.Args) > 1 {&#xA;        fileName = os.Args[1]&#xA;    }&#xA;&#xA;    &#xA;&#xA;    errCh := make(chan error, 2)&#xA;    ctx, cancelFn := context.WithCancel(context.Background())&#xA;    // Record&#xA;    go func() { errCh &lt;- recordToVideo(ctx, fileName) }()&#xA;&#xA;    go func() {&#xA;        errCh &lt;- nil&#xA;    }()&#xA;    err := &lt;-errCh&#xA;    cancelFn()&#xA;    if err != nil &amp;&amp; err != context.Canceled {&#xA;        log.Fatalf("Execution failed: %v", err)&#xA;    }&#xA;    &#xA;    return c.Redirect(fmt.Sprintf("/room/%s", guuid.New().String()))&#xA;}&#xA;&#xA;func recordToVideo(ctx context.Context, fileName string) error {&#xA;    ctx, cancelFn := context.WithCancel(ctx)&#xA;    defer cancelFn()&#xA;    // Build ffmpeg&#xA;    ffmpeg := exec.Command("ffmpeg",&#xA;        "-f", "gdigrab",&#xA;        "-framerate", "30",&#xA;        "-i", "desktop",&#xA;        fileName,&#xA;    )&#xA;    // Stdin for sending data&#xA;    stdin, err := ffmpeg.StdinPipe()&#xA;    if err != nil {&#xA;        return err&#xA;    }&#xA;    //var buf bytes.Buffer&#xA;    defer stdin.Close()&#xA;    // Run it in the background&#xA;    errCh := make(chan error, 1)&#xA;&#xA;    go func() {&#xA;        fmt.Printf("Executing: %v\n", strings.Join(ffmpeg.Args, " "))&#xA;        //Here if&#xA;        out, err := ffmpeg.CombinedOutput()&#xA;        fmt.Printf("FFMPEG output:\n%v\n", string(out))&#xA;        errCh &lt;- err&#xA;    }()&#xA;    // Just start sending a bunch of frames&#xA;    for {&#xA;        // Check if we&#x27;re done, otherwise go again&#xA;        select {&#xA;        case &lt;-ctx.Done():&#xA;            return ctx.Err()&#xA;        case err := &lt;-errCh:&#xA;            return err&#xA;        default:&#xA;        }&#xA;    }&#xA;}&#xA;&#xA;//Function to run command FFMPEG&#xA;func recordToVideo(ctx context.Context, fileName string) error {&#xA;    ctx, cancelFn := context.WithCancel(ctx)&#xA;    defer cancelFn()&#xA;    // Build ffmpeg&#xA;    ffmpeg := exec.Command("ffmpeg",&#xA;        "-f", "gdigrab",&#xA;        "-framerate", "30",&#xA;        "-i", "desktop",&#xA;        "-f", "mp4",&#xA;        fileName,&#xA;    )&#xA;    // Stdin for sending data&#xA;    stdin, err := ffmpeg.StdinPipe()&#xA;    if err != nil {&#xA;        return err&#xA;    }&#xA;    //var buf bytes.Buffer&#xA;    defer stdin.Close()&#xA;    // Run it in the background&#xA;    errCh := make(chan error, 1)&#xA;&#xA;    go func() {&#xA;        fmt.Printf("Executing: %v\n", strings.Join(ffmpeg.Args, " "))&#xA;        &#xA;        if err := ffmpeg.Run(); err != nil {&#xA;            return&#xA;        }&#xA;        //fmt.Printf("FFMPEG output:\n%v\n", string(out))&#xA;        errCh &lt;- err&#xA;    }()&#xA;    // Just start sending a bunch of frames&#xA;    for {&#xA;        &#xA;        // Check if we&#x27;re done, otherwise go again&#xA;        select {&#xA;        case &lt;-ctx.Done():&#xA;            return ctx.Err()&#xA;        case err := &lt;-errCh:&#xA;            return err&#xA;        default:&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    Thanks for advance

    &#xA;

  • Does anyone use go-av to parse mp4 audio and then use oto/portaudio to output it ?

    27 juillet 2021, par seven

    it is use go-av to get audio

    &#xA;

    func audio() (&lt;-chan []byte, error) {&#xA;    buffer := make(chan []byte, 1024)&#xA;    go func() {&#xA;     ......&#xA;      for inCtx.AvReadFrame(pkt) >= 0 {&#xA;            if pkt.StreamIndex() == audioStreamIndex {&#xA;                l := pCodecCtx.AvcodecDecodeAudio4((*avcodec.Frame)(unsafe.Pointer(utilFrame)), &amp;gotName, pkt)&#xA;                //fmt.Println("AvcodecDecodeAudio4:", l)&#xA;                if l &lt; 0 {&#xA;                    fmt.Println("codec decode audio4 error")&#xA;                    os.Exit(1)&#xA;                }&#xA;                if gotName > 0 {&#xA;&#xA;                    fram := getFramBytes(utilFrame)&#xA;                    fmt.Println("buf add:", index)&#xA;                    buffer &lt;- fram&#xA;&#xA;                }&#xA;            }&#xA;            pkt.AvFreePacket()&#xA;        }&#xA;        go func() {&#xA;            for {&#xA;                if len(buffer) &lt;= 0 {&#xA;                    fmt.Println("close buf")&#xA;                    close(buffer)&#xA;                    break&#xA;                }&#xA;            }&#xA;        }()&#xA;&#xA;        (*avcodec.Context)(unsafe.Pointer(pCodecCtxOrig)).AvcodecClose()&#xA;    }()&#xA;    return buffer, nil&#xA;}&#xA;func getFramBytes(f *avutil.Frame) []byte {&#xA;    data := avutil.Data(f)&#xA;    var bf = make([]byte, len(data))&#xA;    for i := 0; i &lt; len(data); i&#x2B;&#x2B; {&#xA;&#xA;        if data[i] != nil {&#xA;            bf = append(bf, *data[i])&#xA;        }&#xA;    }&#xA;    return bf&#xA;}&#xA;&#xA;

    &#xA;

    and it is output it

    &#xA;

    func main() {&#xA;&#xA;    portaudio.Initialize()&#xA;    defer portaudio.Terminate()&#xA;    out := make([]int32, 8192)&#xA;    stream, err := portaudio.OpenDefaultStream(0, 1, 44100, len(out), &amp;out)&#xA;    defer stream.Close()&#xA;    if err != nil {&#xA;        fmt.Println(err)&#xA;        return&#xA;    }&#xA;    err = stream.Start()&#xA;    if err != nil {&#xA;        fmt.Println(err)&#xA;        return&#xA;    }&#xA;    defer stream.Stop()&#xA;    buf, err := audio()&#xA;    if err != nil {&#xA;        fmt.Println(err)&#xA;        return&#xA;    }&#xA;    //index := 0&#xA;    //c, err := oto.NewContext(44100, 2, 2, 8192)&#xA;    //if err != nil {&#xA;    //  return&#xA;    //}&#xA;    //defer c.Close()&#xA;    //&#xA;    //p := c.NewPlayer()&#xA;    //defer p.Close()&#xA;    for {&#xA;        select {&#xA;        case frame, ok := &lt;-buf:&#xA;            if !ok {&#xA;                os.Exit(0)&#xA;            }&#xA;            //index &#x2B;= 1&#xA;            //fmt.Println("$$:", index)&#xA;            //if _, err := io.Copy(p, bytes.NewReader(frame)); err != nil {&#xA;            //  fmt.Println(err)&#xA;            //  return&#xA;            //}&#xA;            err := binary.Read(bytes.NewReader(frame), binary.BigEndian, out)&#xA;            if err != nil {&#xA;                fmt.Println("binary.Read:", err)&#xA;                os.Exit(0)&#xA;            }&#xA;            err = stream.Write()&#xA;            if err != nil {&#xA;                fmt.Println("stream.Write:", err)&#xA;                os.Exit(0)&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;}&#xA;&#xA;

    &#xA;

    ** the result is**

    &#xA;

    binary.Read : unexpected EOF

    &#xA;

    if use oto it has no effect

    &#xA;

    Has anyone used this method, or is there any other way to use go-av to play audio and video ?

    &#xA;

    Is there a problem in use ? I feel that there is a problem with the data conversion from the audio decoding.

    &#xA;

    Maybe there is a problem with getFramBytes

    &#xA;