Advanced search

Medias (91)

Other articles (105)

  • Encoding and processing into web-friendly formats

    13 April 2011, by

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs

    12 April 2011, by

    La manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
    Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.

  • Gestion de la ferme

    2 March 2010, by

    La ferme est gérée dans son ensemble par des "super admins".
    Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
    Dans un premier temps il utilise le plugin "Gestion de mutualisation"

On other websites (13003)

  • Freeze when writing ffmpeg execution result to io.Pipe

    7 November 2023, by alex

    I am writing a wrapper to work with exec.Cmd to work with io.Pipe. The wrapper is intended to simplify work with the file system, I want to convert a video, write the result of the conversion to io.Pipe, read it in the goroutine and transfer it to make a preview of the new converted file. For this purpose I use FFmpeg. But I've encountered a problem, when I start the test the execution just hangs and I can't get any result, but there are no errors, everything just hangs.

    


    CmdRunner source code

    


    type CmdRunner struct {
    commander Commander
    StdIn io.ReadCloser
    StdoutWriter io.WriteCloser
    StdErrWriter io.Writer
}

func (c *CmdRunner) RunByPipe(ctx context.Context) error {
    //done := make(chan error)
    name, args := c.commander.Command()
    cmd := exec.CommandContext(ctx, name, args...)

    if c.StdIn != nil {
        fmt.Print("RunByPipe STDIN\n")
        cmd.Stdin = c.StdIn
    }

    if c.StdoutWriter != nil {
        fmt.Print("RunByPipe STDOUT\n")
        cmd.Stdout = c.StdoutWriter
    }

    stderr := bytes.Buffer{}
    cmd.Stderr = &stderr

    if err := cmd.Start(); err != nil {
        return err
    }

    if err := cmd.Wait(); err != nil {
        return err
    }

    if stderr.String() != "" {
        return fmt.Errorf("want empty stderr, but got %s", stderr.String())
    }

    return nil
}



    


    Unit test code

    


    type TestCommander struct {
    name string
    args []string
}

func (c *TestCommander) SetCommand(name string, args []string) {
    c.name = name
    c.args = args
}

func (c *TestCommander) Command() (string, []string) {
    return c.name, c.args
}

func TestConvert(t *testing.T) {
    ctx := context.Background()
    filePath := "testdata/input_mp4.mp4"
    data, err := convertFile(filePath, ctx)
    outFile := "testdata/output_mp4.mp4"
    if err != nil {
        fmt.Print("ERR: ", err, "\n")
    }

    os.WriteFile(outFile, data, 0644)

}

func convertFile(filePath string, ctx context.Context) (bytes []byte, err error) {
    // Create a CmdRunner instance with your custom Commander.
    runner := &CmdRunner{}
    commander := &TestCommander{}
    args := []string{
        "-nostats",
        "-i", filePath,
        "-y",
        "-loglevel", "0",
        "-filter:v", "fps=30, crop=trunc(iw/2)*2:trunc(ih/2)*2",
        "-c:v", "libx264",
        "-c:a", "aac",
        "-pix_fmt", "yuv420p",
        "-movflags", "frag_keyframe+faststart",
        "-bufsize", "24M",
        "-maxrate", "12M",
        "-f", "mp4",
        "pipe:1",
    }

    commander.SetCommand("ffmpeg", args)
    runner.SetCommander(commander)
    outputPipeReader, outputPipeWriter := io.Pipe()
    runner.SetStdOutWriter(outputPipeWriter)

    wg := &sync.WaitGroup{}
    wg.Add(1)
    go func() {
        defer outputPipeReader.Close()
        defer wg.Done()

        // Read data from output pipe
        bytes, err = io.ReadAll(outputPipeReader)
        if err != nil {
            fmt.Print("\nReadAll err: ", err, "\n")
        }
    }()

    err = runner.RunByPipe(ctx)
    if err != nil {
        fmt.Print("\nRunByPipe err: ", err, "\n")
        return
    }

    wg.Wait()

    return
}


    


    I can't find a clue as to what might have gone wrong.
P.S: But if I remove if err := cmd.Wait(); err != nil { return err } Then the problem goes away, but there will be no data, because nothing is written to io.Pipe.Why?

    


  • avutil/opt: Don't cast when the result might be misaligned

    25 March 2024, by Andreas Rheinhardt
    avutil/opt: Don't cast when the result might be misaligned
    

    A pointer conversion is UB if the resulting pointer is not
    correctly aligned for the resultant type, even if no
    load/store is ever performed through that pointer (C11 6.3.2.3 (7)).

    This may happen in opt_copy_elem(), because the pointers are
    converted even when they belong to a type that does not guarantee
    sufficient alignment.

    Fix this by deferring the cast after having checked the type.
    Also make the casts -Wcast-qual safe and avoid an indirection
    for src.

    Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>

    • [DH] libavutil/opt.c
  • FFmpeg: canvas and crop work separately but result in black screen when combined

    25 January, by didi00

    I'm working on a video processing pipeline with FFmpeg, where I:

    &#xA;

      &#xA;
    • Create a black canvas using the color filter.
    • &#xA;

    • Crop a region from my video input.
    • &#xA;

    • Overlay the cropped region onto the black canvas.
    • &#xA;

    &#xA;

    Both the canvas and the crop display correctly when tested individually. However, when I attempt to combine them (overlay the crop onto the canvas), the result is a black screen.&#xA;What Works:

    &#xA;

    Black Canvas Alone:

    &#xA;

    ffmpeg -filter_complex "color=c=black:s=1920x1080[out]" -map "[out]" -f nut - | ffplay &#xA;-&#xA;

    &#xA;

    This shows a plain black screen, as expected.

    &#xA;

    Cropped Region Alone:

    &#xA;

    ffmpeg -f v4l2 -input_format yuyv422 -framerate 60 -video_size 1920x1080 -i /dev/video0 &#xA;\ -vf "crop=1024:192:0:0" -f nut - | ffplay -&#xA;

    &#xA;

    This shows the cropped region of the video correctly.

    &#xA;

    When I combine these steps to overlay the crop onto the black canvas, I get a black screen:

    &#xA;

    ffmpeg -f v4l2 -input_format yuyv422 -framerate 60 -video_size 1920x1080 -i /dev/video0 &#xA;\-filter_complex "color=c=black:s=1920x1080,format=yuv420p[background]; \&#xA;[0:v]crop=1024:192:0:0,format=yuv420p[region0]; \&#xA;[background][region0]overlay=x=0:y=0[out]" \&#xA;-map "[out]" -f nut - | ffplay -&#xA;

    &#xA;

    Environment:

    &#xA;

      &#xA;
    • OS: Linux (Debian-based)
    • &#xA;

    • FFmpeg Version: [Insert version, e.g., 4.x or 5.x]
    • &#xA;

    • Capture Card Format: yuyv422
    • &#xA;

    &#xA;

    Question:

    &#xA;

    Why does the pipeline result in a black screen when combining the canvas and the crop, even though both work separately? Is this an issue with pixel format compatibility, or is there something I'm overlooking in the overlay filter setup?

    &#xA;