Recherche avancée

Médias (91)

Autres articles (98)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

    MediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
    The zip file provided here only contains the sources of MediaSPIP in its standalone version.
    To get a working installation, you must manually install all-software dependencies on the server.
    If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (7053)

  • ffmpeg writes invalid fps to the mp4 container (and in avi it is true). What is the reason ?

    8 juin 2020, par Ivan Sh.

    I need to record frames in real time. To test this situation, I make pts non-linear (since frames may be lost), thus :

    



    // AVFrame
video_frame->pts = prev_pts + 2;


    



    I use libavformat to write to a file. Parameters AVCodecContext and AVStream :

    



    #define STREAM_FRAME_RATE 25
#define CODEC_PIX_FMT  AV_PIX_FMT_YUV420P
#define FRAME_WIDTH 1440
#define FRAME_HEIGHT 900

// AVCodecContext
cc->codec_id = video_codec->id;
cc->bit_rate = 400000;
cc->width = FRAME_WIDTH;
cc->height = FRAME_HEIGHT;
cc->gop_size = 12;
cc->pix_fmt = CODEC_PIX_FMT;

// AVStream
video_stream->time_base = AVRational{ 1, STREAM_FRAME_RATE };
cc->time_base = video_stream->time_base;
cc->framerate = AVRational{ STREAM_FRAME_RATE , 1 };


    



    Write to file :

    



    static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
{
    /* rescale output packet timestamp values from codec to stream timebase */
    //av_packet_rescale_ts(pkt, *time_base, st->time_base);
    pkt->pts = av_rescale_q(pkt->pts, *time_base, st->time_base);
    pkt->dts = av_rescale_q(pkt->dts, *time_base, st->time_base);
    pkt->stream_index = st->index;

    /* Write the compressed frame to the media file. */
    //log_packet(fmt_ctx, pkt);
    //return av_write_frame(fmt_ctx, pkt);
    return av_interleaved_write_frame(fmt_ctx, pkt);
}


    



    If you use the avi container, then the information on the number of frames per second is indicated correctly in the file : 25 fps

    



    enter image description here

    



    If you use the mp4 container, then the file information about the number of frames per second is indicated incorrectly : 12.5 fps

    



    enter image description here

    



    Tell me, please, what other settings need to be added ?

    


  • CLI Extract date/time stamp (timestamp) from quicktime or mpeg files

    25 mai 2020, par vy32

    Is there a way to extract a date/time or a timestamp from various multi-media container files with Quicktime or MPEG2/MPEG4 ? I'm looking ideally for a command line tool. I have been able to get timestamps using ffprobe, part of the ffmpeg suite, but I haven't gotten the year, month and date. The camera had a clock so I'm pretty sure that this information was available.

    



    The history of this data file is that it was first shot on miniDV and transferred to a Mac over Firewire 800 using QuicktimePlayer to record the video. I'm told that the miniDV format is motion jpeg. The file command reports that the file is ISO Media, Apple QuickTime movie, Apple QuickTime (.MOV/QT).

    



    % ffprobe -f lavfi -i "movie=filename.mov,fps=fps=25[out0]" -show_frames -show_streams -show_entries frame=pkt_pts_time -of csv=p=0 2>&1 | head -30
ffprobe version 4.2.2 Copyright (c) 2007-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-librsvg --enable-libtheora --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-indev=jack --enable-opencl --disable-outdev=xv --enable-audiotoolbox --enable-videotoolbox --enable-sdl2 --disable-securetransport --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-x86asm --enable-libx265 --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfdk-aac
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, lavfi, from 'movie=/Volumes/SanDiskSSD/Movies/Italy22.mov,fps=fps=25[out0]':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
0.000000
0.040000
0.080000
0.120000
0.160000
0.200000
0.240000
0.280000
0.320000
0.360000
0.400000
0.440000
0.480000
0.520000
0.560000
%


    



    I want output showing the year, month and date that this was shot.

    


  • How to get FFMPEG to encode H264 using libx264 ?

    12 décembre 2021, par Basit Anwer

    FFMPEG encode example fails to create a H264 video. MPEG1 works fine though.

    



    Pasting the code here as well

    



    &#xA;     * @file&#xA;     * video encoding with libavcodec API example&#xA;     *&#xA;     * @example encode_video.c&#xA;     */&#xA;    #include &#xA;    #include &#xA;    #include &#xA;    #include <libavcodec></libavcodec>avcodec.h>&#xA;    #include <libavutil></libavutil>opt.h>&#xA;    #include <libavutil></libavutil>imgutils.h>&#xA;    static void encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt,&#xA;                       FILE *outfile)&#xA;    {&#xA;        int ret;&#xA;        /* send the frame to the encoder */&#xA;        if (frame)&#xA;            printf("Send frame %3"PRId64"\n", frame->pts);&#xA;        ret = avcodec_send_frame(enc_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error sending a frame for encoding\n");&#xA;            exit(1);&#xA;        }&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(enc_ctx, pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                return;&#xA;            else if (ret &lt; 0) {&#xA;                fprintf(stderr, "Error during encoding\n");&#xA;                exit(1);&#xA;            }&#xA;            printf("Write packet %3"PRId64" (size=%5d)\n", pkt->pts, pkt->size);&#xA;            fwrite(pkt->data, 1, pkt->size, outfile);&#xA;            av_packet_unref(pkt);&#xA;        }&#xA;    }&#xA;&#xA;    int main(int argc, char **argv)&#xA;    {&#xA;        const char *filename, *codec_name;&#xA;        const AVCodec *codec;&#xA;        AVCodecContext *c= NULL;&#xA;        int i, ret, x, y;&#xA;        FILE *f;&#xA;        AVFrame *frame;&#xA;        AVPacket *pkt;&#xA;        uint8_t endcode[] = { 0, 0, 1, 0xb7 };&#xA;        if (argc &lt;= 2) {&#xA;            fprintf(stderr, "Usage: %s <output file="file"> <codec>\n", argv[0]);&#xA;            exit(0);&#xA;        }&#xA;        filename = argv[1];&#xA;        codec_name = argv[2];&#xA;        /* find the mpeg1video encoder */&#xA;        codec = avcodec_find_encoder_by_name(codec_name);&#xA;        if (!codec) {&#xA;            fprintf(stderr, "Codec &#x27;%s&#x27; not found\n", codec_name);&#xA;            exit(1);&#xA;        }&#xA;        c = avcodec_alloc_context3(codec);&#xA;        if (!c) {&#xA;            fprintf(stderr, "Could not allocate video codec context\n");&#xA;            exit(1);&#xA;        }&#xA;        pkt = av_packet_alloc();&#xA;        if (!pkt)&#xA;            exit(1);&#xA;        /* put sample parameters */&#xA;        c->bit_rate = 400000;&#xA;        /* resolution must be a multiple of two */&#xA;        c->width = 352;&#xA;        c->height = 288;&#xA;        /* frames per second */&#xA;        c->time_base = (AVRational){1, 25};&#xA;        c->framerate = (AVRational){25, 1};&#xA;        /* emit one intra frame every ten frames&#xA;         * check frame pict_type before passing frame&#xA;         * to encoder, if frame->pict_type is AV_PICTURE_TYPE_I&#xA;         * then gop_size is ignored and the output of encoder&#xA;         * will always be I frame irrespective to gop_size&#xA;         */&#xA;        c->gop_size = 10;&#xA;        c->max_b_frames = 1;&#xA;        c->pix_fmt = AV_PIX_FMT_YUV420P;&#xA;        if (codec->id == AV_CODEC_ID_H264)&#xA;            av_opt_set(c->priv_data, "preset", "slow", 0);&#xA;        /* open it */&#xA;        ret = avcodec_open2(c, codec, NULL);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        f = fopen(filename, "wb");&#xA;        if (!f) {&#xA;            fprintf(stderr, "Could not open %s\n", filename);&#xA;            exit(1);&#xA;        }&#xA;        frame = av_frame_alloc();&#xA;        if (!frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        frame->format = c->pix_fmt;&#xA;        frame->width  = c->width;&#xA;        frame->height = c->height;&#xA;        ret = av_frame_get_buffer(frame, 32);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not allocate the video frame data\n");&#xA;            exit(1);&#xA;        }&#xA;        /* encode 1 second of video */&#xA;        for (i = 0; i &lt; 25; i&#x2B;&#x2B;) {&#xA;            fflush(stdout);&#xA;            /* make sure the frame data is writable */&#xA;            ret = av_frame_make_writable(frame);&#xA;            if (ret &lt; 0)&#xA;                exit(1);&#xA;            /* prepare a dummy image */&#xA;            /* Y */&#xA;            for (y = 0; y &lt; c->height; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width; x&#x2B;&#x2B;) {&#xA;                    frame->data[0][y * frame->linesize[0] &#x2B; x] = x &#x2B; y &#x2B; i * 3;&#xA;                }&#xA;            }&#xA;            /* Cb and Cr */&#xA;            for (y = 0; y &lt; c->height/2; y&#x2B;&#x2B;) {&#xA;                for (x = 0; x &lt; c->width/2; x&#x2B;&#x2B;) {&#xA;                    frame->data[1][y * frame->linesize[1] &#x2B; x] = 128 &#x2B; y &#x2B; i * 2;&#xA;                    frame->data[2][y * frame->linesize[2] &#x2B; x] = 64 &#x2B; x &#x2B; i * 5;&#xA;                }&#xA;            }&#xA;            frame->pts = i;&#xA;            /* encode the image */&#xA;            encode(c, frame, pkt, f);&#xA;        }&#xA;        /* flush the encoder */&#xA;        encode(c, NULL, pkt, f);&#xA;        /* add sequence end code to have a real MPEG file */&#xA;        if (codec->id == AV_CODEC_ID_MPEG1VIDEO || codec->id == AV_CODEC_ID_MPEG2VIDEO)&#xA;            fwrite(endcode, 1, sizeof(endcode), f);&#xA;        fclose(f);&#xA;        avcodec_free_context(&amp;c);&#xA;        av_frame_free(&amp;frame);&#xA;        av_packet_free(&amp;pkt);&#xA;        return 0;&#xA;    }&#xA;</codec></output>

    &#xA;&#xA;

    The code fails at encode call and every avcodec_receive_packet call returns AVERROR(EAGAIN)

    &#xA;&#xA;

    What am i missing here ?

    &#xA;