Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (50)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • 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

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (4826)

  • video not playing on iOS safari

    21 octobre 2020, par Dean Van Greunen

    This video plays perfectly on Chrome Desktop and Android Chrome, on the latest releases.

    


    However it won't work on an iPad and an iPhone.

    


    Video Link

    


    also here is the file info.

    


    enter image description here

    


  • x264 encoding severe quality loss

    1er septembre 2020, par SolskGaer

    I used this repo to encode a mjpeg stream to a h264 one, but the output is not so good. The stream is a series of screenshot of an iPhone. In the output stream, even the lines between two items in the settings app are gone. How do I improve the output stream quality ?
Here is the code snippet that x264-go use to init an encoder

    


    func NewEncoder(w io.Writer, opts *Options) (e *Encoder, err error) {
    e = &Encoder{}

    e.w = w
    e.pts = 0
    e.opts = opts

    e.csp = x264c.CspI420

    e.nals = make([]*x264c.Nal, 3)
    e.img = NewYCbCr(image.Rect(0, 0, e.opts.Width, e.opts.Height))

    param := x264c.Param{}

    if e.opts.Preset != "" && e.opts.Profile != "" {
        ret := x264c.ParamDefaultPreset(&param, e.opts.Preset, e.opts.Tune)
        if ret < 0 {
            err = fmt.Errorf("x264: invalid preset/tune name")
            return
        }
    } else {
        x264c.ParamDefault(&param)
    }

    param.IWidth = int32(e.opts.Width)
    param.IHeight = int32(e.opts.Height)

    param.ICsp = e.csp
    param.BVfrInput = 0
    param.BRepeatHeaders = 1
    param.BAnnexb = 1

    param.ILogLevel = e.opts.LogLevel

    if e.opts.FrameRate > 0 {
        param.IFpsNum = uint32(e.opts.FrameRate)
        param.IFpsDen = 1

        param.IKeyintMax = int32(e.opts.FrameRate)
        param.BIntraRefresh = 1
    }

    if e.opts.Profile != "" {
        ret := x264c.ParamApplyProfile(&param, e.opts.Profile)
        if ret < 0 {
            err = fmt.Errorf("x264: invalid profile name")
            return
        }
    }

    // Allocate on create instead while encoding
    var picIn x264c.Picture
    ret := x264c.PictureAlloc(&picIn, e.csp, int32(e.opts.Width), int32(e.opts.Height))
    if ret < 0 {
        err = fmt.Errorf("x264: cannot allocate picture")
        return
    }
    e.picIn = picIn
    defer func() {
        // Cleanup if intialization fail
        if err != nil {
            x264c.PictureClean(&picIn)
        }
    }()

    e.e = x264c.EncoderOpen(&param)
    if e.e == nil {
        err = fmt.Errorf("x264: cannot open the encoder")
        return
    }

    ret = x264c.EncoderHeaders(e.e, e.nals, &e.nnals)
    if ret < 0 {
        err = fmt.Errorf("x264: cannot encode headers")
        return
    }

    if ret > 0 {
        b := C.GoBytes(e.nals[0].PPayload, C.int(ret))
        n, er := e.w.Write(b)
        if er != nil {
            err = er
            return
        }

        if int(ret) != n {
            err = fmt.Errorf("x264: error writing headers, size=%d, n=%d", ret, n)
        }
    }

    return
}


    


    and the encoder option is defined as

    


    opts := &x264.Options{
        Width:     int(width)/2*2,
        Height:    int(height)/2*2,
        FrameRate: 15,
        Tune:      "zerolatency",
        Preset:    "medium",
        Profile:   "baseline",
        LogLevel:  x264.LogNone,
    }


    


    And I also used ffmpeg(though the api is pretty old)

    


    package screencast&#xA;&#xA;import (&#xA;&#xA;    /*&#xA;        #include &#xA;        #include &#xA;        #include &#xA;        #include &#xA;        #include <libavcodec></libavcodec>avcodec.h>&#xA;        #include <libavformat></libavformat>avformat.h>&#xA;        #include <libavutil></libavutil>avutil.h>&#xA;        #include <libavutil></libavutil>opt.h>&#xA;        #include <libavutil></libavutil>channel_layout.h>&#xA;        #include <libavutil></libavutil>common.h>&#xA;        #include <libavutil></libavutil>imgutils.h>&#xA;        #include <libavutil></libavutil>mathematics.h>&#xA;        #include <libavutil></libavutil>samplefmt.h>&#xA;&#xA;        typedef struct {&#xA;            int w, h;&#xA;            int pixfmt;&#xA;            char *preset[2];&#xA;            char *profile;&#xA;            int bitrate;&#xA;            int got;&#xA;            AVCodec *c;&#xA;            AVCodecContext *ctx;&#xA;            AVFrame *f;&#xA;            AVPacket pkt;&#xA;        } h264enc_t;&#xA;&#xA;        static int h264enc_new(h264enc_t *m) {&#xA;            m->c = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;            m->ctx = avcodec_alloc_context3(m->c);&#xA;            m->ctx->width = m->w;&#xA;            m->ctx->height = m->h;&#xA;            m->ctx->pix_fmt = m->pixfmt;&#xA;            m->ctx->time_base = (AVRational){1,10};&#xA;            av_opt_set(m->ctx->priv_data, "preset", "slow", 0);&#xA;            av_opt_set(m->ctx->priv_data, "tune", "zerolatency", 0);&#xA;            av_opt_set(m->ctx->priv_data, "profile", "baseline", 0);&#xA;            av_opt_set(m->ctx->priv_data, "crf", "18.0.", 0);&#xA;            m->f = av_frame_alloc();&#xA;            m->f->format = m->ctx->pix_fmt;&#xA;            m->f->width = m->ctx->width;&#xA;            m->f->height = m->ctx->height;&#xA;            avcodec_open2(m->ctx, m->c, NULL);&#xA;            return av_image_alloc(m->f->data, m->f->linesize, m->ctx->width, m->ctx->height, m->ctx->pix_fmt, 32);&#xA;        }&#xA;&#xA;    */&#xA;    "C"&#xA;    "errors"&#xA;    "image"&#xA;    "unsafe"&#xA;    //"log"&#xA;)&#xA;&#xA;type H264Encoder struct {&#xA;    m      C.h264enc_t&#xA;    Header []byte&#xA;    Pixfmt image.YCbCrSubsampleRatio&#xA;    W, H   int&#xA;    pts    int&#xA;}&#xA;&#xA;func NewH264Encoder(w, h int) (m *H264Encoder, err error) {&#xA;    m = &amp;H264Encoder{}&#xA;    m.m.w = (C.int)(w)&#xA;    m.m.h = (C.int)(h)&#xA;    m.W = w&#xA;    m.H = h&#xA;    m.Pixfmt = image.YCbCrSubsampleRatio420&#xA;    m.m.pixfmt = C.AV_PIX_FMT_YUV420P&#xA;    r := C.h264enc_new(&amp;m.m)&#xA;    if int(r) &lt; 0 {&#xA;        err = errors.New("open encoder failed")&#xA;        return&#xA;    }&#xA;    return&#xA;}&#xA;&#xA;func (m *H264Encoder) Encode(img *image.YCbCr) (data []byte, err error) {&#xA;    var f *C.AVFrame&#xA;    if img == nil {&#xA;        f = nil&#xA;    } else {&#xA;        if img.SubsampleRatio != m.Pixfmt {&#xA;            err = errors.New("image pixfmt not match")&#xA;            return&#xA;        }&#xA;        if img.Rect.Dx() != m.W || img.Rect.Dy() != m.H {&#xA;            err = errors.New("image size not match")&#xA;            return&#xA;        }&#xA;        f = m.m.f&#xA;        f.data[0] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Y[0]))&#xA;        f.data[1] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Cb[0]))&#xA;        f.data[2] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Cr[0]))&#xA;        f.linesize[0] = (C.int)(img.YStride)&#xA;        f.linesize[1] = (C.int)(img.CStride)&#xA;        f.linesize[2] = (C.int)(img.CStride)&#xA;    }&#xA;&#xA;    C.av_init_packet(&amp;m.m.pkt)&#xA;    m.m.pkt.data = nil&#xA;    m.m.pkt.size = 0&#xA;    f.pts = (C.longlong)(m.pts)&#xA;    m.pts&#x2B;&#x2B;&#xA;    r := C.avcodec_encode_video2(m.m.ctx, &amp;m.m.pkt, f, &amp;m.m.got)&#xA;    defer C.av_packet_unref(&amp;m.m.pkt)&#xA;    if int(r) &lt; 0 {&#xA;        err = errors.New("encode failed")&#xA;        return&#xA;    }&#xA;    if m.m.got == 0 {&#xA;        err = errors.New("no picture")&#xA;        return&#xA;    }&#xA;    if m.m.pkt.size == 0 {&#xA;        err = errors.New("packet size == 0")&#xA;        return&#xA;    }&#xA;&#xA;    data = make([]byte, m.m.pkt.size)&#xA;    C.memcpy(&#xA;        unsafe.Pointer(&amp;data[0]),&#xA;        unsafe.Pointer(m.m.pkt.data),&#xA;        (C.size_t)(m.m.pkt.size),&#xA;    )&#xA;    return data, nil&#xA;}&#xA;

    &#xA;

    but got the same output. However, when I use the ffmpeg binary, the result was pretty good, so I guess I set wrong parameters, but I don't know which.&#xA;Any suggestion would be appreciated. If you have better way to achieve this, I'll appreciate it.

    &#xA;

    For your information : I must do this using golang.

    &#xA;

    screenshot of output stream

    &#xA;

  • x264 encoding severe quality loss

    1er septembre 2020, par SolskGaer

    I used this repo to encode a mjpeg stream to a h264 one, but the output is not so good. The stream is a series of screenshot of an iPhone. In the output stream, even the lines between two items in the settings app are gone. How do I improve the output stream quality ?&#xA;Here is the code snippet that x264-go use to init an encoder

    &#xA;

    func NewEncoder(w io.Writer, opts *Options) (e *Encoder, err error) {&#xA;    e = &amp;Encoder{}&#xA;&#xA;    e.w = w&#xA;    e.pts = 0&#xA;    e.opts = opts&#xA;&#xA;    e.csp = x264c.CspI420&#xA;&#xA;    e.nals = make([]*x264c.Nal, 3)&#xA;    e.img = NewYCbCr(image.Rect(0, 0, e.opts.Width, e.opts.Height))&#xA;&#xA;    param := x264c.Param{}&#xA;&#xA;    if e.opts.Preset != "" &amp;&amp; e.opts.Profile != "" {&#xA;        ret := x264c.ParamDefaultPreset(&amp;param, e.opts.Preset, e.opts.Tune)&#xA;        if ret &lt; 0 {&#xA;            err = fmt.Errorf("x264: invalid preset/tune name")&#xA;            return&#xA;        }&#xA;    } else {&#xA;        x264c.ParamDefault(&amp;param)&#xA;    }&#xA;&#xA;    param.IWidth = int32(e.opts.Width)&#xA;    param.IHeight = int32(e.opts.Height)&#xA;&#xA;    param.ICsp = e.csp&#xA;    param.BVfrInput = 0&#xA;    param.BRepeatHeaders = 1&#xA;    param.BAnnexb = 1&#xA;&#xA;    param.ILogLevel = e.opts.LogLevel&#xA;&#xA;    if e.opts.FrameRate > 0 {&#xA;        param.IFpsNum = uint32(e.opts.FrameRate)&#xA;        param.IFpsDen = 1&#xA;&#xA;        param.IKeyintMax = int32(e.opts.FrameRate)&#xA;        param.BIntraRefresh = 1&#xA;    }&#xA;&#xA;    if e.opts.Profile != "" {&#xA;        ret := x264c.ParamApplyProfile(&amp;param, e.opts.Profile)&#xA;        if ret &lt; 0 {&#xA;            err = fmt.Errorf("x264: invalid profile name")&#xA;            return&#xA;        }&#xA;    }&#xA;&#xA;    // Allocate on create instead while encoding&#xA;    var picIn x264c.Picture&#xA;    ret := x264c.PictureAlloc(&amp;picIn, e.csp, int32(e.opts.Width), int32(e.opts.Height))&#xA;    if ret &lt; 0 {&#xA;        err = fmt.Errorf("x264: cannot allocate picture")&#xA;        return&#xA;    }&#xA;    e.picIn = picIn&#xA;    defer func() {&#xA;        // Cleanup if intialization fail&#xA;        if err != nil {&#xA;            x264c.PictureClean(&amp;picIn)&#xA;        }&#xA;    }()&#xA;&#xA;    e.e = x264c.EncoderOpen(&amp;param)&#xA;    if e.e == nil {&#xA;        err = fmt.Errorf("x264: cannot open the encoder")&#xA;        return&#xA;    }&#xA;&#xA;    ret = x264c.EncoderHeaders(e.e, e.nals, &amp;e.nnals)&#xA;    if ret &lt; 0 {&#xA;        err = fmt.Errorf("x264: cannot encode headers")&#xA;        return&#xA;    }&#xA;&#xA;    if ret > 0 {&#xA;        b := C.GoBytes(e.nals[0].PPayload, C.int(ret))&#xA;        n, er := e.w.Write(b)&#xA;        if er != nil {&#xA;            err = er&#xA;            return&#xA;        }&#xA;&#xA;        if int(ret) != n {&#xA;            err = fmt.Errorf("x264: error writing headers, size=%d, n=%d", ret, n)&#xA;        }&#xA;    }&#xA;&#xA;    return&#xA;}&#xA;

    &#xA;

    and the encoder option is defined as

    &#xA;

    opts := &amp;x264.Options{&#xA;        Width:     int(width)/2*2,&#xA;        Height:    int(height)/2*2,&#xA;        FrameRate: 15,&#xA;        Tune:      "zerolatency",&#xA;        Preset:    "medium",&#xA;        Profile:   "baseline",&#xA;        LogLevel:  x264.LogNone,&#xA;    }&#xA;

    &#xA;

    And I also used ffmpeg(though the api is pretty old)

    &#xA;

    package screencast&#xA;&#xA;import (&#xA;&#xA;    /*&#xA;        #include &#xA;        #include &#xA;        #include &#xA;        #include &#xA;        #include <libavcodec></libavcodec>avcodec.h>&#xA;        #include <libavformat></libavformat>avformat.h>&#xA;        #include <libavutil></libavutil>avutil.h>&#xA;        #include <libavutil></libavutil>opt.h>&#xA;        #include <libavutil></libavutil>channel_layout.h>&#xA;        #include <libavutil></libavutil>common.h>&#xA;        #include <libavutil></libavutil>imgutils.h>&#xA;        #include <libavutil></libavutil>mathematics.h>&#xA;        #include <libavutil></libavutil>samplefmt.h>&#xA;&#xA;        typedef struct {&#xA;            int w, h;&#xA;            int pixfmt;&#xA;            char *preset[2];&#xA;            char *profile;&#xA;            int bitrate;&#xA;            int got;&#xA;            AVCodec *c;&#xA;            AVCodecContext *ctx;&#xA;            AVFrame *f;&#xA;            AVPacket pkt;&#xA;        } h264enc_t;&#xA;&#xA;        static int h264enc_new(h264enc_t *m) {&#xA;            m->c = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;            m->ctx = avcodec_alloc_context3(m->c);&#xA;            m->ctx->width = m->w;&#xA;            m->ctx->height = m->h;&#xA;            m->ctx->pix_fmt = m->pixfmt;&#xA;            m->ctx->time_base = (AVRational){1,10};&#xA;            av_opt_set(m->ctx->priv_data, "preset", "slow", 0);&#xA;            av_opt_set(m->ctx->priv_data, "tune", "zerolatency", 0);&#xA;            av_opt_set(m->ctx->priv_data, "profile", "baseline", 0);&#xA;            av_opt_set(m->ctx->priv_data, "crf", "18.0.", 0);&#xA;            m->f = av_frame_alloc();&#xA;            m->f->format = m->ctx->pix_fmt;&#xA;            m->f->width = m->ctx->width;&#xA;            m->f->height = m->ctx->height;&#xA;            avcodec_open2(m->ctx, m->c, NULL);&#xA;            return av_image_alloc(m->f->data, m->f->linesize, m->ctx->width, m->ctx->height, m->ctx->pix_fmt, 32);&#xA;        }&#xA;&#xA;    */&#xA;    "C"&#xA;    "errors"&#xA;    "image"&#xA;    "unsafe"&#xA;    //"log"&#xA;)&#xA;&#xA;type H264Encoder struct {&#xA;    m      C.h264enc_t&#xA;    Header []byte&#xA;    Pixfmt image.YCbCrSubsampleRatio&#xA;    W, H   int&#xA;    pts    int&#xA;}&#xA;&#xA;func NewH264Encoder(w, h int) (m *H264Encoder, err error) {&#xA;    m = &amp;H264Encoder{}&#xA;    m.m.w = (C.int)(w)&#xA;    m.m.h = (C.int)(h)&#xA;    m.W = w&#xA;    m.H = h&#xA;    m.Pixfmt = image.YCbCrSubsampleRatio420&#xA;    m.m.pixfmt = C.AV_PIX_FMT_YUV420P&#xA;    r := C.h264enc_new(&amp;m.m)&#xA;    if int(r) &lt; 0 {&#xA;        err = errors.New("open encoder failed")&#xA;        return&#xA;    }&#xA;    return&#xA;}&#xA;&#xA;func (m *H264Encoder) Encode(img *image.YCbCr) (data []byte, err error) {&#xA;    var f *C.AVFrame&#xA;    if img == nil {&#xA;        f = nil&#xA;    } else {&#xA;        if img.SubsampleRatio != m.Pixfmt {&#xA;            err = errors.New("image pixfmt not match")&#xA;            return&#xA;        }&#xA;        if img.Rect.Dx() != m.W || img.Rect.Dy() != m.H {&#xA;            err = errors.New("image size not match")&#xA;            return&#xA;        }&#xA;        f = m.m.f&#xA;        f.data[0] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Y[0]))&#xA;        f.data[1] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Cb[0]))&#xA;        f.data[2] = (*C.uint8_t)(unsafe.Pointer(&amp;img.Cr[0]))&#xA;        f.linesize[0] = (C.int)(img.YStride)&#xA;        f.linesize[1] = (C.int)(img.CStride)&#xA;        f.linesize[2] = (C.int)(img.CStride)&#xA;    }&#xA;&#xA;    C.av_init_packet(&amp;m.m.pkt)&#xA;    m.m.pkt.data = nil&#xA;    m.m.pkt.size = 0&#xA;    f.pts = (C.longlong)(m.pts)&#xA;    m.pts&#x2B;&#x2B;&#xA;    r := C.avcodec_encode_video2(m.m.ctx, &amp;m.m.pkt, f, &amp;m.m.got)&#xA;    defer C.av_packet_unref(&amp;m.m.pkt)&#xA;    if int(r) &lt; 0 {&#xA;        err = errors.New("encode failed")&#xA;        return&#xA;    }&#xA;    if m.m.got == 0 {&#xA;        err = errors.New("no picture")&#xA;        return&#xA;    }&#xA;    if m.m.pkt.size == 0 {&#xA;        err = errors.New("packet size == 0")&#xA;        return&#xA;    }&#xA;&#xA;    data = make([]byte, m.m.pkt.size)&#xA;    C.memcpy(&#xA;        unsafe.Pointer(&amp;data[0]),&#xA;        unsafe.Pointer(m.m.pkt.data),&#xA;        (C.size_t)(m.m.pkt.size),&#xA;    )&#xA;    return data, nil&#xA;}&#xA;

    &#xA;

    but got the same output. However, when I use the ffmpeg binary, the result was pretty good, so I guess I set wrong parameters, but I don't know which.&#xA;Any suggestion would be appreciated. If you have better way to achieve this, I'll appreciate it.

    &#xA;

    For your information : I must do this using golang.

    &#xA;

    screenshot of output stream

    &#xA;