Recherche avancée

Médias (33)

Mot : - Tags -/creative commons

Autres articles (77)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

  • Pas question de marché, de cloud etc...

    10 avril 2011

    Le vocabulaire utilisé sur ce site essaie d’éviter toute référence à la mode qui fleurit allègrement
    sur le web 2.0 et dans les entreprises qui en vivent.
    Vous êtes donc invité à bannir l’utilisation des termes "Brand", "Cloud", "Marché" etc...
    Notre motivation est avant tout de créer un outil simple, accessible à pour tout le monde, favorisant
    le partage de créations sur Internet et permettant aux auteurs de garder une autonomie optimale.
    Aucun "contrat Gold ou Premium" n’est donc prévu, aucun (...)

Sur d’autres sites (6578)

  • FFmpeg can not open video file after adding the GLsurfaceView to render frames

    4 avril 2016, par Kyle Lo

    The source code works perfectly without any modification.

    I successfully use the below function to play the specified video.

    playview.openVideoFile("/sdcard/Test/mv.mp4");

    And for the research purpose I need to display the frame by using OpenGL ES. So I remove the original method below.

    ANativeWindow* window = ANativeWindow_fromSurface(env, javaSurface);

    ANativeWindow_Buffer buffer;
    if (ANativeWindow_lock(window, &buffer, NULL) == 0) {
     memcpy(buffer.bits, pixels,  w * h * 2);
     ANativeWindow_unlockAndPost(window);
    }

    ANativeWindow_release(window);

    And I add FrameRenderer class into my project

    public class FrameRenderer implements GLSurfaceView.Renderer {

       public long time = 0;
       public short framerate = 0;
       public long fpsTime = 0;
       public long frameTime = 0;
       public float avgFPS = 0;
       private PlayNative mNative = null;

       @Override
       public void onSurfaceCreated(GL10 gl, EGLConfig config) {/*do nothing*/}

       @Override
       public void onSurfaceChanged(GL10 gl, int width, int height) {

       }

       @Override
       public void onDrawFrame(GL10 gl) {
           mNative.render();
       }

    In the native side I create a corresponding method in VideoPlay.cpp And I only use glClearColorto test if the OpenGL function works or not.

    void VideoPlay::render() {
       glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
       glClear(GL_COLOR_BUFFER_BIT);
    }

    And the onCreate is as below.

    protected void onCreate(Bundle savedInstanceState) {
           // TODO Auto-generated method stub
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main_layout);

           playview = new PlayView(this);

           playview.openVideoFile("/sdcard/test_tt_racing.mp4");
           //playview.openVideoFile("/sdcard/big_buck_bunny.mp4");

           GLSurfaceView surface = (GLSurfaceView)findViewById(R.id.surfaceviewclass);
           surface.setRenderer(new FrameRenderer());
           ...

    Then test it on the mobile, the screen becomes red which means the GLSurfaceView and OpenGL works fine.

    But after I press the play bottom, whole the app stucked. And Show in the
    Log

    My question is why I can open the video whose path is totally the same with the previous one, just after I added the GLsurface renderer and how can I fix it ?

  • FFMPEG - FFV1 frame encoding crashes on cleaning up

    21 mai 2016, par Yan

    I’m trying to implement a frame encoding functionality using the ffmpeg c-api. I am receiving frames from a camera which are in the Gray16le format. I want to convert encode them using the ffv1 encoder and copy the resulting frame into the variable "data". This is the code that I got so far. It seems to be working in a sense that it doesn’t crash until the part where I am freeing up my variables.

    /* Video compression variables///////////////////////////////////*/
    struct timeval stop, start;

    AVCodec *codec;
    AVCodecContext *context= NULL;
    const AVPixFmtDescriptor *avPixDesc = NULL; // used to get bits per pixel
    int ret, got_output;
    int bufferSize = 0; // Size of encoded image frame in bytes
    //uint8_t* outBuffer;
    AVFrame *inFrame; //
    AVPacket pkt;
    Data* data;
    /* Video compression ///////////////////////////////////*/

    Frame* frame;
    /////////////////////////////////////////////////////////////////////////
    // start frame compression - current codec is ffv1
    //////////////////////////////////////////////////////////////////////////

    gettimeofday(&start, NULL); // get current time
    avcodec_register_all(); // register all the codecs
    codec = avcodec_find_encoder(AV_CODEC_ID_FFV1); // find the ffv1 encoder
    if (!codec) {
       fprintf(stderr, "Codec not found\n");
       exit(1);
    }

    context = avcodec_alloc_context3(codec);
    if (!context) {
       fprintf(stderr, "Could not allocate video codec context\n");
       exit(1);
    }

    frame = getFrame(); // get frame so we can set context params

    /* put sample parameters */
    context->bit_rate = 400000; // from example, half might also work
    /* resolution must be a multiple of two */
    context->width = frame->size[0];
    context->height = frame->size[1];
    /* frames per second */
    context->time_base = (AVRational){1,22}; // 22 fps

    context->gop_size = 1; // typical for ffv1 codec
    context->max_b_frames = 1; // set to 1 for now, the higher the b-frames count, the higher the needed ressources
    context->pix_fmt = AV_PIX_FMT_GRAY16LE ; // same as source, Y , 16bpp, little-endian, 12 of the 16 pixels are used

    /* open it */
    if (avcodec_open2(context, codec, NULL) < 0) {
           fprintf(stderr, "Could not open codec\n");
           exit(1);
    }

    inFrame = av_frame_alloc();
    if(!inFrame)
    {
       printf("Could not allocate video frame\n! Exciting..");
       exit(1);
    }

    // allocate image in inFrame
    ret = av_image_alloc(inFrame->data, inFrame->linesize, context->width, context->height, context->pix_fmt, 16);
    if(ret<0)
    {
       printf("Error allocating image of inFrame! Exiting..\n");
       exit(1);
    }

    // copy data of frame of type Frame* into frame of type AVFrame* so we can use ffmpeg to encode it
    int picFill = avpicture_fill((AVPicture*)inFrame, (uint8_t*)frame->image, context->pix_fmt, context->width, context->height);

    if(picFill < 0)
    {
       printf("Error filling inFrame with frame->image! Exiting..\n");
       exit(1);
    }
    else
    {
       printf("Successfully filled inFrame with frame->image..\n");
       printf("Size of bytes filled:  %d", picFill);
    }

    inFrame->width = context->width;
    inFrame->height = context->height;
    inFrame->format = context->pix_fmt;

    if(frame->image[0] == NULL)
    {
           printf("Error! frame->image[0] == NULL.. Exiting..\n");
           exit(1);
    }

    fflush(stdout);
    int i=0;

    // start encoding
    while(!got_output) // while we didn't get a complete package
    {
       /* Start encoding the given frame */
       av_init_packet(&pkt);
       pkt.data = NULL;    // packet data will be allocated by the encoder
       pkt.size = 0;

       i++;

       /* encode the image */
       ret = avcodec_encode_video2(context, &pkt, inFrame, &got_output);
       if (ret < 0) {
               fprintf(stderr, "Error encoding frame\n");
               exit(1);
       }

       inFrame->pts = i;

       if(got_output)
       {
           printf("Got a valid package after %d frames..\n", i);
           // encoding of frame done, adapt "data"-field accordingly
           avPixDesc = av_pix_fmt_desc_get(context->pix_fmt); // Get pixelFormat descriptor
           bufferSize = av_image_get_buffer_size(context->pix_fmt, inFrame->width, inFrame->height,16);
           if(bufferSize <= 0)
           {
               printf("Error! Buffersize of encoded frame is <= 0, exciting...\n");
           }
           else
           {
               printf("Buffersize determined to be %d\n", bufferSize);
           }

           data->m_size[0] = inFrame->width;
           data->m_size[1] = inFrame->height;
           data->m_bytesPerPixel = av_get_bits_per_pixel(avPixDesc)/8;

           if (0 != av_get_bits_per_pixel(avPixDesc) % 8)
                   data->m_bytesPerPixel += 1;

           printf("Buffersize is: %d, should be %d\n", bufferSize, inFrame->width * inFrame->height * data->m_bytesPerPixel);
           data->m_image = malloc(bufferSize);
           printf("copying data into final variable...\n");

           memcpy(data->m_image, pkt.data, bufferSize); // copy data from ffmpeg frame
           printf("copying of data done\n");

           printf("Unrefing packet..\n");
           av_packet_unref(&pkt);
           printf("Unrefing packet done..\n");
       }
       else
       {
           printf("Didnt get package, so we get and encode next frame..\n");
           frame = getFrame(); // get next frame            

           picFill = avpicture_fill((AVPicture*)inFrame, (uint8_t*)frame->image, context->pix_fmt, context->width, context->height);
           if(!picFill)
           {
               printf("Error filling frame with data!!..\n");
               exit(1);
           }
           else
           {
               printf("Size required to store received frame in AVFrame in bytes: %d", picFill);
           }
       }
    }

    printf("\nDone with encoding.. cleaning up..\n");
    printf("Closing context...\n");
    avcodec_close(context);
    printf("Closing context done...\n");
    printf("Freeing context...\n");
    av_free(context);
    printf("Freeing context done...\n");
    if(inFrame->data[0] != NULL)
    {
       printf("avfreep() pointer to FFMPEG frame data...\n");
       av_freep(&inFrame->data[0]);
       printf("Freeing pointer to FFMPEG frame data done...\n");
    }
    else
    {
       printf("infRame->data[0] was not deleted because it was NULL\n");
    }

    printf("Freeing frame...\n");
    av_frame_free(&inFrame);
    printf("Freeing inFrame done...\n");
    printf("Compression of frame done...\n");
    gettimeofday(&stop, NULL);
    printf("took %lu ms\n", (stop.tv_usec - start.tv_usec) / 1000);

    This is the output that I am getting when I run the program :

    [ffv1 @ 0x75101970] bits_per_raw_sample > 8, forcing range coder
    Successfully filled inFrame with frame->image..
    Size of bytes filled:  1377792Got a valid package after 1 frames..
    Buffersize determined to be 1377792
    Buffersize is: 1377792, should be 1377792
    copying data into final variable...
    copying of data done
    Unrefing packet..
    Unrefing packet done..

    Done with encoding.. cleaning up..
    Closing context...
    Closing context done...
    Freeing context...
    Freeing context done...
    avfreep() pointer to FFMPEG frame data...
    *** Error in `./encoding': free(): invalid pointer: 0x74a66428 ***
    Aborted

    The error seems to occur when calling the av_freep() function. If you could point me in the right direction, it would be greatly appreciated ! This is my first time working with the ffmpeg api and I feel that I am not so close to my goal, though I spent quite some time looking for the error already..

    Best regards !

  • Proper reading of MP3 file disrupted by ID3 tags

    3 septembre 2016, par PookyFan

    My semestral project is due this Thursday and I have major problem with reading MP3 file (the project is about sound analysis, don’t ask my what exactly is it about and why I’m doing it so late).

    First, I read first 10 bytes to check for ID3 tags. If they’re present, I’ll just skip to the first MP3 header - or at least that’s the big idea. Here is how I count ID3 tag size :

    if (inbuf[0] == 'I' && inbuf[1] == 'D' && inbuf[2] == '3') //inbuf contains first 10 bytes from file
    {
       int size = inbuf[3] * 2097152 + inbuf[4] * 16384 + inbuf[5] * 128 + inbuf[6]; //Will change to binary shifts later
       //Do something else with it - skip rest of ID3 tags etc
    }

    It works ok for files without ID3 tags and for some files with them, but for some other files ffmpeg (which I use for decoding) returns "no header" error, which means it didn’t catch MP3 header correctly. I know that since if I remove ID3 from that .mp3 file (with Winamp for example), no errors occur. The conclusion is that size count algorithm isn’t always valid.

    So the question is : how do I get to know how big exactly is entire ID3 part of the .mp3 file (all possible tags, album picture and whatever) ? I’m looking for it everywhere but I just keep finding this algorithm I posted above. Sometimes also something about some 10 bytes footer I need to take into account, but it seems it frequently gets more than 10 bytes for it to eventually catch proper MP3 frame.