Recherche avancée

Médias (3)

Mot : - Tags -/pdf

Autres articles (36)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

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

Sur d’autres sites (6519)

  • How to get currecnt AVFrame sequential number after av_seek_frame ?

    15 janvier 2023, par Sirop4ik

    I am new in decoder and FFmpeg. What I need is to implement the logic that can read frames with some step (ex:20), in other words, I have a file and I need to read frames 0, 20, 40, 60...

    


    what I do is

    


    
AVFrame * m_pAVFrame = nullptr;
int firstFrameIdx = 0;

while(true)
{

if(firstFrameIdx > 0)
{
int64_t seekTarget = FrameToPts(m_pAVStream, firstFrameIdx);
nRet = av_seek_frame(m_pAVFormatCtx, m_streamIdx, seekTarget, AVSEEK_FLAG_FRAME);
}

nRet = av_read_frame(m_pAVFormatCtx, m_pAVPkt);
ret = avcodec_send_packet(m_pAVCodecCtx, m_pAVPkt);
ret = avcodec_receive_frame(m_pAVCodecCtx, m_pAVFrame);

firstFrameIdx+=20;
}



    


    But problem is that av_seek_frame moves the pointer to the Iframe, lets say the video file has keyframes each 15(of course it could be a different number) like 0, 15, 30... So it means that if I try to seek to frame 20 actually I get to frame 15.

    


    I see that AVFrame has a property coded_picture_number that could be useful in my case, I tried to put these returned values to the vector and I see that these values irrelevant

    


    enter image description here

    


    what I expected to see there is 0, 15, 30, 45...

    


    It'll be useful if I for example can make a seek then get a frame to ask the order number (ex:15) then I can understand that Iframe is 15 and in order to reach frame 20 I need to read and skip 5 frames so as a result, I get to frame 20, but as you see above after the seek I ask the order number and get weird values like 0, 2, 1, 3... there is nothing to do with it...

    


    I feel like there is some basic knowledge that I miss, could someone explain how to make a seek logic and get to the right frame ?

    


    UPDATE

    


    Init logic

    


    bool FFmpegDecoder::Init(unsigned char const * pData, int dataSize, int reqId, bool bUseHWAccel, FFmpegDecoderCallback * pCB)&#xA;{&#xA;    Deinit();&#xA;&#xA;    // From memory:&#xA;    if (pData == nullptr || dataSize == 0)&#xA;    {&#xA;        printf("FFmpegDecoder::Init FAILED: neither filename nor memory data were given !\n");&#xA;        return false;&#xA;    }&#xA;    m_pIoCtx = std::make_shared<aviocontextmem>(pData, dataSize);&#xA;&#xA;    if (m_pIoCtx->IsValid() == false)&#xA;    {&#xA;        printf("FFmpegDecoder::Init FAILED: m_pIoCtx is nullptr !\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_reqId = reqId;&#xA;    m_bUseHWAccel = bUseHWAccel;&#xA;    m_pCB = pCB;&#xA;    m_pData = pData;&#xA;    m_dataSize = dataSize;&#xA;&#xA;    m_bRequestedAbort = false;&#xA;&#xA;    m_pAVPkt = av_packet_alloc();&#xA;    av_init_packet(m_pAVPkt);&#xA;&#xA;    m_pAVFrame = av_frame_alloc();&#xA;    m_pAVFrameRGB = av_frame_alloc();&#xA;&#xA;    if (m_bUseHWAccel)&#xA;    {&#xA;        m_pSwAVFrameForHw = av_frame_alloc();&#xA;    }&#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;&#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 (m_bUseHWAccel)&#xA;    {&#xA;        AVHWDeviceType hwDevType = AV_HWDEVICE_TYPE_DXVA2;&#xA;        g_hwPixFormat = find_fmt_by_hw_type(hwDevType);&#xA;        m_pAVCodecCtx->get_format = get_hw_format;&#xA;        av_opt_set_int(m_pAVCodecCtx, "refcounted_frames", 1, 0);&#xA;        if (av_hwdevice_ctx_create(&amp;m_pBufferRefForHw, hwDevType, NULL, NULL, 0) &lt; 0)&#xA;        {&#xA;            printf("FFmpegDecoder::InitFFmpeg: error in av_hwdevice_ctx_create\n");&#xA;            return false;&#xA;        }&#xA;        m_pAVCodecCtx->hw_device_ctx = av_buffer_ref(m_pBufferRefForHw);&#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;    //InitConvertColorSpace&#xA;    // Init converter from YUV420p to BGR:&#xA;    if (m_bUseHWAccel)&#xA;    {&#xA;        m_pSwsCtxConvertImg = sws_getContext(m_pAVCodecCtx->width, m_pAVCodecCtx->height, AV_PIX_FMT_NV12, m_pAVCodecCtx->width, m_pAVCodecCtx->height, AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);&#xA;    }&#xA;    else&#xA;    {&#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;    }&#xA;    if (!m_pSwsCtxConvertImg)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in sws_getContext\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_bInitOK = true;&#xA;    return true;&#xA;}&#xA;</aviocontextmem>

    &#xA;

    Decoding logic with last changes

    &#xA;

    void FFmpegDecoder::DecodeWithStep(int step)&#xA;{&#xA;    step = 20;&#xA;    int currentFramePos = 0;&#xA;    int number_of_errors = 0;&#xA;    const int MAX_ERROR_NUM = 10;&#xA;&#xA;    while (true)&#xA;    {&#xA;        if (step > 0)&#xA;        {&#xA;            int seekPos = currentFramePos &#x2B; step;&#xA;            int64_t seekTarget = FrameToPts(m_pAVStream, seekPos);&#xA;&#xA;            if (av_seek_frame(m_pAVFormatCtx, m_streamIdx, seekTarget, AVSEEK_FLAG_FRAME) &lt; 0)&#xA;            {&#xA;                number_of_errors&#x2B;&#x2B;;&#xA;            }&#xA;            else&#xA;            {&#xA;                currentFramePos = seekPos;&#xA;                m_is_seeked = true;&#xA;            }&#xA;        }&#xA;&#xA;        if (av_read_frame(m_pAVFormatCtx, m_pAVPkt) == 0)&#xA;        {&#xA;            if (m_pAVPkt->stream_index == m_streamIdx) //to make sure that I dont get packets from other streams&#xA;            {&#xA;                if (m_is_seeked)&#xA;                {&#xA;                    avcodec_flush_buffers(m_pAVCodecCtx);&#xA;                    m_is_seeked = false;&#xA;                }&#xA;&#xA;                if (avcodec_send_packet(m_pAVCodecCtx, m_pAVPkt) == 0)&#xA;                {&#xA;                    printf("----- BATCH\n");&#xA;&#xA;                    while (avcodec_receive_frame(m_pAVCodecCtx, m_pAVFrame) == 0)&#xA;                    {&#xA;                        ProcessFrame(m_pAVFrame);&#xA;                        av_frame_unref(m_pAVFrame);&#xA;                        currentFramePos&#x2B;&#x2B;;&#xA;                        printf("----- cur position (%d) \n", currentFramePos);&#xA;                    }&#xA;                }&#xA;&#xA;                av_packet_unref(m_pAVPkt);&#xA;            }&#xA;        }&#xA;        else&#xA;        {&#xA;            number_of_errors&#x2B;&#x2B;;&#xA;        }&#xA;&#xA;        if (number_of_errors == MAX_ERROR_NUM)&#xA;        {&#xA;            printf("EXIT\n");&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    UPDATE

    &#xA;

    Init logic

    &#xA;

    bool FFmpegDecoder::Init(unsigned char const * pData, int dataSize, int reqId, bool bUseHWAccel, FFmpegDecoderCallback * pCB)&#xA;{&#xA;    Deinit();&#xA;&#xA;    // From memory:&#xA;    if (pData == nullptr || dataSize == 0)&#xA;    {&#xA;        printf("FFmpegDecoder::Init FAILED: neither filename nor memory data were given !\n");&#xA;        return false;&#xA;    }&#xA;    m_pIoCtx = std::make_shared<aviocontextmem>(pData, dataSize);&#xA;&#xA;    if (m_pIoCtx->IsValid() == false)&#xA;    {&#xA;        printf("FFmpegDecoder::Init FAILED: m_pIoCtx is nullptr !\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_reqId = reqId;&#xA;    m_bUseHWAccel = bUseHWAccel;&#xA;    m_pCB = pCB;&#xA;    m_pData = pData;&#xA;    m_dataSize = dataSize;&#xA;&#xA;    m_bRequestedAbort = false;&#xA;&#xA;    m_pAVPkt = av_packet_alloc();&#xA;    av_init_packet(m_pAVPkt);&#xA;&#xA;    m_pAVFrame = av_frame_alloc();&#xA;    m_pAVFrameRGB = av_frame_alloc();&#xA;&#xA;    if (m_bUseHWAccel)&#xA;    {&#xA;        m_pSwAVFrameForHw = av_frame_alloc();&#xA;    }&#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;&#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 (m_bUseHWAccel)&#xA;    {&#xA;        AVHWDeviceType hwDevType = AV_HWDEVICE_TYPE_DXVA2;&#xA;        g_hwPixFormat = find_fmt_by_hw_type(hwDevType);&#xA;        m_pAVCodecCtx->get_format = get_hw_format;&#xA;        av_opt_set_int(m_pAVCodecCtx, "refcounted_frames", 1, 0);&#xA;        if (av_hwdevice_ctx_create(&amp;m_pBufferRefForHw, hwDevType, NULL, NULL, 0) &lt; 0)&#xA;        {&#xA;            printf("FFmpegDecoder::InitFFmpeg: error in av_hwdevice_ctx_create\n");&#xA;            return false;&#xA;        }&#xA;        m_pAVCodecCtx->hw_device_ctx = av_buffer_ref(m_pBufferRefForHw);&#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;    //InitConvertColorSpace&#xA;    // Init converter from YUV420p to BGR:&#xA;    if (m_bUseHWAccel)&#xA;    {&#xA;        m_pSwsCtxConvertImg = sws_getContext(m_pAVCodecCtx->width, m_pAVCodecCtx->height, AV_PIX_FMT_NV12, m_pAVCodecCtx->width, m_pAVCodecCtx->height, AV_PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);&#xA;    }&#xA;    else&#xA;    {&#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;    }&#xA;    if (!m_pSwsCtxConvertImg)&#xA;    {&#xA;        printf("FFmpegDecoder::InitFFmpeg: error in sws_getContext\n");&#xA;        return false;&#xA;    }&#xA;&#xA;    m_bInitOK = true;&#xA;    return true;&#xA;}&#xA;</aviocontextmem>

    &#xA;

    void FFmpegDecoder::DecodeWithStep(int step)&#xA;{&#xA;    step = 20;&#xA;    int currentFramePos = 0;&#xA;    int number_of_errors = 0;&#xA;    const int MAX_ERROR_NUM = 10;&#xA;    int seekPos = 0;&#xA;&#xA;    while (true)&#xA;    {&#xA;        if (step > 1)&#xA;        {&#xA;            seekPos = currentFramePos &#x2B; step;&#xA;            int64_t seekTarget = FrameToPts(m_pAVStream, seekPos);&#xA;&#xA;            if (av_seek_frame(m_pAVFormatCtx, m_streamIdx, seekTarget, AVSEEK_FLAG_FRAME) &lt; 0)&#xA;            {&#xA;                number_of_errors&#x2B;&#x2B;;&#xA;            }&#xA;            else&#xA;            {&#xA;                m_is_seeked = true;&#xA;            }&#xA;        }&#xA;&#xA;        while (true)&#xA;        {&#xA;            if (av_read_frame(m_pAVFormatCtx, m_pAVPkt) == 0)&#xA;            {&#xA;                if (m_pAVPkt->stream_index == m_streamIdx) //to make sure that I dont get packets from other streams&#xA;                {&#xA;                    if (m_is_seeked)&#xA;                    {&#xA;                        avcodec_flush_buffers(m_pAVCodecCtx);&#xA;                        m_is_seeked = false;&#xA;                    }&#xA;&#xA;                    if (avcodec_send_packet(m_pAVCodecCtx, m_pAVPkt) == 0)&#xA;                    {&#xA;                        int ret = 0;&#xA;                        while (ret >= 0)&#xA;                        {&#xA;                            ret = avcodec_receive_frame(m_pAVCodecCtx, m_pAVFrame);&#xA;&#xA;                            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)&#xA;                            {&#xA;                                av_frame_unref(m_pAVFrame);&#xA;                                break;&#xA;                            }&#xA;&#xA;                            currentFramePos = m_pAVFrame->display_picture_number; //In order to get position of currect frame (seek move poiter to the key frame)&#xA;&#xA;                            if (currentFramePos &lt; seekPos) //Some frames need to be skiped in order to reach needed frame&#xA;                            {&#xA;                                printf("----- SKIP : cur position (%d) \n", currentFramePos);&#xA;                                av_frame_unref(m_pAVFrame);&#xA;                                continue;&#xA;                            }&#xA;&#xA;                            ProcessFrame(m_pAVFrame); //needed frame was processed&#xA;                            av_frame_unref(m_pAVFrame);&#xA;                            printf("----- cur position (%d) \n", currentFramePos);&#xA;                            break;&#xA;                        }&#xA;                    }&#xA;&#xA;                    av_packet_unref(m_pAVPkt);&#xA;                }&#xA;                else&#xA;                {&#xA;                    av_packet_unref(m_pAVPkt); //we got a frame from the wrong stream&#xA;                }&#xA;            }&#xA;            else&#xA;            {&#xA;                number_of_errors&#x2B;&#x2B;;&#xA;            }&#xA;&#xA;            if (number_of_errors == MAX_ERROR_NUM)&#xA;            {&#xA;                printf("EXIT1\n");&#xA;                break;&#xA;            }&#xA;        }&#xA;&#xA;        if (number_of_errors == MAX_ERROR_NUM)&#xA;        {&#xA;            printf("EXIT2\n");&#xA;            break;&#xA;        }&#xA;    }&#xA;}&#xA;

    &#xA;

    int64_t FrameToPts(AVStream* pavStream, int frame)&#xA;{&#xA;    return (int64_t(frame) * pavStream->r_frame_rate.den *  pavStream->time_base.den) /&#xA;        (int64_t(pavStream->r_frame_rate.num) * pavStream->time_base.num);&#xA;}&#xA;

    &#xA;

  • Announcing Matomo 4 : More security, privacy and better performance

    17 novembre 2020, par Matomo Core Team — Community, Development, Privacy, Security

    The moment we’ve all been waiting for is here … Matomo Analytics 4 has launched !! We’re incredibly grateful for all community members and contributors who’ve helped with improvements, and our awesome team for all the fixes. 

    We can’t wait for you to gain greater security, privacy protection, and be able to boost your website performance. Now who’s ready ?

    Minimise your business’ web data security risk

    We’ve made Matomo even more secure to meet our users’ ever increasing security needs. Matomo 4 has certainly delivered on these expectations with a wide range of security enhancements and fixes across the platform :

    • Support for app specific API tokens. [#6559]
    • API tokens and session ids are now stored hashed in the database which means if someone can access your database they wouldn’t be able to get the actual token.
    • A more secure host validation. [#16169]
    • By default, you no longer can embed widgets through tokens with higher privileges. [#16264]
    • Plenty of other minor security fixes.

    More protection of your customer’s personal data

    Matomo 4 ensures you’re compliant with data privacy laws and provides you with more ways to keep your customer’s personal data private, such as :

    • The ability to automatically anonymise the referrer to avoid tracking personal data by accident. [#15426]
    • The option to enforce the disabling of cookies. [#16258]
    • Possibility in JavaScript tracker to turn cookies on and off at any time. [#13056]
    • The option to not store any IP address at all. [#16377]
    • Easily disable visits log and visitor profile feature if needed for privacy compliance [#16259]
    • New segment to separate visitors who gave consent vs visitors who didn’t give consent. [#16192]

    Matomo now offers PHP 8 support to users. Want to know more ? Get a detailed list of over 300 fixes and improvements in the Matomo 4 changelog.

    Increased conversion rates with a focus on page performance

    Our new Page Performance feature in Matomo 4 can help you increase conversion rates by showing you exactly how fast or slow your website is going, and WHY. An Akamai Online Retail Study in 2017 found that a 100-millisecond delay in website load time could underperform website conversion rates by up to 7%. 

    By using this new feature you can quickly identify slow pages and fix page speed issues as soon as they arise, meaning you never miss out on those valuable new sales opportunities.

    Improve your Google search rankings in 2021

    According to moz.com, Google’s bringing in a new ranking factor into their algorithm named Core Web Vitals, which will place greater emphasis on load speed (favouring websites that load faster). This means the slower your page loads, the worse it will rank in Google. With Matomo’s new feature, you’ll be able to optimise your pages to rank better according to the Core Web Vitals ranking factor. 

    Read more on how you can use this new feature : https://matomo.org/faq/how-to/how-do-i-see-page-performance-reports/

    Need help upgrading Matomo ?

    Read the Updating Matomo user guide or contact the Matomo experts

    Please note : It may take a while for you to receive a notice to update to Matomo 4.

  • Manipulating one video into multi outputs with FFmpeg results in no audio in the last output

    27 octobre 2015, par my name is

    Using FFmpeg, I’m trying to do some filtering operations on one input video to scale it (out1), scale and trim it (out2).
    This is the command I’m using :

    ffmpeg -y \
    -i "Robotica_1080.mkv" \
    -filter_complex "[0:v]split=2[v1][v2]; \
    [v1]scale=640:360,setpts=PTS-STARTPTS[vout1]; \
    [v2]trim=10:15,scale=640:360,setpts=PTS-STARTPTS[vout2]; \
    [0:a]asplit=2[a1][a2]; \
    [a1]anull,asetpts=PTS-STARTPTS[aout1]; \
    [a2]atrim=10:15,asetpts=PTS-STARTPTS[aout2]; \
    [vout1][aout1]concat=n=1:v=1:a=1[out1]; \
    [vout2][aout2]concat=n=1:v=1:a=1[out2]" \
    -map "[out1]" "1.mp4" \
    -map "[out2]" "2.mp4"

    1.mp4 is ok while 2.mp4 lasts 5 seconds as expected but without audio at all (the QuickTime inspector doesn’t write the audio codec)

    I tried to remove the trim/atrim filters, so the filter_complex parameter looked like this :

    -filter_complex "[0:v]split=2[v1][v2]; \
    [v1]scale=640:360[vout1]; \
    [v2]scale=640:360[vout2]; \
    [0:a]asplit=2[a1][a2]; \
    [a1]anull[aout1]; \
    [a2]anull[aout2]; \
    [vout1][aout1]concat=n=1:v=1:a=1[out1]; \
    [vout2][aout2]concat=n=1:v=1:a=1[out2]" \

    but still no audio on 2.mp4

    Can anyone give me a hint ?

    —EDIT—
    This is the output from first ffmpeg command :


    Mac-mini:~ Luca$ /Applications/XAMPP/xamppfiles/htdocs/MediaGallery/ffmpeg/ffmpeg -y \
    > -i "/Users/Luca/Desktop/_TEMP UPLOAD/Video/Robotica_1080.mkv" \
    > -filter_complex "[0:v]split=2[v1][v2]; \
    > [v1]scale=640:360,setpts=PTS-STARTPTS[vout1]; \
    > [v2]trim=10:15,scale=640:360,setpts=PTS-STARTPTS[vout2]; \
    > [0:a]asplit=2[a1][a2]; \
    > [a1]anull,asetpts=PTS-STARTPTS[aout1]; \
    > [a2]atrim=10:15,asetpts=PTS-STARTPTS[aout2]; \
    > [vout1][aout1]concat=n=1:v=1:a=1[out1]; \
    > [vout2][aout2]concat=n=1:v=1:a=1[out2]" \
    > -map "[out1]" "/Users/Luca/Downloads/1.mp4" \
    > -map "[out2]" "/Users/Luca/Downloads/2.mp4"
    ffmpeg version N-72460-gc5a07f1-tessus Copyright (c) 2000-2015 the FFmpeg developers
     built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
     configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --as=yasm --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-version3 --disable-ffplay --disable-indev=qtkit --disable-indev=x11grab_xcb
     libavutil      54. 23.101 / 54. 23.101
     libavcodec     56. 40.100 / 56. 40.100
     libavformat    56. 33.101 / 56. 33.101
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 16.101 /  5. 16.101
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, matroska,webm, from '/Users/Luca/Desktop/_TEMP UPLOAD/Video/Robotica_1080.mkv':
     Metadata:
       encoder         : libDivXMediaFormat 4.0.0.0578
     Duration: 00:00:20.04, start: 0.000000, bitrate: 4282 kb/s
       Stream #0:0(eng): Video: hevc (Main), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
       Stream #0:1(en): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    [swscaler @ 0x7fb4d181c400] deprecated pixel format used, make sure you did set range correctly
    [swscaler @ 0x7fb4d185be00] deprecated pixel format used, make sure you did set range correctly
    No pixel format specified, yuvj420p for H.264 encoding chosen.
    Use -pix_fmt yuv420p for compatibility with outdated media players.
       Last message repeated 1 times
    [libx264 @ 0x7fb4d183f400] using SAR=1/1
    [libx264 @ 0x7fb4d183f400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    [libx264 @ 0x7fb4d183f400] profile High, level 3.0
    [libx264 @ 0x7fb4d183f400] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    [libx264 @ 0x7fb4d184e400] using SAR=1/1
    [libx264 @ 0x7fb4d184e400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    [libx264 @ 0x7fb4d184e400] profile High, level 3.0
    [libx264 @ 0x7fb4d184e400] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '/Users/Luca/Downloads/1.mp4':
     Metadata:
       encoder         : Lavf56.33.101
       Stream #0:0: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
       Metadata:
         encoder         : Lavc56.40.100 libvo_aacenc
       Stream #0:1: Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s
       Metadata:
         encoder         : Lavc56.40.100 libvo_aacenc
       Stream #0:2: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p(pc), 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
       Metadata:
         encoder         : Lavc56.40.100 libx264
    Output #1, mp4, to '/Users/Luca/Downloads/2.mp4':
     Metadata:
       encoder         : Lavf56.33.101
       Stream #1:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuvj420p(pc), 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
       Metadata:
         encoder         : Lavc56.40.100 libx264
    Stream mapping:
     Stream #0:0 (hevc) -> split
     Stream #0:1 (aac) -> asplit
     concat:out:a0 -> Stream #0:0 (libvo_aacenc)
     concat:out:a0 -> Stream #0:1 (libvo_aacenc)
     concat:out:v0 -> Stream #0:2 (libx264)
     concat:out:v0 -> Stream #1:0 (libx264)
    Press [q] to stop, [?] for help
    frame=  501 fps= 26 q=-1.0 Lq=-1.0 size=    1512kB time=00:00:19.97 bitrate= 620.1kbits/s    
    video:1385kB audio:392kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
    [libx264 @ 0x7fb4d183f400] frame I:3     Avg QP:19.30  size:  3879
    [libx264 @ 0x7fb4d183f400] frame P:321   Avg QP:24.53  size:  3024
    [libx264 @ 0x7fb4d183f400] frame B:177   Avg QP:26.20  size:   825
    [libx264 @ 0x7fb4d183f400] consecutive B-frames: 40.7% 34.7%  5.4% 19.2%
    [libx264 @ 0x7fb4d183f400] mb I  I16..4: 24.8% 65.9%  9.3%
    [libx264 @ 0x7fb4d183f400] mb P  I16..4:  7.5% 10.5%  2.5%  P16..4: 22.9%  7.4%  2.7%  0.0%  0.0%    skip:46.5%
    [libx264 @ 0x7fb4d183f400] mb B  I16..4:  0.4%  0.6%  0.3%  B16..8: 17.2%  2.9%  0.7%  direct: 0.9%  skip:77.1%  L0:37.2% L1:51.8% BI:11.0%
    [libx264 @ 0x7fb4d183f400] 8x8 transform intra:51.6% inter:69.2%
    [libx264 @ 0x7fb4d183f400] coded y,uvDC,uvAC intra: 40.2% 24.2% 1.1% inter: 8.5% 4.0% 0.0%
    [libx264 @ 0x7fb4d183f400] i16 v,h,dc,p:  9% 65%  1% 25%
    [libx264 @ 0x7fb4d183f400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 29% 16%  4%  6%  6%  7%  6%  6%
    [libx264 @ 0x7fb4d183f400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 34% 12%  3%  7%  6%  7%  4%  4%
    [libx264 @ 0x7fb4d183f400] i8c dc,h,v,p: 63% 25% 11%  1%
    [libx264 @ 0x7fb4d183f400] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 0x7fb4d183f400] ref P L0: 69.3% 11.5% 12.5%  6.7%
    [libx264 @ 0x7fb4d183f400] ref B L0: 82.4% 16.7%  0.8%
    [libx264 @ 0x7fb4d183f400] ref B L1: 98.6%  1.4%
    [libx264 @ 0x7fb4d183f400] kb/s:450.44
    [libx264 @ 0x7fb4d184e400] frame I:1     Avg QP:22.23  size:  6699
    [libx264 @ 0x7fb4d184e400] frame P:78    Avg QP:24.94  size:  2998
    [libx264 @ 0x7fb4d184e400] frame B:46    Avg QP:27.93  size:  1036
    [libx264 @ 0x7fb4d184e400] consecutive B-frames: 32.0% 56.0%  2.4%  9.6%
    [libx264 @ 0x7fb4d184e400] mb I  I16..4: 53.5% 26.6% 19.9%
    [libx264 @ 0x7fb4d184e400] mb P  I16..4:  9.8%  7.6%  3.1%  P16..4: 25.0%  8.0%  2.8%  0.0%  0.0%    skip:43.8%
    [libx264 @ 0x7fb4d184e400] mb B  I16..4:  0.8%  0.5%  0.4%  B16..8: 22.4%  3.5%  0.8%  direct: 1.1%  skip:70.4%  L0:41.1% L1:48.0% BI:10.9%
    [libx264 @ 0x7fb4d184e400] 8x8 transform intra:36.1% inter:66.1%
    [libx264 @ 0x7fb4d184e400] coded y,uvDC,uvAC intra: 33.5% 24.6% 1.8% inter: 8.5% 3.8% 0.0%
    [libx264 @ 0x7fb4d184e400] i16 v,h,dc,p:  4% 82%  1% 13%
    [libx264 @ 0x7fb4d184e400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 40% 18%  3%  4%  4%  7%  3%  5%
    [libx264 @ 0x7fb4d184e400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 40% 13%  3%  5%  5%  6%  3%  4%
    [libx264 @ 0x7fb4d184e400] i8c dc,h,v,p: 54% 36%  8%  2%
    [libx264 @ 0x7fb4d184e400] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 0x7fb4d184e400] ref P L0: 60.6% 10.5% 17.5% 11.4%
    [libx264 @ 0x7fb4d184e400] ref B L0: 77.6% 22.0%  0.4%
    [libx264 @ 0x7fb4d184e400] ref B L1: 99.1%  0.9%
    [libx264 @ 0x7fb4d184e400] kb/s:461.15