Recherche avancée

Médias (1)

Mot : - Tags -/biomaping

Autres articles (79)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • Mediabox : ouvrir les images dans l’espace maximal pour l’utilisateur

    8 février 2011, par

    La visualisation des images est restreinte par la largeur accordée par le design du site (dépendant du thème utilisé). Elles sont donc visibles sous un format réduit. Afin de profiter de l’ensemble de la place disponible sur l’écran de l’utilisateur, il est possible d’ajouter une fonctionnalité d’affichage de l’image dans une boite multimedia apparaissant au dessus du reste du contenu.
    Pour ce faire il est nécessaire d’installer le plugin "Mediabox".
    Configuration de la boite multimédia
    Dès (...)

  • 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

Sur d’autres sites (7367)

  • Video created via shell_exec() does not play, but video created via terminal does

    25 février 2021, par Mukul Kashyap

    I am creating a video from single audio and single image and it is fine when the audio length less than 10 seconds but when the audio length exceeds 10 seconds then video not playing. I am using FFmpeg to create video using shell_exec().
The video is fine when I directly runs the FFmpeg command on the terminal but the only issue comes with the shell_exec command.

    


    This command I am using -

    


    ffmpeg -loop 1 -f image2 -i $this->img_url -i  $this->audio_url -vf scale=1920*1080 -pix_fmt yuv420p -vcodec libx264 -shortest ".$video_local_dir.$video_name;


    


  • Creating video from single long audio and single image then created video not playing

    25 février 2021, par Mukul Kashyap

    I am creating a video from single audio and single image and it is fine when the audio length less than 10 seconds but when the audio length exceeds 10 seconds then video not playing. I am using FFmpeg to create video using shell_exec().
The video is fine when I directly runs the FFmpeg command on the terminal but the only issue comes with the shell_exec command.

    


    This command I am using -

    


    ffmpeg -loop 1 -f image2 -i $this->img_url -i $this->audio_url -vf scale=1920*1080 -pix_fmt yuv420p -vcodec libx264 -shortest ".$video_local_dir.$video_name ;

    


    Please help me to fix this issue

    


    Thanks.

    


  • How to reduce time while writing to output stream

    9 février 2021, par Summit

    I am streaming the render ouput of a opengl application using mpegts.The issue that i am facing is that the time taken to encode the frame is quite long.

    


    The application renders at 60 fps with frame size of 1920 X 1080 , the frame data of the application is pushed to a std::queue.

    


    This is the process for ffmpeg.

    


    I  initialize the stream like this.&#xA;&#xA;   streamerUpd.InitUPD("udp://127.0.0.1:1234", 1920, 1080, rings_);&#xA;&#xA;int StreamUPD::InitUPD(const char* url, int width, int height, std::shared_ptr<ringbuffer2> rings)&#xA;{&#xA;&#xA;    rings_ = rings;&#xA;    width_ = width;&#xA;    height_ = height;&#xA;    filename = url;&#xA;    int ret;&#xA;    av_dict_set(&amp;opt, "pkt_size", "1316", 0);&#xA;    &#xA;        &#xA;    avformat_alloc_output_context2(&amp;oc, nullptr, "mpegts", filename);&#xA;    if (!oc) {&#xA;        return 1;&#xA;    }&#xA;&#xA;    fmt = oc->oformat;&#xA;    /* Add the audio and video streams using the default format codecs&#xA;     * and initialize the codecs. */&#xA;    if (fmt->video_codec != AV_CODEC_ID_NONE) {&#xA;        add_stream(&amp;video_st, oc, &amp;video_codec, fmt->video_codec);&#xA;        have_video = 1;&#xA;        encode_video = 1;&#xA;    }&#xA;&#xA;    /* Write the stream header, if any. */&#xA;    ret = avformat_write_header(oc, &amp;opt);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error occurred when opening output file: %s\n",&#xA;            av_err2str(ret));&#xA;        return 1;&#xA;    }&#xA;    thr = std::thread(&amp;StreamUPD::output_result, this);&#xA;    return 0;&#xA;}&#xA;</ringbuffer2>

    &#xA;

    ////////////////////////////////////////////////////////////////////////////////////////

    &#xA;

    // Add the output stream

    &#xA;

    void StreamUPD::add_stream(OutputStream* ost, AVFormatContext* oc, AVCodec** codec, enum AVCodecID codec_id)&#xA;{&#xA;    AVCodecContext* c;&#xA;    int i;&#xA;    /* find the encoder */&#xA;    *codec = avcodec_find_encoder(codec_id);&#xA;    if (!(*codec)) {&#xA;        fprintf(stderr, "Could not find encoder for &#x27;%s&#x27;\n",&#xA;            avcodec_get_name(codec_id));&#xA;        exit(1);&#xA;    }&#xA;    ost->st = avformat_new_stream(oc, NULL);&#xA;    if (!ost->st) {&#xA;        fprintf(stderr, "Could not allocate stream\n");&#xA;        exit(1);&#xA;    }&#xA;    ost->st->id = oc->nb_streams - 1;&#xA;    c = avcodec_alloc_context3(*codec);&#xA;    if (!c) {&#xA;        fprintf(stderr, "Could not alloc an encoding context\n");&#xA;        exit(1);&#xA;    }&#xA;    ost->enc = c;&#xA;    switch ((*codec)->type) {&#xA;    case AVMEDIA_TYPE_VIDEO:&#xA;        c->codec_id = codec_id;&#xA;        c->bit_rate = 400000;&#xA;&#xA;        /* Resolution must be a multiple of two. */&#xA;        c->width = width_;&#xA;        c->height = height_;&#xA;        /* timebase: This is the fundamental unit of time (in seconds) in terms&#xA;         * of which frame timestamps are represented. For fixed-fps content,&#xA;         * timebase should be 1/framerate and timestamp increments should be&#xA;         * identical to 1. */&#xA;        ost->st->time_base = { 1, STREAM_FRAME_RATE };&#xA;        c->time_base = ost->st->time_base;&#xA;        c->gop_size = 12; /* emit one intra frame every twelve frames at most */&#xA;        c->pix_fmt = STREAM_PIX_FMT;&#xA;        &#xA;        if (c->codec_id == AV_CODEC_ID_MPEG2VIDEO) {&#xA;            /* just for testing, we also add B-frames */&#xA;            qDebug() &lt;&lt; "This is MPEG2VIDEO Frame";&#xA;            c->max_b_frames = 2;&#xA;            &#xA;        }&#xA;        if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {&#xA;            /* Needed to avoid using macroblocks in which some coeffs overflow.&#xA;             * This does not happen with normal video, it just happens here as&#xA;             * the motion of the chroma plane does not match the luma plane. */&#xA;            c->mb_decision = 2;&#xA;        }&#xA;        break;&#xA;    default:&#xA;        break;&#xA;    }&#xA;    /* Some formats want stream headers to be separate. */&#xA;    if (oc->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;        c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;}&#xA;

    &#xA;

    //////////////////////////////////////////////////////////////////////////////////

    &#xA;

    // Open the video

    &#xA;

    void StreamUPD::open_video(AVFormatContext* oc, AVCodec* codec, OutputStream* ost, AVDictionary* opt_arg)&#xA;    {&#xA;        int ret;&#xA;        AVCodecContext* c = ost->enc;&#xA;        AVDictionary* opt = NULL;&#xA;        av_dict_copy(&amp;opt, opt_arg, 0);&#xA;        /* open the codec */&#xA;        ret = avcodec_open2(c, codec, &amp;opt);&#xA;        av_dict_free(&amp;opt);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not open video codec: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        /* allocate and init a re-usable frame */&#xA;        ost->frame = alloc_picture(c->pix_fmt, c->width, c->height);&#xA;        if (!ost->frame) {&#xA;            fprintf(stderr, "Could not allocate video frame\n");&#xA;            exit(1);&#xA;        }&#xA;        /* If the output format is not YUV420P, then a temporary YUV420P&#xA;         * picture is needed too. It is then converted to the required&#xA;         * output format. */&#xA;        ost->tmp_frame = NULL;&#xA;        if (c->pix_fmt != AV_PIX_FMT_YUV420P) {&#xA;            ost->tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c->width, c->height);&#xA;            if (!ost->tmp_frame) {&#xA;                fprintf(stderr, "Could not allocate temporary picture\n");&#xA;                exit(1);&#xA;            }&#xA;        }&#xA;        /* copy the stream parameters to the muxer */&#xA;        ret = avcodec_parameters_from_context(ost->st->codecpar, c);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Could not copy the stream parameters\n");&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;

    &#xA;

    Once i have setup the ffmpeg output stream this is how i am streaming the data.

    &#xA;

    This function gets the frame data from the std::queue(pixelsQueue) and sends it for encoding.

    &#xA;

    int StreamUPD::stream_video_frame()&#xA;{   &#xA;    ost = &amp;video_st;&#xA;    c = ost->enc;   &#xA;&#xA;    /* when we pass a frame to the encoder, it may keep a reference to it&#xA;     * internally; make sure we do not overwrite it here */&#xA;    if (av_frame_make_writable(ost->frame) &lt; 0)&#xA;        exit(1);&#xA;    if (!ost->sws_ctx) {&#xA;        ost->sws_ctx = sws_getContext(c->width, c->height,&#xA;            AV_PIX_FMT_RGB24,&#xA;            c->width, c->height,&#xA;            c->pix_fmt,&#xA;            SWS_FAST_BILINEAR, NULL, NULL, NULL);&#xA;        if (!ost->sws_ctx) {&#xA;            fprintf(stderr,&#xA;                "Could not initialize the conversion context\n");&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;    finished_ = true;&#xA;&#xA;    if (pixelsQueue.size() > 0) {       &#xA;        if (pixelsQueue.pop(pixels)) {&#xA;            fill_yuv_image(ost->sws_ctx, frame_data->pixels_.get(), ost->frame, c->width, c->height);&#xA;            ost->frame->pts = ost->next_pts&#x2B;&#x2B;;&#xA;            return write_frame(oc, ost->enc, ost->st, ost->frame);&#xA;        }&#xA;    }&#xA;    return 1;&#xA;}&#xA;

    &#xA;

    Writing the data to the output stream.

    &#xA;

    The function avcodec_receive_packet is the one that takes lot of time.

    &#xA;

    int StreamUPD::write_frame(AVFormatContext* fmt_ctx, AVCodecContext* c,&#xA;    AVStream* st, AVFrame* frame)&#xA;{&#xA;    int ret;&#xA;    // send the frame to the encoder&#xA;    AVPacket pkt = { 0 };&#xA;    ret = avcodec_send_frame(c, frame);&#xA;    ret = avcodec_receive_packet(c, &amp;pkt);&#xA;    if (ret &lt; 0) {&#xA;        fprintf(stderr, "Error sending a frame to the encoder: %s\n",&#xA;            av_err2str(ret));&#xA;        exit(1);&#xA;    }&#xA;    &#xA;    while (ret >= 0) {&#xA;        AVPacket pkt = { 0 };&#xA;        ret = avcodec_receive_packet(c, &amp;pkt);  // This is the function that takes lot of time&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;            break;&#xA;        else if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error encoding a frame: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;        // rescale output packet timestamp values from codec to stream timebase &#xA;        av_packet_rescale_ts(&amp;pkt, c->time_base, st->time_base);&#xA;        pkt.stream_index = st->index;&#xA;        // Write the compressed frame to the media file. &#xA;        ret = av_interleaved_write_frame(fmt_ctx, &amp;pkt);&#xA;        av_packet_unref(&amp;pkt);&#xA;        if (ret &lt; 0) {&#xA;            fprintf(stderr, "Error while writing output packet: %s\n", av_err2str(ret));&#xA;            exit(1);&#xA;        }&#xA;    }&#xA;    return ret == AVERROR_EOF ? 1 : 0;&#xA;}&#xA;

    &#xA;

    How can i reduce the outputting time while writing the frames to the stream ?

    &#xA;

    Currently i push more frames in the buffer and the outputting speed is less so the buffer starts to run out of memory in some time.

    &#xA;