Recherche avancée

Médias (0)

Mot : - Tags -/médias

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

Autres articles (77)

  • Support de tous types de médias

    10 avril 2011

    Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)

  • MediaSPIP v0.2

    21 juin 2013, par

    MediaSPIP 0.2 est la première version de MediaSPIP stable.
    Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

Sur d’autres sites (6007)

  • PyAV : force new framerate while remuxing stream ?

    7 juin 2019, par ToxicFrog

    I have a Python program that receives a sequence of H264 video frames over the network, which I want to display and, optionally, record. The camera records at 30FPS and sends frames as fast as it can, which isn’t consistently 30FPS due to changing network conditions ; sometimes it falls behind and then catches up, and rarely it drops frames entirely.

    The "display" part is easy ; I don’t need to care about timing or stream metadata, just display the frames as fast as they arrive :

    input = av.open(get_video_stream())
    for packet in input.demux(video=0):
     for frame in packet.decode():
       # A bunch of numpy and pygame code here to convert the frame to RGB
       # row-major and blit it to the screen

    The "record" part looks like it should be easy :

    input = av.open(get_video_stream())
    output = av.open(filename, 'w')
    output.add_stream(template=input.streams[0])
    for packet in input.demux(video=0):
     for frame in packet.decode():
       # ...display code...
     packet.stream = output.streams[0]
     output.mux_one(packet)
    output.close()

    And indeed this produces a valid MP4 file containing all the frames, and if I play it back with mplayer -fps 30 it works fine. But that -fps 30 is absolutely required :

    $ ffprobe output.mp4
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 960x720,
                     1277664 kb/s, 12800 fps, 12800 tbr, 12800 tbn, 25600 tbc (default)

    Note that 12,800 frames/second. It should look something like this (produced by calling mencoder -fps 30 and piping the frames into it) :

    $ ffprobe mencoder_test.mp4
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 960x720,
                     2998 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)

    Inspecting the packets and frames I get from the input stream, I see :

    stream: time_base=1/1200000
    codec: framerate=25 time_base=1/50
    packet: dts=None pts=None duration=48000 time_base=1/1200000
    frame: dst=None pts=None time=None time_base=1/1200000

    So, the packets and frames don’t have timestamps at all ; they have a time_base which doesn’t match either the timebase that ends up in the final file or the actual framerate of the camera ; the codec has a framrate and timebase that doesn’t match the final file, the camera framerate, or the other video stream metadata !

    The PyAV documentation is all but entirely absent when it comes to issues of timing and framerate, but I have tried manually setting various combinations of stream, packet, and frame time_base, dts, and pts with no success. I can always remux the recorded videos again to get the correct framerate, but I’d rather write video files that are correct in the first place.

    So, how do I get pyAV to remux the video in a way that produces an output that is correctly marked as 30fps ?

  • Android opengl es YUV to RGB conversion using shaders

    1er février 2014, par DSG

    I am working on a video player for android device, in which I am using ffmpeg for decoding and opengl es for rendering. I am stuck at one point where I am using opengl es shaders for YUV to RGB conversion. Application is able to display image but its not displaying correct colors. After conervting from YUV to RGB, image only displays green and pink colors. I did searched on google, but no solution found. Can any one please help me on this topic ?

    I am getting three different buffers (y, u, v) from ffmpeg and then I am passing these buffers to 3 textures as it is.

    Here are shaders I am using.

    static const char kVertexShader[] =
    "attribute vec4 vPosition;      \n"
     "attribute vec2 vTexCoord;        \n"
     "varying vec2 v_vTexCoord;        \n"
    "void main() {                        \n"
       "gl_Position = vPosition;       \n"
       "v_vTexCoord = vTexCoord;       \n"
    "}                                          \n";

    static const char kFragmentShader[] =
       "precision mediump float;               \n"
       "varying vec2 v_vTexCoord;          \n"
       "uniform sampler2D yTexture;        \n"
       "uniform sampler2D uTexture;        \n"
       "uniform sampler2D vTexture;        \n"
       "void main() {                      \n"
           "float y=texture2D(yTexture, v_vTexCoord).r;\n"
           "float u=texture2D(uTexture, v_vTexCoord).r - 0.5;\n"
           "float v=texture2D(vTexture, v_vTexCoord).r - 0.5;\n"
           "float r=y + 1.13983 * v;\n"
           "float g=y - 0.39465 * u - 0.58060 * v;\n"
           "float b=y + 2.03211 * u;\n"
           "gl_FragColor = vec4(r, g, b, 1.0);\n"
       "}\n";

       static const GLfloat kVertexInformation[] =
       {
            -1.0f, 1.0f,           // TexCoord 0 top left
            -1.0f,-1.0f,           // TexCoord 1 bottom left
             1.0f,-1.0f,           // TexCoord 2 bottom right
             1.0f, 1.0f            // TexCoord 3 top right
       };
       static const GLshort kTextureCoordinateInformation[] =
       {
            0, 0,         // TexCoord 0 top left
            0, 1,         // TexCoord 1 bottom left
            1, 1,         // TexCoord 2 bottom right
            1, 0          // TexCoord 3 top right
       };
       static const GLuint kStride = 0;//COORDS_PER_VERTEX * 4;
       static const GLshort kIndicesInformation[] =
       {
            0, 1, 2,
            0, 2, 3
       };

    Here is another person who had asked same question : Camera frame yuv to rgb conversion using GL shader language

    Thank You.

    UPDATE :

    ClayMontgomery's shaders.

    const char* VERTEX_SHADER = "\
    attribute vec4 a_position;\
    attribute vec2 a_texCoord;\
    varying   vec2 gsvTexCoord;\
    varying   vec2 gsvTexCoordLuma;\
    varying   vec2 gsvTexCoordChroma;\
    \
    void main()\
    {\
       gl_Position = a_position;\
       gsvTexCoord = a_texCoord;\
       gsvTexCoordLuma.s = a_texCoord.s / 2.0;\
       gsvTexCoordLuma.t = a_texCoord.t / 2.0;\
       gsvTexCoordChroma.s = a_texCoord.s / 4.0;\
       gsvTexCoordChroma.t = a_texCoord.t / 4.0;\
    }";


    const char* YUV_FRAGMENT_SHADER = "\
    precision highp float;\
    uniform sampler2D y_texture;\
    uniform sampler2D u_texture;\
    uniform sampler2D v_texture;\
    varying   vec2 gsvTexCoord;\
    varying vec2 gsvTexCoordLuma;\
    varying vec2 gsvTexCoordChroma;\
    \
    void main()\
    {\
       float y = texture2D(y_texture, gsvTexCoordLuma).r;\
       float u = texture2D(u_texture, gsvTexCoordChroma).r;\
       float v = texture2D(v_texture, gsvTexCoordChroma).r;\
       u = u - 0.5;\
       v = v - 0.5;\
       vec3 rgb;\
       rgb.r = y + (1.403 * v);\
       rgb.g = y - (0.344 * u) - (0.714 * v);\
       rgb.b = y + (1.770 * u);\
       gl_FragColor = vec4(rgb, 1.0);\
    }";

    Here is output :

    enter image description here

  • what is wrong about the I420 render from ffmpeg ?

    9 mai 2022, par DLKUN

    I use glfw render YUV from ffmpeg ;the Y is ok(only use data Y ,and frag texture2D Y is ok ,the color is Grayscale).but when I add U,V ;the display show pink and green ; I try to change frag shader or the imgtexture ,there have no use .

    


    #include <glad></glad>glad.h>&#xA;#include <glfw></glfw>glfw3.h>&#xA;&#xA;#include<string>&#xA;#include<fstream>&#xA;#include<sstream>&#xA;#include<iostream>&#xA;#include&#xA;&#xA;#include &#xA;&#xA;// settings&#xA;const unsigned int SCR_WIDTH = 544;&#xA;const unsigned int SCR_HEIGHT = 960;&#xA;const int len = 544 * 960 * 3/2;&#xA;BYTE YUVdata [len];//&#xA;BYTE Ydata [544 * 960];//&#xA;BYTE Udata [272 * 480];//&#xA;BYTE Vdata [272 * 480];//&#xA;unsigned int VBO = 0;&#xA;unsigned int VAO = 0;&#xA;unsigned int EBO = 0;&#xA;unsigned int texturePIC = 0;&#xA;int shaderProgram = 0;&#xA;&#xA;GLuint texIndexarray[3];&#xA;GLuint texUniformY = 99;&#xA;GLuint texUniformU = 99;&#xA;GLuint texUniformV = 99;&#xA;&#xA;void LoadPicture()&#xA;{&#xA;&#xA;&#xA;    glGenTextures(3, texIndexarray);&#xA;&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[0]);&#xA;    &#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);&#xA;&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[1]);&#xA;    &#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[2]);&#xA;    &#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);&#xA;    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);&#xA;&#xA;&#xA;    glValidateProgram(shaderProgram);&#xA;&#xA;    texUniformY = glGetUniformLocation(shaderProgram, "dataY");//2&#xA;    texUniformU = glGetUniformLocation(shaderProgram, "dataU");//0&#xA;    texUniformV = glGetUniformLocation(shaderProgram, "dataV");//1&#xA;&#xA;    &#xA;    FILE* fp = fopen("./output544_960.yuv","rb&#x2B;");//I420&#xA;    int returns  =fread(YUVdata,1,len,fp);&#xA;    int w = 544;&#xA;    int h = 960;&#xA;    int ysize = w*h;&#xA;    int uvsize = w * h / 4;&#xA;&#xA;    void* uptr = &amp;YUVdata[ysize];&#xA;    void* vptr = &amp;YUVdata[ysize * 5 / 4];&#xA;&#xA;    memcpy(Ydata,YUVdata,ysize);&#xA;    memcpy(Udata, uptr,uvsize);&#xA;    memcpy(Vdata, vptr,uvsize);&#xA;    glActiveTexture(GL_TEXTURE0);&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[0]);&#xA;    &#xA;    glTexImage2D(GL_TEXTURE_2D, 0 , GL_RED, w, h ,0, GL_RED,GL_UNSIGNED_BYTE ,Ydata);&#xA;    glUniform1i(texUniformY, texIndexarray[0]);               &#xA;&#xA;&#xA;    glActiveTexture(GL_TEXTURE1);&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[1]);&#xA;    glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w/2, h/2, 0, GL_RED, GL_UNSIGNED_BYTE,Udata );&#xA;&#xA;    glUniform1i(texUniformU, texIndexarray[1]);&#xA;&#xA;&#xA;    glActiveTexture(GL_TEXTURE2);&#xA;    glBindTexture(GL_TEXTURE_2D, texIndexarray[2]);&#xA;    glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w/2, h/2, 0, GL_RED, GL_UNSIGNED_BYTE,Vdata);&#xA;    glUniform1i(texUniformV, texIndexarray[2]);&#xA;&#xA;}&#xA;&#xA;&#xA;void render()&#xA;{&#xA;    glBindVertexArray(VAO);&#xA;    glUseProgram(shaderProgram);&#xA;    glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_INT,0);&#xA;    //glDrawArrays(GL_TRIANGLE_FAN,0,4);&#xA;    glUseProgram(0);&#xA;    glBindVertexArray(0);&#xA;}&#xA;&#xA;void initmodule()&#xA;{&#xA;    &#xA;    float vertexs[] = {&#xA;        &#xA;        1.0f,  1.0f, 0.0f,  1.0f, 0.0f,   &#xA;        1.0f, -1.0f, 0.0f,  1.0f, 1.0f,   &#xA;        -1.0f, -1.0f, 0.0f,  0.0f, 1.0f,   &#xA;        -1.0f,  1.0f, 0.0f,  0.0f, 0.0f    &#xA;    &#xA;    &#xA;    };&#xA;    &#xA;    unsigned int indexs[] = {&#xA;        0,1,3,&#xA;        1,2,3,&#xA;    };&#xA;&#xA;    &#xA;    glGenVertexArrays(1,&amp;VAO);&#xA;    glBindVertexArray(VAO);&#xA;&#xA;    &#xA;&#xA;    glGenBuffers(1, &amp;VBO);&#xA;    glBindBuffer(GL_ARRAY_BUFFER, VBO);&#xA;    &#xA;    glBufferData(GL_ARRAY_BUFFER,sizeof(vertexs), vertexs, GL_STATIC_DRAW);&#xA;&#xA;    &#xA;    glGenBuffers(1,&amp;EBO);&#xA;    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,EBO);&#xA;    glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(indexs),indexs,GL_STATIC_DRAW);&#xA;    &#xA;    LoadPicture();&#xA;&#xA;    glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,5*sizeof(float),(void*)0);&#xA;    &#xA;    glEnableVertexAttribArray(0);&#xA;    &#xA;    glVertexAttribPointer(1,2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));&#xA;    &#xA;    glEnableVertexAttribArray(1);&#xA;&#xA;    &#xA;    glBindBuffer(GL_ARRAY_BUFFER,0);&#xA;&#xA;    &#xA;    glBindVertexArray(0);&#xA;&#xA;&#xA;&#xA;}&#xA;&#xA;void initshader(const char* verpath,const char* fragpath)&#xA;{&#xA;    &#xA;    std::string VerCode("");&#xA;    std::string fregCode("");&#xA;    &#xA;    std::ifstream  vShaderFile;&#xA;    std::ifstream  fShaderFile;&#xA;&#xA;    vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);&#xA;    fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);&#xA;&#xA;    try&#xA;    {&#xA;        vShaderFile.open(verpath);&#xA;        fShaderFile.open(fragpath);&#xA;&#xA;        std::stringstream vsstream, fsstream;&#xA;        vsstream &lt;&lt; vShaderFile.rdbuf();&#xA;        fsstream &lt;&lt; fShaderFile.rdbuf();&#xA;        VerCode = vsstream.str();&#xA;        fregCode = fsstream.str();&#xA;    &#xA;    }&#xA;    catch (const std::exception&amp;)&#xA;    {&#xA;        std::cout &lt;&lt; "read file error" &lt;&lt; std::endl;&#xA;    }&#xA;&#xA;    const char* vshader = VerCode.c_str();&#xA;    const char* fshader = fregCode.c_str();&#xA;&#xA;    &#xA;    unsigned int vertexID = 0, fragID = 0;&#xA;    char infoLog[512];&#xA;    int  successflag = 0;&#xA;    vertexID = glCreateShader(GL_VERTEX_SHADER);&#xA;    glShaderSource(vertexID,1,&amp;vshader,NULL );&#xA;    glCompileShader(vertexID);&#xA;    &#xA;    glGetShaderiv(vertexID,GL_COMPILE_STATUS,&amp;successflag);&#xA;    if (!successflag)&#xA;    {&#xA;        glGetShaderInfoLog(vertexID,512,NULL,infoLog);&#xA;        std::string errstr(infoLog);&#xA;        std::cout &lt;&lt; "v shader err"&lt;/frag&#xA;    fragID = glCreateShader(GL_FRAGMENT_SHADER);&#xA;    glShaderSource(fragID, 1, &amp;fshader, NULL);&#xA;    glCompileShader(fragID);&#xA;    &#xA;    glGetShaderiv(fragID, GL_COMPILE_STATUS, &amp;successflag);&#xA;    if (!successflag)&#xA;    {&#xA;        glGetShaderInfoLog(fragID, 512, NULL, infoLog);&#xA;        std::string errstr(infoLog);&#xA;        std::cout &lt;&lt; "f shader err"&lt;/&#xA;    initmodule();&#xA;&#xA;&#xA;    &#xA;    while (!glfwWindowShouldClose(window))&#xA;    {&#xA;        &#xA;        processInput(window);&#xA;&#xA;        glClearColor(0.0f,0.0f,0.0f,1.0f);&#xA;        glClear(GL_COLOR_BUFFER_BIT);&#xA;        render();&#xA;    &#xA;        &#xA;        glfwSwapBuffers(window);&#xA;        &#xA;        glfwPollEvents();&#xA;    }&#xA;&#xA;    &#xA;    glfwTerminate();&#xA;    return 0;&#xA;}&#xA;</iostream></sstream></fstream></string>

    &#xA;

    I get the Y data ,and run the code is ok ;the color is gray ;but when I add the U ,the color is Light green;and when i add the V is pink and green ;

    &#xA;

        #version 330 core&#xA;layout(location = 0) out vec4 FragColor;&#xA;in vec2 TexCoord;&#xA;uniform sampler2D dataY;&#xA;uniform sampler2D dataU;&#xA;uniform sampler2D dataV;&#xA;vec3 yuv;&#xA;vec3 rgb;&#xA;void main()&#xA;{&#xA;&#xA;&#xA;   yuv.x = texture2D(dataY, TexCoord).r-0.0625;&#xA;   yuv.y = texture2D(dataU, TexCoord).r-0.5;&#xA;   yuv.z = texture2D(dataV, TexCoord).r-0.5;&#xA;&#xA;   rgb = mat3(1,              1,      1,     &#xA;            0,       -0.18732, 1.8556,    &#xA;            1.57481, -0.46813,      0) * yuv;   &#xA;    FragColor = vec4(rgb.x, rgb.y,rgb.z,1); &#xA;};&#xA;

    &#xA;