Recherche avancée

Médias (91)

Autres articles (33)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    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 (...)

  • Emballe Médias : Mettre en ligne simplement des documents

    29 octobre 2010, par

    Le plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
    Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
    D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...)

  • 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 (3840)

  • 2 video decoding with same bitrate android

    4 mars 2016, par Bee

    How to do double decoding(2 videos decoding) with same bit rate android ? I mean I want to play 2 videos in 2 different views but syncronisedly. I found this grafika double decoder. But it is not with same bitrate.
    The documentation says that.
    Any one know any sample project or guideline that I can follow ? Or maybe just can illustrate the steps I have to do ? May be used ffmpeg or something else ? Can anyone plese help me ?

  • Is there a way to change the ffplay playback speed while running

    20 mai 2024, par richjhart

    I am trying to modify ffplay 7.0 to allow us to modify the playback speed while running. Our use-case only involves basic video-only mp4 files.

    


    We can set the playback speed with something like the following :

    


    ffplay -i ..\Video\SampleVideoLong.mp4 -vf "setpts=5.0*PTS" -loglevel debug -sync video

    


    But I don't know how to change that option "live" (note if I don't choose -sync video, it gets very laggy - but that's fine as our use-case is video only.

    


    I have tried the following (with just a fixed rate at the moment) :

    


            {
            static double l_CurrentSpeed = 1.0;
            double l_NewSpeed = 2.0;
            double l_Diff = l_NewSpeed / l_CurrentSpeed;
            double l_ClockSpeed = cur_stream->extclk.speed;
            double l_NewClockSpeed = l_ClockSpeed * l_Diff;
            av_log(NULL, AV_LOG_DEBUG,
                "Changing speed from %f to %f\n",
                l_ClockSpeed, l_NewClockSpeed
                );

            set_clock_speed(&cur_stream->vidclk, l_NewClockSpeed);
            //set_clock(&cur_stream->vidclk, l_NewClockSpeed, cur_stream->extclk.serial);
            l_CurrentSpeed = l_NewSpeed;
        }


    


    I've set both the pts (set_clock()) and the "speed" (set_clock_speed()), but neither of these had any effect.

    


    Would I need to something extra, or is there a way to update the setpts expression in the video filter from ffplay ?

    


    Note the metadata of the file we are trying with is :

    


    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '..\Video\SampleVideoLong.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf61.1.100
  Duration: 00:18:10.56, start: 0.160000, bitrate: 1755 kb/s
  Stream #0:0[0x1](und), 1, 1/90000: Video: mpeg2video (Main), 1 reference frame (mp4v / 0x7634706D), yuv420p(tv, bt709, progressive, left), 1920x1080 [SAR 1:1 DAR 16:9], 0/1, 1754 kb/s, 25 fps, 25 tbr, 90k tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : XDCAM EX 1080p25
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 278528 vbv_delay: N/A


    


    I believe the files we'll be using should have identical or similar metadata.

    


  • ffmpeg : programmatically use libavcodec and encode and decode raw bitmap, all in just few milliseconds and small compressed size on Raspberry Pi 4

    15 mars 2023, par Jerry Switalski

    We need to compress the size of the 1024x2048 image we produce, to size of about jpeg (200-500kb) from raw 32bits RGBA (8Mb) on Raspberry Pi 4. All in c/c++ program.

    


    The compression needs to be just in few milliseconds, otherwise it is pointless to us.

    


    We decided to try supported encoding using ffmpeg dev library and c/c++ code.

    


    The problem we are facing is that when we edited example of the encoding, provided by ffmpeg developers, the times we are dealing are unacceptable.

    


    Here you can see the edited code where the frames are created :

    


    for (i = 0; i < 25; i++)
{
#ifdef MEASURE_TIME
        auto start_time = std::chrono::high_resolution_clock::now();
        std::cout << "START Encoding frame...\n";
#endif
    fflush(stdout);

    ret = av_frame_make_writable(frame);
    if (ret < 0)
        exit(1);

    //I try here, to convert our 32 bits RGBA image to YUV pixel format:

    for (y = 0; y < c->height; y++)
    {
        for (x = 0; x < c->width; x++)
        {
            int imageIndexY = y * frame->linesize[0] + x;

            uint32_t rgbPixel = ((uint32_t*)OutputDataImage)[imageIndexY];

            double Y, U, V;
            uint8_t R = rgbPixel << 24;
            uint8_t G = rgbPixel << 16;
            uint8_t B = rgbPixel << 8;

            YUVfromRGB(Y, U, V, (double)R, (double)G, (double)B);
            frame->data[0][imageIndexY] = (uint8_t)Y;

            if (y % 2 == 0 && x % 2 == 0)
            {
                int imageIndexU = (y / 2) * frame->linesize[1] + (x / 2);
                int imageIndexV = (y / 2) * frame->linesize[2] + (x / 2);

                frame->data[1][imageIndexU] = (uint8_t)U;
                frame->data[2][imageIndexV] = (uint8_t)Y;
            }
        }
    }

    frame->pts = i;

    /* encode the image */
    encode(c, frame, pkt, f);

#ifdef MEASURE_TIME
        auto end_time = std::chrono::high_resolution_clock::now();
        auto time = end_time - start_time;
        std::cout << "FINISHED Encoding frame in: " << time / std::chrono::milliseconds(1) << "ms.\n";

#endif
    }


    


    Here are some important parts of the previous parts of that function :

    


    codec_name = "mpeg4";

codec = avcodec_find_encoder_by_name(codec_name);

c = avcodec_alloc_context3(codec);
    
c->bit_rate = 1000000;  
c->width = IMAGE_WIDTH;
c->height = IMAGE_HEIGHT;
c->gop_size = 1;
c->max_b_frames = 1;
c->pix_fmt = AV_PIX_FMT_YUV420P;   


    


    IMAGE_WIDTH and IMAGE_HEIGHT are 1024 and 2048 corresponding.

    


    The result I have ran on Raspberry Pi 4 look like this :

    


    START Encoding frame...
Send frame   0
FINISHED Encoding frame in: 40ms.
START Encoding frame...
Send frame   1
Write packet   0 (size=11329)
FINISHED Encoding frame in: 60ms.
START Encoding frame...
Send frame   2
Write packet   1 (size=11329)
FINISHED Encoding frame in: 58ms.


    


    Since I am completely green in encoding and using codecs, my question will be how to do it the best way and correct way, meaning the way which would reduce timing to few ms, and I am not sure the codec was chosen the best for the job, or the pixel format.

    


    The rest of the meaningful code you can see here (the encode() function you can find in the ffmpeg developer example I gave link to above) :

    


    void RGBfromYUV(double& R, double& G, double& B, double Y, double U, double V)
{
    Y -= 16;
    U -= 128;
    V -= 128;
    R = 1.164 * Y + 1.596 * V;
    G = 1.164 * Y - 0.392 * U - 0.813 * V;
    B = 1.164 * Y + 2.017 * U;
}