Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (106)

  • Création définitive du canal

    12 mars 2010, par

    Lorsque votre demande est validée, vous pouvez alors procéder à la création proprement dite du canal. Chaque canal est un site à part entière placé sous votre responsabilité. Les administrateurs de la plateforme n’y ont aucun accès.
    A la validation, vous recevez un email vous invitant donc à créer votre canal.
    Pour ce faire il vous suffit de vous rendre à son adresse, dans notre exemple "http://votre_sous_domaine.mediaspip.net".
    A ce moment là un mot de passe vous est demandé, il vous suffit d’y (...)

  • Mise à disposition des fichiers

    14 avril 2011, par

    Par défaut, lors de son initialisation, MediaSPIP ne permet pas aux visiteurs de télécharger les fichiers qu’ils soient originaux ou le résultat de leur transformation ou encodage. Il permet uniquement de les visualiser.
    Cependant, il est possible et facile d’autoriser les visiteurs à avoir accès à ces documents et ce sous différentes formes.
    Tout cela se passe dans la page de configuration du squelette. Il vous faut aller dans l’espace d’administration du canal, et choisir dans la navigation (...)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

Sur d’autres sites (13541)

  • Deprecation error when using imageio.ffmpeg.download()

    29 novembre 2022, par SHASHIKUMAR B J

    I'm trying to merge the prerecorded videos using python Opencv.
But i'm getting the error while importing.

    



    "Traceback (most recent call last):&#xA;  File "video.py", line 4, in <module>&#xA;    from moviepy. editor import VideoFileClip,concatenate_videoclips &#xA;  File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/moviepy/editor.py", line 26, in <module>&#xA;    imageio.plugins.ffmpeg.download()&#xA;  File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/imageio/plugins/ffmpeg.py", line 40, in download&#xA;    "imageio.ffmpeg.download() has been deprecated. "&#xA;RuntimeError: imageio.ffmpeg.download() has been deprecated. Use &#x27;pip install imageio-ffmpeg&#x27; instead.&#x27;"&#xA;</module></module>

    &#xA;&#xA;

    would anyone please help to get out of this problem

    &#xA;&#xA;

    Here is the code :

    &#xA;&#xA;

    import cv2 &#xA;import os &#xA;import time &#xA;from moviepy.editor import VideoFileClip,concatenate_videoclips &#xA;def vidcapt():&#xA;    a = time.strftime("%H,%M,%S")&#xA;    cap = cv2.VideoCapture(0)&#xA;    fourcc = cv2.VideoWriter_fourcc(*&#x27;XVID&#x27;)&#xA;    out = cv2.VideoWriter(a&#x2B;&#x27;.avi&#x27;, fourcc, 24.0, (640,480))&#xA;    t1 = time.time()&#xA;    while(cap.isOpened()):&#xA;            ret, frame = cap.read() &#xA;            if ret == True:&#xA;                    out.write(frame)&#xA;                    cv2.imshow(&#x27;frame&#x27;,frame)&#xA;                    t2 = time.time()&#xA;                    time_diff = t2-t1&#xA;                    if time_diff >= 5:&#xA;                            break&#xA;            else:&#xA;                    break&#xA;    cap.release()&#xA;    out.release()&#xA;    cv2.destroyAllWindows()&#xA;&#xA;while True:&#xA;        vidcapt()&#xA;&#xA;&#xA;clip1 = VideoFileClip("11,05,42.avi")&#xA;clip2 = VideoFileClip("11,05,47.avi").subclip(50,60)&#xA;final_clip = concatenate_videoclips([clip1,clip2])&#xA;final_clip.write_videofile("merged.avi")&#xA;

    &#xA;

  • ffmpeg and Intel Quick Sync Video

    13 mars 2018, par Maxim

    i’m trying to use Intel Quick Sync Video, but have an acces violation when do av_hwdevice_ctx_create() with type == AV_HWDEVICE_TYPE_QSV. It work if i use AV_HWDEVICE_TYPE_D3D11VA for example, without any problems. I dont know what to do. Can anybody help me ? I’m use example from ffmpeg, but modified it a little bit :

    #include
    extern "C" {
    #include <libavcodec></libavcodec>avcodec.h>
    #include <libavformat></libavformat>avformat.h>
    #include <libavutil></libavutil>pixdesc.h>
    #include <libavutil></libavutil>hwcontext.h>
    #include <libavutil></libavutil>opt.h>
    #include <libavutil></libavutil>avassert.h>
    #include <libavutil></libavutil>imgutils.h>
    }

    static AVBufferRef *hw_device_ctx = NULL;
    static enum AVPixelFormat hw_pix_fmt;
    static FILE *output_file = NULL;

    static enum AVPixelFormat find_fmt_by_hw_type(const enum AVHWDeviceType type)
    {
       enum AVPixelFormat fmt;

       switch (type) {
       case AV_HWDEVICE_TYPE_VAAPI:
           fmt = AV_PIX_FMT_VAAPI;
           break;
       case AV_HWDEVICE_TYPE_DXVA2:
           fmt = AV_PIX_FMT_DXVA2_VLD;
           break;
       case AV_HWDEVICE_TYPE_D3D11VA:
           fmt = AV_PIX_FMT_D3D11;
           break;
       case AV_HWDEVICE_TYPE_VDPAU:
           fmt = AV_PIX_FMT_VDPAU;
           break;
       case AV_HWDEVICE_TYPE_VIDEOTOOLBOX:
           fmt = AV_PIX_FMT_VIDEOTOOLBOX;
           break;
       case AV_HWDEVICE_TYPE_QSV://thise i added by myself
           fmt = AV_PIX_FMT_QSV;
           break;
       default:
           fmt = AV_PIX_FMT_NONE;
           break;
       }

       return fmt;
    }

    static int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type)
    {
       int err = 0;

       if ((err = av_hwdevice_ctx_create(&amp;hw_device_ctx, type,
           NULL, NULL, 0)) &lt; 0) {
           fprintf(stderr, "Failed to create specified HW device.\n");
           return err;
       }
       ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);

       return err;
    }

    static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
       const enum AVPixelFormat *pix_fmts)
    {
       const enum AVPixelFormat *p;

       for (p = pix_fmts; *p != -1; p++) {
           if (*p == hw_pix_fmt)
               return *p;
       }

       fprintf(stderr, "Failed to get HW surface format.\n");
       return AV_PIX_FMT_NONE;
    }

    static int decode_write(AVCodecContext *avctx, AVPacket *packet)
    {
       AVFrame *frame = NULL, *sw_frame = NULL;
       AVFrame *tmp_frame = NULL;
       uint8_t *buffer = NULL;
       int size;
       int ret = 0;

       ret = avcodec_send_packet(avctx, packet);
       if (ret &lt; 0) {
           fprintf(stderr, "Error during decoding\n");
           return ret;
       }

       while (ret >= 0) {
           if (!(frame = av_frame_alloc()) || !(sw_frame = av_frame_alloc())) {
               fprintf(stderr, "Can not alloc frame\n");
               ret = AVERROR(ENOMEM);
               goto fail;
           }

           ret = avcodec_receive_frame(avctx, frame);
           if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
               av_frame_free(&amp;frame);
               av_frame_free(&amp;sw_frame);
               return 0;
           }
           else if (ret &lt; 0) {
               fprintf(stderr, "Error while decoding\n");
               goto fail;
           }

           if (frame->format == hw_pix_fmt) {
               /* retrieve data from GPU to CPU */
               if ((ret = av_hwframe_transfer_data(sw_frame, frame, 0)) &lt; 0) {
                   fprintf(stderr, "Error transferring the data to system memory\n");
                   goto fail;
               }
               tmp_frame = sw_frame;
           }
           else
               tmp_frame = frame;

           size = av_image_get_buffer_size((AVPixelFormat)tmp_frame->format, tmp_frame->width,
               tmp_frame->height, 1);
           buffer = (uint8_t*)av_malloc(size);
           if (!buffer) {
               fprintf(stderr, "Can not alloc buffer\n");
               ret = AVERROR(ENOMEM);
               goto fail;
           }
           ret = av_image_copy_to_buffer(buffer, size,
               (const uint8_t * const *)tmp_frame->data,
               (const int *)tmp_frame->linesize, (AVPixelFormat)tmp_frame->format,
               tmp_frame->width, tmp_frame->height, 1);
           if (ret &lt; 0) {
               fprintf(stderr, "Can not copy image to buffer\n");
               goto fail;
           }

           if ((ret = fwrite(buffer, 1, size, output_file)) &lt; 0) {
               fprintf(stderr, "Failed to dump raw data.\n");
               goto fail;
           }

       fail:
           av_frame_free(&amp;frame);
           av_frame_free(&amp;sw_frame);
           if (buffer)
               av_freep(&amp;buffer);
           if (ret &lt; 0)
               return ret;
       }

       return 0;
    }

    int main(int argc, char *argv[])
    {
       AVFormatContext *input_ctx = NULL;
       int video_stream, ret;
       AVStream *video = NULL;
       AVCodecContext *decoder_ctx = NULL;
       AVCodec *decoder = NULL;
       AVPacket packet;
       enum AVHWDeviceType type;

       if (argc &lt; 4) {
           fprintf(stderr, "Usage: %s  <input file="file" /> <output file="file">\n", argv[0]);
           return -1;
       }

       av_register_all();

       type = av_hwdevice_find_type_by_name(argv[1]);
       hw_pix_fmt = find_fmt_by_hw_type(type);
       if (hw_pix_fmt == -1) {
           fprintf(stderr, "Cannot support '%s' in this example.\n", argv[1]);
           return -1;
       }

       /* open the input file */
       if (avformat_open_input(&amp;input_ctx, argv[2], NULL, NULL) != 0) {
           fprintf(stderr, "Cannot open input file '%s'\n", argv[2]);
           return -1;
       }

       if (avformat_find_stream_info(input_ctx, NULL) &lt; 0) {
           fprintf(stderr, "Cannot find input stream information.\n");
           return -1;
       }

       /* find the video stream information */
       ret = av_find_best_stream(input_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &amp;decoder, 0);
       if (ret &lt; 0) {
           fprintf(stderr, "Cannot find a video stream in the input file\n");
           return -1;
       }
       video_stream = ret;

       if (!(decoder_ctx = avcodec_alloc_context3(decoder)))
           return AVERROR(ENOMEM);

       video = input_ctx->streams[video_stream];
       if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) &lt; 0)
           return -1;

       decoder_ctx->get_format = get_hw_format;
       av_opt_set_int(decoder_ctx, "refcounted_frames", 1, 0);

       if (hw_decoder_init(decoder_ctx, type) &lt; 0)
           return -1;

       if ((ret = avcodec_open2(decoder_ctx, decoder, NULL)) &lt; 0) {
           fprintf(stderr, "Failed to open codec for stream #%u\n", video_stream);
           return -1;
       }

       /* open the file to dump raw data */
       output_file = fopen(argv[3], "w+");

       /* actual decoding and dump the raw data */
       while (ret >= 0) {
           if ((ret = av_read_frame(input_ctx, &amp;packet)) &lt; 0)
               break;

           if (video_stream == packet.stream_index)
               ret = decode_write(decoder_ctx, &amp;packet);

           av_packet_unref(&amp;packet);
       }

       /* flush the decoder */
       packet.data = NULL;
       packet.size = 0;
       ret = decode_write(decoder_ctx, &amp;packet);
       av_packet_unref(&amp;packet);

       if (output_file)
           fclose(output_file);
       avcodec_free_context(&amp;decoder_ctx);
       avformat_close_input(&amp;input_ctx);
       av_buffer_unref(&amp;hw_device_ctx);

       return 0;
    }
    </output>
  • FFmpeg API : problem with framerate while encoding video

    21 mars 2021, par locust

    I was trying to create C++ program for cutting out specified part of a video. And it works to some extent, but the output video seems to have completely wrong framerate, because even though the cut part in original file is 3 sec long, the output is sped up to less than a second. I don't really know which parameter gives me such an outcome. I appreciate any idea.

    &#xA;

    Source code (fixed with av_packet_rescale_ts) :

    &#xA;

    AVStream* outStream = NULL;&#xA;bool initialized = false;&#xA;&#xA;while (av_read_frame(inFormatContext, &amp;inPacket) >= 0) {&#xA;    if (inPacket.stream_index == inVideoStreamIndex) {&#xA;        int ret;&#xA;        ret = avcodec_send_packet(decoderContext, &amp;inPacket);&#xA;        if (ret &lt; 0) {&#xA;            //error&#xA;        }&#xA;&#xA;        while (ret >= 0) {&#xA;            if (!(frame = av_frame_alloc()))&#xA;                return AVERROR(ENOMEM);&#xA;            ret = avcodec_receive_frame(decoderContext, frame);         &#xA;            frame->pts = av_frame_get_best_effort_timestamp(frame);&#xA;&#xA;            if (!initialized) {&#xA;                encoderContext->time_base = decoderContext->time_base;&#xA;                encoderContext->framerate = decoderContext->framerate;&#xA;&#xA;                if ((ret = avcodec_open2(encoderContext, inEncoder, NULL)) &lt; 0) {&#xA;                    //error&#xA;                }&#xA;&#xA;                if (!(outStream = avformat_new_stream(outFormatContext, inEncoder))) {&#xA;                    //error&#xA;                }&#xA;&#xA;                outStream->time_base = encoderContext->time_base;&#xA;                ret = avcodec_parameters_from_context(outStream->codecpar, encoderContext);&#xA;                if (ret &lt; 0) {&#xA;                    //error&#xA;                }&#xA;&#xA;                if ((ret = avformat_write_header(outFormatContext, NULL)) &lt; 0) {&#xA;                    //error&#xA;                }&#xA;&#xA;                initialized = true;&#xA;            }&#xA;&#xA;            if (frame->pts >= starttime_int64 &amp;&amp; frame->pts &lt;= endtime_int64) {&#xA;                AVPacket enc_pkt;&#xA;&#xA;                av_init_packet(&amp;enc_pkt);&#xA;                enc_pkt.data = NULL;&#xA;                enc_pkt.size = 0;&#xA;&#xA;                if ((ret = avcodec_send_frame(encoderContext, frame)) &lt; 0) {&#xA;                    //error&#xA;                }&#xA;                while (1) {&#xA;                    ret = avcodec_receive_packet(encoderContext, &amp;enc_pkt);&#xA;                    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                        break;&#xA;                    }&#xA;                    else if (ret &lt; 0) {&#xA;                        //error&#xA;                    }&#xA;&#xA;                    av_packet_rescale_ts(&amp;enc_pkt, inVideoStream->time_base, outFormatContext->streams[inVideoStreamIndex]->time_base);      // This one fixed the issue&#xA;&#xA;                    if (av_write_frame(outFormatContext, &amp;enc_pkt) != 0) {&#xA;                        //error&#xA;                    }&#xA;                }&#xA;                av_packet_unref(&amp;enc_pkt);&#xA;            }&#xA;        }&#xA;&#xA;        if (frame->pts > endtime_int64) {&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;