Recherche avancée

Médias (91)

Autres articles (96)

  • 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 (...)

  • 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.

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (11220)

  • lavf/matroskaenc.c : add early support for colour elements

    7 mars 2016, par Neil Birkbeck
    lavf/matroskaenc.c : add early support for colour elements
    

    Adding early support for a subset of the proposed colour elements
    according to the latest version of spec :
    https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&index=hIKLhMdgTMTEwUTeA4ct38h0tmE

    Like matroskadec, I’ve left out elements for pix_fmt related things
    as there still seems to be some discussion around these.

    The new elements are exposed under strict experimental mode.

    Signed-off-by : Neil Birkbeck <neil.birkbeck@gmail.com>
    Signed-off-by : Michael Niedermayer <michael@niedermayer.cc>

    • [DH] libavformat/matroskaenc.c
  • Revision 96b6b6bbf0 : add auto keyframe unit test To do so we add a framework for encoding a yv12 fil

    23 juin 2012, par Jim Bankoski

    Changed Paths : Modify /test/encode_test_driver.cc Add /test/i420_video_source.h Modify /test/keyframe_test.cc Add /test/test-data.sha1 Modify /test/test.mk add auto keyframe unit test To do so we add a framework for encoding a yv12 file.. Change-Id : (...)

  • FFMpeg gpl (ffmpeg-4.2.1-win64-dev_and_shared) version give different decode result (cmd query vs code)

    31 mai 2021, par Aleksey Timoshchenko

    *all the source img I put on my google drive due to SO restrictions (just click on links provided in the text)

    &#xA;

    The problem is that for .h264 I use two implementations (cmd query and code) (depends on the tasks) that give me different results and I don't see any reason for this.

    &#xA;

    Before all I would like to give an explanation, I have .bmp bayer image, then I do debayering and compress it to .h264 (compress .h264) with the script

    &#xA;

    ffmpeg -y -hide_banner -i orig_bayer.bmp -vf format=gray -f rawvideo pipe: | ffmpeg -hide_banner -y -framerate 30 -f rawvideo -pixel_format bayer_rggb8 -video_size 4096x3000 -i pipe: -c:v hevc_nvenc -qp 0 -pix_fmt yuv444p res.h264&#xA;

    &#xA;


    &#xA;

    Then the first cmd query implementation of decoding (image result)

    &#xA;

    ffmpeg -y -i res.h264 -vframes 1 -f image2 gpl_script_res.bmp -hide_banner&#xA;

    &#xA;


    &#xA;

    The second implementation is code one and takes more lines (image result here)

    &#xA;

    Init ffmpeg

    &#xA;

    bool FFmpegDecoder::InitFFmpeg()&#xA;{&#xA;    m_pAVPkt = av_packet_alloc();&#xA;    m_pAVFrame = av_frame_alloc();&#xA;    m_pAVFrameRGB = av_frame_alloc();&#xA;&#xA;    m_pAVFormatCtx = avformat_alloc_context();&#xA;    m_pIoCtx->initAVFormatContext(m_pAVFormatCtx);&#xA;&#xA;    if (avformat_open_input(&amp;m_pAVFormatCtx, "", nullptr, nullptr) != 0)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avformat_open_input\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    if (avformat_find_stream_info(m_pAVFormatCtx, nullptr) &lt; 0)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avformat_find_stream_info\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    //av_dump_format(ctx_format, 0, "", false);&#xA;    for (int i = 0; i &lt; (int)m_pAVFormatCtx->nb_streams; i&#x2B;&#x2B;)&#xA;    {&#xA;        if (m_pAVFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)&#xA;        {&#xA;            m_streamIdx = i;&#xA;            m_pAVStream = m_pAVFormatCtx->streams[i];&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (m_pAVStream == nullptr)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: failed to find video stream\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_pAVCodec = avcodec_find_decoder(m_pAVStream->codecpar->codec_id);&#xA;    if (!m_pAVCodec)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avcodec_find_decoder\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_pAVCodecCtx = avcodec_alloc_context3(m_pAVCodec);&#xA;    if (!m_pAVCodecCtx)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avcodec_alloc_context3\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    if (avcodec_parameters_to_context(m_pAVCodecCtx, m_pAVStream->codecpar) &lt; 0)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avcodec_parameters_to_context\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    if (avcodec_open2(m_pAVCodecCtx, m_pAVCodec, nullptr) &lt; 0)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in avcodec_open2\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_pAVFrameRGB->format = AV_PIX_FMT_BGR24;&#xA;    m_pAVFrameRGB->width = m_pAVCodecCtx->width;&#xA;    m_pAVFrameRGB->height = m_pAVCodecCtx->height;&#xA;    if (av_frame_get_buffer(m_pAVFrameRGB, 32) != 0)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in av_frame_get_buffer\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_streamRotationDegrees = GetAVStreamRotation(m_pAVStream);&#xA;    m_estimatedFramesCount = 0;&#xA;    assert(m_pAVFormatCtx->nb_streams > 0);&#xA;    if (m_pAVFormatCtx->nb_streams > 0)&#xA;    {&#xA;        m_estimatedFramesCount = m_pAVFormatCtx->streams[0]->nb_frames;&#xA;    }&#xA;&#xA;    return InitConvertColorSpace(); &#xA;}&#xA;&#xA;bool FFmpegDecoder::InitConvertColorSpace()&#xA;{&#xA;    // Init converter from YUV420p to BGR:&#xA;    m_pSwsCtxConvertImg = sws_getContext(m_pAVCodecCtx->width, m_pAVCodecCtx->height, m_pAVCodecCtx->pix_fmt, m_pAVCodecCtx->width, m_pAVCodecCtx->height, AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);&#xA;    if (!m_pSwsCtxConvertImg)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in sws_getContext\n");&#xA;        return false;&#xA;    }&#xA;    return true;&#xA;}&#xA;

    &#xA;

    Decoding impl

    &#xA;

    bool FFmpegDecoder::DecodeContinue(int firstFrameIdx, int maxNumFrames)&#xA;{&#xA;    if (firstFrameIdx == FIRST_FRAME_IDX_BEGINNING)&#xA;    {&#xA;        firstFrameIdx = 0;&#xA;    }&#xA;&#xA;    auto lastReportedFrameIdxTillNow = GetLastReportedFrameIdx();&#xA;&#xA;    if (GetLastDecodedFrameIdx() >= 0 &amp;&amp; firstFrameIdx &lt;= GetLastDecodedFrameIdx())&#xA;    {&#xA;        printf("FFmpegDecoder::DecodeContinue FAILED: firstFrameIdx (%d) already passed decoded (Last decoded idx: %d)\n", firstFrameIdx, GetLastDecodedFrameIdx());&#xA;        return false;&#xA;    }&#xA;&#xA;    bool bRes;&#xA;    int nRet = 0;&#xA;    bool bDecodeShouldEnd = false;&#xA;&#xA;    if (m_pAVPkt != nullptr)&#xA;    {&#xA;        while (nRet >= 0)&#xA;        {&#xA;            m_bCurrentAVPktSentToCodec = false;&#xA;            nRet = av_read_frame(m_pAVFormatCtx, m_pAVPkt);&#xA;            if (nRet &lt; 0)&#xA;            {&#xA;                break;&#xA;            }&#xA;            if (m_pAVPkt->stream_index == m_streamIdx)&#xA;            {&#xA;                bRes = DecodeCurrentAVPkt(firstFrameIdx, maxNumFrames, bDecodeShouldEnd);&#xA;                if (!bRes || m_bRequestedAbort)&#xA;                {&#xA;                    av_packet_unref(m_pAVPkt);&#xA;                    return false;&#xA;                }&#xA;&#xA;                if (bDecodeShouldEnd)&#xA;                {&#xA;                    av_packet_unref(m_pAVPkt);&#xA;                    return true;&#xA;                }&#xA;            }&#xA;&#xA;            av_packet_unref(m_pAVPkt);&#xA;        }&#xA;        m_bCurrentAVPktSentToCodec = false;&#xA;        m_pAVPkt = nullptr;&#xA;    }&#xA;&#xA;    // drain:&#xA;    bRes = DecodeCurrentAVPkt(firstFrameIdx, maxNumFrames, bDecodeShouldEnd);&#xA;    if (!bRes)&#xA;    {&#xA;        return false;&#xA;    }&#xA;&#xA;    if (lastReportedFrameIdxTillNow == GetLastReportedFrameIdx())&#xA;    {&#xA;        printf("FFmpegDecoder::DecodeContinue(firstFrameIdx==%d, maxNumFrames==%d) FAILED: no new frame was decoded\n", firstFrameIdx, maxNumFrames);&#xA;        return false;&#xA;    }&#xA;&#xA;    return true;&#xA;}&#xA;&#xA;&#xA;bool FFmpegDecoder::DecodeCurrentAVPkt(int firstFrameIdx, int maxNumFrames, bool &amp; bDecodeShouldEnd)&#xA;{&#xA;    bDecodeShouldEnd = false;&#xA;&#xA;    int ret = 0;&#xA;    if (m_bCurrentAVPktSentToCodec == false)&#xA;    {&#xA;        ret = avcodec_send_packet(m_pAVCodecCtx, m_pAVPkt);&#xA;        m_bCurrentAVPktSentToCodec = true;&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;        {&#xA;            printf("FFmpegDecoder::DecodeFrameImp: error EAGAIN/AVERROR_EOF in avcodec_send_packet\n");&#xA;            return false;&#xA;        }&#xA;        if (ret &lt; 0)&#xA;        {&#xA;            if (ret == AVERROR_INVALIDDATA)&#xA;            {&#xA;                printf("FFmpegDecoder::DecodeFrameImp: error (%d - AVERROR_INVALIDDATA) in avcodec_send_packet\n", ret);&#xA;            }&#xA;            else&#xA;            {&#xA;                printf("FFmpegDecoder::DecodeFrameImp: error (%d) in avcodec_send_packet\n", ret);&#xA;            }&#xA;            return false;&#xA;        }&#xA;    }&#xA;&#xA;    ret = 0;&#xA;    while (ret >= 0)&#xA;    {&#xA;        ret = avcodec_receive_frame(m_pAVCodecCtx, m_pAVFrame);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;        {&#xA;            break;&#xA;        }&#xA;&#xA;        IncrementLastDecodedFrameIdx();&#xA;        if (GetLastDecodedFrameIdx() &lt; firstFrameIdx)&#xA;        {&#xA;            printf("FFmpegDecoder::DecodeCurrentAVPkt ignoring frame idx %d\n", GetLastDecodedFrameIdx());&#xA;            continue;   // we don&#x27;t need this frame&#xA;        }&#xA;&#xA;        AVFrame * theFrame = m_pAVFrame;    // default&#xA;&#xA;        for (int j = 0; j &lt; m_pAVFrame->nb_side_data; j&#x2B;&#x2B;)&#xA;        {&#xA;            AVFrameSideData *sd = m_pAVFrame->side_data[j];&#xA;            if (sd->type == AV_FRAME_DATA_DISPLAYMATRIX) {&#xA;                auto ddd = av_display_rotation_get((int32_t *)sd->data);&#xA;            }&#xA;        }&#xA;&#xA;        if (m_pSwsCtxConvertImg != nullptr)&#xA;        {&#xA;            {&#xA;                if (sws_scale(m_pSwsCtxConvertImg, theFrame->data, theFrame->linesize, 0, theFrame->height, m_pAVFrameRGB->data, m_pAVFrameRGB->linesize) == 0)&#xA;                {&#xA;                    printf("FFmpegDecoder::DecodeFrameImp: error in sws_scale\n");&#xA;                    return false;&#xA;                }&#xA;            }&#xA;            int numChannels = 3;&#xA;            FFmpegDecoderCallback::EPixelFormat pixFormat = FFmpegDecoderCallback::EPixelFormat::RGB;&#xA;            // Report frame to the client and update last reported frame idx:&#xA;            m_pCB->FFmpegDecoderCallback_HandleFrame(m_reqId, GetLastDecodedFrameIdx(), m_pAVFrameRGB->width, m_pAVFrameRGB->height, m_pAVFrameRGB->linesize[0], pixFormat, numChannels, m_pAVFrameRGB->data[0]);&#xA;            m_lastReportedFrameIdx = GetLastDecodedFrameIdx();  &#xA;        }&#xA;&#xA;        if (maxNumFrames != MAX_NUM_FRAMES_INFINITE &amp;&amp; GetLastDecodedFrameIdx() >= (firstFrameIdx &#x2B; maxNumFrames - 1))&#xA;        {&#xA;            bDecodeShouldEnd = true;&#xA;            return true;&#xA;        }&#xA;    }&#xA;    return true;&#xA;}&#xA;&#xA;/*virtual*/ void FFmpegOneDecoderCtx::FFmpegDecoderCallback_HandleFrame(int reqId, int frameIdx0based, int width, int height, int widthStepBytes, EPixelFormat pixFormat, int numChannels, void * pData) /*override*/&#xA;{&#xA;    // We don&#x27;t have metadata json => return the frame as is:&#xA;    m_pLastFrame->create(height, width, CV_8UC3);&#xA;    *m_pLastFrame = cv::Scalar(0, 0, 0);&#xA;    unsigned char * pSrc = reinterpret_cast<unsigned char="char">(pData);&#xA;    unsigned char *pDst = m_pLastFrame->data;&#xA;    auto dstStride = m_pLastFrame->step[0];&#xA;    for (int y = 0; y &lt; height; &#x2B;&#x2B;y)&#xA;    {&#xA;        memcpy(pDst &#x2B; y * dstStride, pSrc &#x2B; y * widthStepBytes, numChannels*width);&#xA;    }&#xA;}&#xA;</unsigned>

    &#xA;

    And eventually usage looks like this

    &#xA;

        //>>>Get Frame&#xA;    FFmpegMultiDecoder decoder;&#xA;    decoder.HandleRequest_GetFrame(nullptr, filename, 1, image);&#xA;    //&lt;&lt;&lt;&#xA;&#xA;    //>>> Collor conversion from BGR to RGB&#xA;    cv::cvtColor(image, image, cv::COLOR_BGR2RGB);&#xA;    //&lt;&lt;&lt;&#xA;    bool isOk = cv::imwrite(save_location, image);&#xA;

    &#xA;

    The problem is that if you try to open two final decompressed images

    &#xA;

      &#xA;
    1. one with code https://drive.google.com/file/d/1sfTnqvHKQ2DUy0uP8POZXDw2-u3oIRfZ/view?usp=sharing
    2. &#xA;

    3. one with cmd query https://drive.google.com/file/d/1cwsOltk3DVtK86eLeyhiYjNeEXj0msES/view?usp=sharing
    4. &#xA;

    &#xA;

    and try to flip from one image to other you'll see that image I got by cmd query a little bit brighter than that I got by code.

    &#xA;

    What is a possible problem here ?

    &#xA;

    If I missed smth feel free to ask.

    &#xA;