Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (20)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Les vidéos

    21 avril 2011, par

    Comme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
    Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
    Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...)

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

  • 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;
}


    


  • How do I remux/transcode a progressive file in ffmpeg ?

    3 décembre 2014, par Levi Roberts

    Here’s what I’m trying to do.

    My primary objective is to remux or transcode a currently downloading media file for AppleTV and iOS compatible streaming.

    I am doing this by looking at the media file and only transcoding when necessary, otherwise it will only alter the container the video/audio lives in. This will reduce overhead for files that are already compatible. The specific compatible output I am looking for is AppleTV3 and iOS.

    I have a file that is progressive, meaning that it is downloading using another download manager or another app without the help of nodejs. This file may or may not have the moov information available in the beginning of the file. It just so happens, that I believe my test file does.

    I have some code that is partially working and it would make sense to be able to get this code fully working. That said, I’m not dismissing alternative ways to do this.

    My primary problem (I think) has to do with the moov header location or that it’s being set incorrectly. I’m hoping the fix is as simple as correcting my poor ffmpeg knowledge with command line parameters.

    I am piping the file to and from ffmpeg via GrowingFile and fs.createWriteStream respectively.

    My code for doing so is :

    var fs = require('fs');
    var child = require('child_process');

    var GrowingFile = require('growing-file');
    var input_file = GrowingFile.open('./tmp/input.mp4');
    var output_file = fs.createWriteStream('./tmp/output.m4v');

    // I've tried various args and ffmpeg params here without success.
    var args = ['-re', '-i', 'pipe:0', '-g', '52', '-ab', '64k', '-vcodec', 'libx264', '-vb', '448k', '-f', 'mp4', '-movflags', 'frag_keyframe+faststart', 'pipe:1'];
    var trans_proc = child.spawn('ffmpeg', args, null);

    input_file.pipe(trans_proc.stdin);
    trans_proc.stdout.pipe(output_file);

    I am also temporarily trying to make these files work as intended via ffmpeg command line alone, without success. That command is :

    ffmpeg -i original.mp4 -vcodec copy -r 24 output.m4v

    Snippet of original.mp4 via mediainfo :

    General
    Format                                   : MPEG-4
    Format profile                           : Base Media / Version 2
    Codec ID                                 : mp42
    File size                                : 9.87 MiB
    Duration                                 : 43mn 14s
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 31.9 Kbp

    Video
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L2.1
    Codec ID                                 : avc1
    Duration                                 : 43mn 14s
    Width                                    : 480 pixels
    Height                                   : 268 pixels
    Color space                              : YUV
    Scan type                                : Progressive
    Stream size                              : 67.5 MiB

    Audio
    Format                                   : AAC
    Format/Info                              : Advanced Audio Codec
    Format profile                           : LC
    Codec ID                                 : 40
    Duration                                 : 43mn 14s
    Bit rate mode                            : Variable
    Bit rate                                 : 96.0 Kbps

    What’s happening is that output.m4v has an incorrect duration of only the part of the file that’s already downloaded. The video reaches the end or a refresh happens to make the duration longer. This process repeats until the original file is done downloading. What I want is to be able to emulate/clone the duration of the input file to the output file .

  • FFmpeg meaningful video thumbnails

    18 avril 2015, par Maverick

    I know this question has been discussed already here. However, it did not solve the problem completely. I trying to retrieve meaning thumbnails from video and while executing the following command.

    ffmpeg -ss 3 -i input.avi -vf "select=gt(scene\,0.4)" -frames:v 5 -vsync vfr -vf "fps=fps=1/600" out%02d.jpg

    As a result, I am only able to get 1 image out of this video. I am not sure, what is going wrong over here.

    Also, it would be great, if someone kindly give a quick explanation of this command parameters and filters. The command originally comes from here

    FFMPEG console output :

    ffmpeg version 2.6 Copyright (c) 2000-2015 the FFmpeg developers
     built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libass --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.1_1/include/openjpeg-1.5 ' --enable-nonfree --enable-vda
     libavutil      54. 20.100 / 54. 20.100
     libavcodec     56. 26.100 / 56. 26.100
     libavformat    56. 25.101 / 56. 25.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 11.102 /  5. 11.102
     libavresample   2.  1.  0 /  2.  1.  0
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, avi, from 'tagesschau.avi':
     Metadata:
       encoder         : Lavf56.25.101
     Duration: 00:00:20.03, start: 0.000000, bitrate: 4357 kb/s
       Stream #0:0: Video: mpeg4 (Simple Profile) (xvid / 0x64697678), yuv420p, 720x540 [SAR 1:1 DAR 4:3], 4190 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc
       Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 44100 Hz, stereo, fltp, 160 kb/s
    [swscaler @ 0x7fcb2a00f600] deprecated pixel format used, make sure you did set range correctly
    [mjpeg @ 0x7fcb2a803c00] bitrate tolerance 4000000 too small for bitrate 200000, overriding
    Output #0, image2, to 'out%02d.jpg':
     Metadata:
       encoder         : Lavf56.25.101
       Stream #0:0: Video: mjpeg, yuvj420p(pc), 720x540 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 0k fps, 0k tbn, 0k tbc
       Metadata:
         encoder         : Lavc56.26.100 mjpeg
    Stream mapping:
     Stream #0:0 -> #0:0 (mpeg4 (native) -> mjpeg (native))
    Press [q] to stop, [?] for help
    frame=    1 fps=0.0 q=6.9 Lsize=N/A time=00:10:00.00 bitrate=N/A    
    video:44kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown