Recherche avancée

Médias (1)

Mot : - Tags -/iphone

Autres articles (41)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Contribute to a better visual interface

    13 avril 2011

    MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
    Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community.

  • Submit enhancements and plugins

    13 avril 2011

    If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
    You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.

Sur d’autres sites (8845)

  • Problems to read frame using FFMPEG to OpenCV Mat

    28 décembre 2022, par Alex

    I'm trying to read all frames from a video using FFMPEG library in C++, but I have got this exception :

    


    Assertion desc failed at libswscale/swscale_internal.h:727


    


    The code that I'm using is follow :

    


    #include <iostream>&#xA;#include <string>&#xA;#include <vector>&#xA;&#xA;extern "C" {&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;}&#xA;&#xA;&#xA;#include <opencv2></opencv2>opencv.hpp>&#xA;&#xA;// helper function to check for FFmpeg errors&#xA;inline void checkError(int error, const std::string &amp;message) {&#xA;    if (error &lt; 0) {&#xA;        std::cerr &lt;&lt; message &lt;&lt; ": " &lt;&lt; av_err2str(error) &lt;&lt; std::endl;&#xA;        exit(EXIT_FAILURE);&#xA;    }&#xA;}&#xA;&#xA;int main() {&#xA;    // initialize FFmpeg&#xA;    av_log_set_level(AV_LOG_ERROR);&#xA;    avformat_network_init();&#xA;&#xA;    // open the input file&#xA;    std::string fileName = "input.mp4";&#xA;    AVFormatContext *formatContext = nullptr;&#xA;    int error = avformat_open_input(&amp;formatContext, fileName.c_str(), nullptr, nullptr);&#xA;    checkError(error, "Error opening input file");&#xA;&#xA;    // find the video stream&#xA;    AVStream *videoStream = nullptr;&#xA;    for (unsigned int i = 0; i &lt; formatContext->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &amp;&amp; !videoStream) {&#xA;            videoStream = formatContext->streams[i];&#xA;        }&#xA;    }&#xA;    if (!videoStream) {&#xA;        std::cerr &lt;&lt; "Error: input file does not contain a video stream" &lt;&lt; std::endl;&#xA;        exit(EXIT_FAILURE);&#xA;    }&#xA;&#xA;    // create the video codec context&#xA;    const AVCodec *videoCodec = avcodec_find_decoder(videoStream->codecpar->codec_id);&#xA;    AVCodecContext *videoCodecContext = avcodec_alloc_context3(videoCodec);&#xA;    if (!videoCodecContext) {&#xA;        std::cerr &lt;&lt; "Error allocating video codec context" &lt;&lt; std::endl;&#xA;        exit(EXIT_FAILURE);&#xA;    }&#xA;    error = avcodec_parameters_to_context(videoCodecContext, videoStream->codecpar);&#xA;    checkError(error, "Error setting video codec context parameters");&#xA;    error = avcodec_open2(videoCodecContext, videoCodec, nullptr);&#xA;    checkError(error, "Error opening video codec");&#xA;&#xA;    // create the frame scaler&#xA;        int width = videoCodecContext->width;&#xA;    int height = videoCodecContext->height;&#xA;    struct SwsContext *frameScaler = sws_getContext(width, height, videoCodecContext->pix_fmt, width, height, AV_PIX_FMT_BGR24, SWS_BICUBIC, nullptr, nullptr, nullptr);&#xA;&#xA;    // read the packets and decode the video frames&#xA;    std::vector videoFrames;&#xA;    AVPacket packet;&#xA;    while (av_read_frame(formatContext, &amp;packet) == 0) {&#xA;        if (packet.stream_index == videoStream->index) {&#xA;            // decode the video frame&#xA;            AVFrame *frame = av_frame_alloc();&#xA;            int gotFrame = 0;&#xA;            error = avcodec_send_packet(videoCodecContext, &amp;packet);&#xA;            checkError(error, "Error sending packet to video codec");&#xA;            error = avcodec_receive_frame(videoCodecContext, frame);&#xA;            checkError(error, "Error receiving frame from video codec");&#xA;            if (error == 0) {&#xA;                gotFrame = 1;&#xA;            }&#xA;            if (gotFrame) {&#xA;                // scale the frame to the desired format&#xA;                AVFrame *scaledFrame = av_frame_alloc();&#xA;                av_image_alloc(scaledFrame->data, scaledFrame->linesize, width, height, AV_PIX_FMT_BGR24, 32);&#xA;                sws_scale(frameScaler, frame->data, frame->linesize, 0, height, scaledFrame->data, scaledFrame->linesize);&#xA;&#xA;                // copy the frame data to a cv::Mat object&#xA;                cv::Mat mat(height, width, CV_8UC3, scaledFrame->data[0], scaledFrame->linesize[0]);&#xA;                videoFrames.push_back(mat.clone());&#xA;&#xA;                // clean up&#xA;                av_freep(&amp;scaledFrame->data[0]);&#xA;                av_frame_free(&amp;scaledFrame);&#xA;            }&#xA;            av_frame_free(&amp;frame);&#xA;        }&#xA;        av_packet_unref(&amp;packet);&#xA;    }&#xA;&#xA;    // clean up&#xA;    sws_freeContext(frameScaler);&#xA;    avcodec_free_context(&amp;videoCodecContext);&#xA;    avformat_close_input(&amp;formatContext);&#xA;&#xA;    return 0;&#xA;}&#xA;</vector></string></iostream>

    &#xA;

    The line that GDB says that occur the exception is this :

    &#xA;

    struct SwsContext *frameScaler = sws_getContext(width, height, videoCodecContext->pix_fmt, width, height, AV_PIX_FMT_BGR24, SWS_BICUBIC, nullptr, nullptr, nullptr);&#xA;

    &#xA;

  • How to extract frame types along with motion vectors using extract_mvs.c from ffmpeg

    26 février 2018, par helmo

    I have been researching ways to get frame types (I, P, B) along with the motion vector data returned from extract_mvs.c in the examples folder in ffmpeg.

    The extract_mvs.c file after it is compiled, returns information like this :

    framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags
    2,-1,16,16,   8,   8,   8,   8,0x0
    2, 1,16,16,   8,   8,   8,   8,0x0
    2, 1,16,16,  24,   8,  24,   8,0x0
    2, 1,16,16,  40,   8,  40,   8,0x0
    2, 1,16,16,  56,   8,  56,   8,0x0
    2, 1,16,16,  72,   8,  72,   8,0x0
    2, 1,16,16,  88,   8,  88,   8,0x0
    ...
    297, 1,16,16, 248, 280, 248, 280,0x0
    297, 1,16,16, 264, 280, 264, 280,0x0
    297,-1,16,16, 278, 279, 280, 280,0x0
    297, 1,16,16, 280, 280, 280, 280,0x0
    297, 1,16,16, 296, 280, 296, 280,0x0
    297, 1,16,16, 312, 280, 312, 280,0x0
    297, 1,16,16, 328, 280, 328, 280,0x0
    297, 1,16,16, 344, 280, 344, 280,0x0

    Along with this information, I would like to output frame type so that I know framenum = 2 is, for example, a ’B’ frame.

    I tried different things, one of which was using a separate command :

    ffprobe input.mp4 -show_frames | grep -E 'pict_type|coded_picture_number'

    But the problem with this command is that it returns data like :

    pict_type=I
    coded_picture_number=0
    pict_type=B
    coded_picture_number=2
    pict_type=P
    coded_picture_number=1
    pict_type=B
    coded_picture_number=4
    pict_type=P
    coded_picture_number=3
    ....
    pict_type=P
    coded_picture_number=293
    pict_type=B
    coded_picture_number=297
    pict_type=B
    coded_picture_number=296

    And there is no much I can relate here between coded_picture_number and framenum. The former starts counting from 0 and the later from 2. I assume framenum starting from 2, means the count from this variable is actually from 1, and it ignored 1 in the extraction process as it is maybe an I frame thus no motion vectors.

    So, how can we use only extract_mvs.c to get not only that information it provides but also the frame types in the returned table. Any hints either syntax/command-wise or in editing the c file would be appreciated. Thanks in advance.

  • Merge commit ’72cebae0d981dde144340cf51f3c323f01e215e5’

    31 mai 2015, par Michael Niedermayer
    Merge commit ’72cebae0d981dde144340cf51f3c323f01e215e5’
    

    * commit ’72cebae0d981dde144340cf51f3c323f01e215e5’ :
    ppc : avutil : Use the abriged vector types

    Conflicts :
    libavutil/ppc/float_dsp_altivec.c
    libavutil/ppc/util_altivec.h

    Merged-by : Michael Niedermayer <michaelni@gmx.at>

    • [DH] libavutil/ppc/float_dsp_altivec.c
    • [DH] libavutil/ppc/util_altivec.h