Recherche avancée

Médias (91)

Autres articles (101)

  • Multilang : améliorer l’interface pour les blocs multilingues

    18 février 2011, par

    Multilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
    Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela.

  • L’agrémenter visuellement

    10 avril 2011

    MediaSPIP est basé sur un système de thèmes et de squelettes. Les squelettes définissent le placement des informations dans la page, définissant un usage spécifique de la plateforme, et les thèmes l’habillage graphique général.
    Chacun peut proposer un nouveau thème graphique ou un squelette et le mettre à disposition de la communauté.

  • Possibilité de déploiement en ferme

    12 avril 2011, par

    MediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
    Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)

Sur d’autres sites (8110)

  • Command Line 'hls_segment_size' creates TS files with segment failures

    14 octobre 2019, par Phantom

    I am converting a simple mp4 video to hls but I need the segments to be in approximately a specific size

    I researched and found :

    -hls_segment_size 17000000

    17000000 bytes( 17MB)

    This creates TS files with approximate sizes, (does not have to be exact size)

    ffmpeg.exe -i "in.mp4" -vcodec copy -acodec aac -hls_list_size 0 -hls_segment_size 17000000 -f hls "out.m3u8"

    In the m3u8 file is created ’#EXT-X-BYTERANGE’, which is the way I want it

    #EXTM3U
    #EXT-X-VERSION:4
    #EXT-X-TARGETDURATION:10
    #EXT-X-MEDIA-SEQUENCE:0
    #EXTINF:8.400000,
    #EXT-X-BYTERANGE:1662108@0
    SampleVideo_1280x720_30mb0.ts
    #EXTINF:4.560000,
    #EXT-X-BYTERANGE:383896@0
    SampleVideo_1280x720_30mb1.ts
    #EXTINF:3.120000,
    #EXT-X-BYTERANGE:408712@383896
    SampleVideo_1280x720_30mb1.ts
    #EXTINF:5.640000,
    #EXT-X-BYTERANGE:1161840@0
    SampleVideo_1280x720_30mb2.ts
    #EXTINF:1.880000,
    #EXT-X-BYTERANGE:230864@0
    SampleVideo_1280x720_30mb3.ts
    #EXTINF:2.160000,
    #EXT-X-BYTERANGE:330880@230864
    SampleVideo_1280x720_30mb3.ts
    #EXTINF:2.080000,
    #EXT-X-BYTERANGE:489928@0
    SampleVideo_1280x720_30mb4.ts
    #EXTINF:4.400000,
    #EXT-X-BYTERANGE:1564348@489928
    SampleVideo_1280x720_30mb4.ts
    ...

    It seems alright, but it has a little problem. I’m testing on a player in the browser, and when the seconds goes from one segment to the other the video has a lock in sound and video. Something very annoying, not natural in the video.

    Not using ’-hls_segment_size’ will have functional TS files, and without BYTERANGE in the m3u8 file

    However, the size of the TS file will be according to the seconds defined

    I am currently trying to get a ts file that is close to a size set between 15MB and 20MB, and have BYTERANGE in the m3u8 file.

    Does anyone have any ideas ?

    here’s the problem I’m trying to describe :

    http://phantsc.rf.gd/AAA/Bbb.html

    exactly in the second 7 of the video a ’locking’ happens, this happens when going from one segment to another

  • Live555 truncates encoded data of FFMpeg

    22 novembre 2019, par Harshil Makwana

    I am trying to stream H264 based data using Live555 over RTSP.

    I am capturing data using V4L2, and then encodes it using FFMPEG and then passing data to Live555’s DeviceSource file, in that I using H264VideoStreamFramer class,

    Below is my codec settings to configure AVCodecContext of encoder,

    codec = avcodec_find_encoder_by_name(CODEC_NAME);
    if (!codec) {
       cerr << "Codec " << codec_name << " not found\n";
       exit(1);
    }

    c = avcodec_alloc_context3(codec);
    if (!c) {
       cerr << "Could not allocate video codec context\n";
       exit(1);
    }

    pkt = av_packet_alloc();
    if (!pkt)
       exit(1);

    /* put sample parameters */
    c->bit_rate = 400000;
    /* resolution must be a multiple of two */
    c->width = PIC_HEIGHT;
    c->height = PIC_WIDTH;
    /* frames per second */
    c->time_base = (AVRational){1, FPS};
    c->framerate = (AVRational){FPS, 1};
    c->gop_size = 10;
    c->max_b_frames = 1;
    c->pix_fmt = AV_PIX_FMT_YUV420P;
    c->rtp_payload_size = 30000;
    if (codec->id == AV_CODEC_ID_H264)
       av_opt_set(c->priv_data, "preset", "fast", 0);
    av_opt_set_int(c->priv_data, "slice-max-size", 30000, 0);
    /* open it */
    ret = avcodec_open2(c, codec, NULL);
    if (ret < 0) {
       cerr << "Could not open codec\n";
       exit(1);
    }

    And I am getting encoded data using avcodec_receive_packet() function. which will return AVPacket.

    And I am passing AVPacket’s data into DeviceSource file below is code snippet of my Live555 code :

    void DeviceSource::deliverFrame() {
       if (!isCurrentlyAwaitingData()) return; // we're not ready for the data yet

       u_int8_t* newFrameDataStart = (u_int8_t*) pkt->data;
       unsigned newFrameSize = pkt->size; //%%% TO BE WRITTEN %%%
       // Deliver the data here:
       if (newFrameSize > fMaxSize) { // Condition becomes true many times
           fFrameSize = fMaxSize;
           fNumTruncatedBytes = newFrameSize - fMaxSize;
       } else {
           fFrameSize = newFrameSize;
       }
       gettimeofday(&fPresentationTime, NULL); // If you have a more accurate time - e.g., from an encoder - then use that instead.
       // If the device is *not* a 'live source' (e.g., it comes instead from a file or buffer), then set "fDurationInMicroseconds" here.
       memmove(fTo, newFrameDataStart, fFrameSize);
    }

    But here, sometimes my packet’s size is getting more than fMaxSize value and as per LIVE555 logic it will truncate frame data, so that sometimes I am getting bad frames on my VLC,

    From Live555 forum, I get to know that encoder should not send packet whose size is more than fMaxSize value, so my question is :

    How to restrict encoder to limit size of packet ?

    Thanks in Advance,

    Harshil

  • Create movie programatically with ffmpeg

    16 janvier 2019, par Martin Delille

    I would like to create a movie programatically with ffmpeg.

    Here is my code :

    QString fileName = "test.mov";
    static char errorString[AV_ERROR_MAX_STRING_SIZE];

    printf("Video encoding\n");

    AVOutputFormat *outputFormat = av_guess_format(nullptr, fileName.toStdString().c_str(), nullptr);

    if (outputFormat == nullptr) {
       qDebug() << "Could not find suitable format for" << fileName;
       return false;
    }

    enum AVCodecID codec_id = AV_CODEC_ID_MJPEG;

    qDebug() << "Format Name:" << outputFormat->name;
    qDebug() << "Format Video Codec:" << outputFormat->video_codec;
    outputFormat->video_codec = codec_id;

    /// allocate the output media context, formatContext
    AVFormatContext *formatContext = avformat_alloc_context();
    formatContext->oformat = outputFormat;

    // find the mpeg1 video encoder
    AVCodec *codec = avcodec_find_encoder(codec_id);

    if (!codec) {
       qDebug() << "codec not found";
       return false;
    }

    qDebug() << "Codec name:" << codec->name;

    AVStream *videoStream = avformat_new_stream(formatContext, codec);
    // put sample parameters
    videoStream->codecpar->bit_rate = 400000;
    videoStream->codecpar->width = width;
    videoStream->codecpar->height = height;
    videoStream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
    videoStream->codecpar->format = AV_PIX_FMT_YUVJ422P;
    videoStream->time_base.num = 1;
    videoStream->time_base.den = 25;

    AVCodecContext *codecContext = avcodec_alloc_context3(nullptr);
    codecContext->codec_id = codec_id;
    codecContext->codec_type = AVMEDIA_TYPE_VIDEO;
    codecContext->width = width;
    codecContext->height = height;
    codecContext->time_base.num = 1;
    codecContext->time_base.den = 25;
    codecContext->pix_fmt = AV_PIX_FMT_YUVJ422P;

    if (int error = avcodec_parameters_to_context(codecContext, videoStream->codecpar)) {
       qDebug() << "Error parameting the context:" << av_make_error_string(errorString, AV_ERROR_MAX_STRING_SIZE, error);
       return false;
    }

    // open it
    if (int error = avcodec_open2(codecContext, codec, nullptr)) {
       qDebug() << "Could not open codec:" << av_make_error_string(errorString, AV_ERROR_MAX_STRING_SIZE, error);
       return false;
    }

    // alloc image and output buffer
    AVFrame *frame = av_frame_alloc();
    frame->format = codecContext->pix_fmt;
    frame->width = codecContext->width;
    frame->height = codecContext->height;

    if (int error = av_image_alloc(frame->data, frame->linesize, frame->width, frame->height, static_cast<enum avpixelformat="avpixelformat">(frame->format), 0)) {
       qDebug() &lt;&lt; "Error allocating image data:" &lt;&lt; av_make_error_string(errorString, AV_ERROR_MAX_STRING_SIZE, error);
       return false;
    }

    // Open the output file, if needed
    if (!(outputFormat->flags &amp; AVFMT_NOFILE)) {
       if (avio_open(&amp;formatContext->pb, fileName.toStdString().c_str(), AVIO_FLAG_WRITE) &lt; 0) {
           qDebug() &lt;&lt; "Could not open" &lt;&lt; fileName;
           return false;
       }
    }

    // some formats want stream headers to be separate
    if (formatContext->oformat->flags &amp; AVFMT_GLOBALHEADER) {
       codecContext->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
    }

    if (int error = avformat_write_header(formatContext, nullptr)) {
       qDebug() &lt;&lt; "error writing header:" &lt;&lt; av_make_error_string(errorString, AV_ERROR_MAX_STRING_SIZE, error);
       return false;
    }
    </enum>

    Unfortunately, when I execute it I have the following output :

    Format Name: mov
    Format Video Codec: 27
    Codec name: mjpeg
    [mov @ 0x1048c7000] Could not find tag for codec none in stream #0, codec not currently supported in container
    error writing header: Invalid argument

    What am I doing wrong ?