Recherche avancée

Médias (1)

Mot : - Tags -/MediaSPIP

Autres articles (97)

  • Websites made ​​with MediaSPIP

    2 mai 2011, par

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

Sur d’autres sites (4010)

  • What's wrong with how I save a vector of AVFrames as mp4 video using the h264 encoder ?

    8 avril 2023, par nokla

    I am trying to encode a vector of AVFrames to an MP4 file using the h264 codec.

    


    The code runs without errors but both when I try to open the saved video file with the windows media and adobe Media Encoded they it says that it is in an unsupported format.

    


    I went through it with a debugger and everything seemed to work fine.

    



    


    This is the function I used to saved the video :

    


    void SaveVideo(std::string&amp; output_filename, std::vector<avframe> video)&#xA;{&#xA;    // Initialize FFmpeg&#xA;    avformat_network_init();&#xA;&#xA;    // Open the output file context&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    int ret = avformat_alloc_output_context2(&amp;format_ctx, nullptr, nullptr, output_filename.c_str());&#xA;    if (ret &lt; 0) {&#xA;        wxMessageBox("Error creating output context: ");&#xA;        wxMessageBox(av_err2str(ret));&#xA;        return;&#xA;    }&#xA;&#xA;    // Open the output file&#xA;    ret = avio_open(&amp;format_ctx->pb, output_filename.c_str(), AVIO_FLAG_WRITE);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error opening output file: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create the video stream&#xA;    const AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_H264);&#xA;    if (!codec) {&#xA;        std::cerr &lt;&lt; "Error finding H.264 encoder" &lt;&lt; std::endl;&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    AVStream* stream = avformat_new_stream(format_ctx, codec);&#xA;    if (!stream) {&#xA;        std::cerr &lt;&lt; "Error creating output stream" &lt;&lt; std::endl;&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Set the stream parameters&#xA;    stream->codecpar->codec_id = AV_CODEC_ID_H264;&#xA;    stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;&#xA;    stream->codecpar->width =video.front().width;&#xA;    stream->codecpar->height = video.front().height;&#xA;    stream->codecpar->format = AV_PIX_FMT_YUV420P;&#xA;    stream->codecpar->bit_rate = 400000;&#xA;    AVRational framerate = { 1, 30};&#xA;    stream->time_base = av_inv_q(framerate);&#xA;&#xA;    // Open the codec context&#xA;    AVCodecContext* codec_ctx = avcodec_alloc_context3(codec);&#xA;    codec_ctx->codec_tag = 0;&#xA;    codec_ctx->time_base = stream->time_base;&#xA;    codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    if (!codec_ctx) {&#xA;        std::cout &lt;&lt; "Error allocating codec context" &lt;&lt; std::endl;&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    ret = avcodec_parameters_to_context(codec_ctx, stream->codecpar);&#xA;    if (ret &lt; 0) {&#xA;        std::cout &lt;&lt; "Error setting codec context parameters: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;    AVDictionary* opt = NULL;&#xA;    ret = avcodec_open2(codec_ctx, codec, &amp;opt);&#xA;    if (ret &lt; 0) {&#xA;        wxMessageBox("Error opening codec: ");&#xA;        wxMessageBox(av_err2str(ret));&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Allocate a buffer for the frame data&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        std::cerr &lt;&lt; "Error allocating frame" &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    frame->format = codec_ctx->pix_fmt;&#xA;    frame->width = codec_ctx->width;&#xA;    frame->height = codec_ctx->height;&#xA;&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error allocating frame buffer: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Allocate a buffer for the converted frame data&#xA;    AVFrame* converted_frame = av_frame_alloc();&#xA;    if (!converted_frame) {&#xA;        std::cerr &lt;&lt; "Error allocating converted frame" &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    converted_frame->format = AV_PIX_FMT_YUV420P;&#xA;    converted_frame->width = codec_ctx->width;&#xA;    converted_frame->height = codec_ctx->height;&#xA;&#xA;    ret = av_frame_get_buffer(converted_frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error allocating converted frame buffer: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        av_frame_free(&amp;converted_frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Initialize the converter&#xA;    SwsContext* converter = sws_getContext(&#xA;        codec_ctx->width, codec_ctx->height, codec_ctx->pix_fmt,&#xA;        codec_ctx->width, codec_ctx->height, AV_PIX_FMT_YUV420P,&#xA;        SWS_BICUBIC, nullptr, nullptr, nullptr&#xA;    );&#xA;    if (!converter) {&#xA;        std::cerr &lt;&lt; "Error initializing converter" &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        av_frame_free(&amp;converted_frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Write the header to the output file&#xA;    ret = avformat_write_header(format_ctx, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error writing header to output file: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        av_frame_free(&amp;converted_frame);&#xA;        sws_freeContext(converter);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Iterate over the frames and write them to the output file&#xA;    int frame_count = 0;&#xA;    for (auto&amp; frame: video) {&#xA;         {&#xA;            // Convert the frame to the output format&#xA;            sws_scale(converter,&#xA;                srcFrame.data, srcFrame.linesize, 0, srcFrame.height,&#xA;                converted_frame->data, converted_frame->linesize&#xA;            );&#xA;&#xA;            // Set the frame properties&#xA;            converted_frame->pts = av_rescale_q(frame_count, stream->time_base, codec_ctx->time_base);&#xA;            frame_count&#x2B;&#x2B;;&#xA;            //converted_frame->time_base.den = codec_ctx->time_base.den;&#xA;            //converted_frame->time_base.num = codec_ctx->time_base.num;&#xA;            // Encode the frame and write it to the output&#xA;            ret = avcodec_send_frame(codec_ctx, converted_frame);&#xA;            if (ret &lt; 0) {&#xA;                std::cerr &lt;&lt; "Error sending frame for encoding: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;                av_frame_free(&amp;frame);&#xA;                av_frame_free(&amp;converted_frame);&#xA;                sws_freeContext(converter);&#xA;                avcodec_free_context(&amp;codec_ctx);&#xA;                avformat_free_context(format_ctx);&#xA;                return;&#xA;            }&#xA;            AVPacket* pkt = av_packet_alloc();&#xA;            if (!pkt) {&#xA;                std::cerr &lt;&lt; "Error allocating packet" &lt;&lt; std::endl;&#xA;                return;&#xA;            }&#xA;            while (ret >= 0) {&#xA;                ret = avcodec_receive_packet(codec_ctx, pkt);&#xA;                if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                    std::string a = av_err2str(ret);&#xA;                    break;&#xA;                }&#xA;                else if (ret &lt; 0) {&#xA;                    wxMessageBox("Error during encoding");&#xA;                    wxMessageBox(av_err2str(ret));&#xA;                    av_packet_unref(pkt);&#xA;                    av_frame_free(&amp;frame);&#xA;                    av_frame_free(&amp;converted_frame);&#xA;                    sws_freeContext(converter);&#xA;                    avcodec_free_context(&amp;codec_ctx);&#xA;                    avformat_free_context(format_ctx);&#xA;                    return;&#xA;                }&#xA;&#xA;                // Write the packet to the output file&#xA;                av_packet_rescale_ts(pkt, codec_ctx->time_base, stream->time_base);&#xA;                pkt->stream_index = stream->index;&#xA;                ret = av_interleaved_write_frame(format_ctx, pkt);&#xA;                av_packet_unref(pkt);&#xA;                if (ret &lt; 0) {&#xA;                    std::cerr &lt;&lt; "Error writing packet to output file: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;                    av_frame_free(&amp;frame);&#xA;                    av_frame_free(&amp;converted_frame);&#xA;                    sws_freeContext(converter);&#xA;                    avcodec_free_context(&amp;codec_ctx);&#xA;                    avformat_free_context(format_ctx);&#xA;                    return;&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    // Flush the encoder&#xA;    ret = avcodec_send_frame(codec_ctx, nullptr);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error flushing encoder: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;frame);&#xA;        av_frame_free(&amp;converted_frame);&#xA;        sws_freeContext(converter);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        return;&#xA;    }&#xA;&#xA;    while (ret >= 0) {&#xA;        AVPacket* pkt = av_packet_alloc();&#xA;        if (!pkt) {&#xA;            std::cerr &lt;&lt; "Error allocating packet" &lt;&lt; std::endl;&#xA;            return;&#xA;        }&#xA;        ret = avcodec_receive_packet(codec_ctx, pkt);&#xA;        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;            wxMessageBox("Error recieving packet");&#xA;            wxMessageBox(av_err2str(ret));&#xA;            break;&#xA;        }&#xA;        else if (ret &lt; 0) {&#xA;            std::cerr &lt;&lt; "Error during encoding: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;            av_packet_unref(pkt);&#xA;            av_frame_free(&amp;frame);&#xA;            av_frame_free(&amp;converted_frame);&#xA;            sws_freeContext(converter);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            return;&#xA;        }&#xA;&#xA;        // Write the packet to the output file&#xA;        av_packet_rescale_ts(pkt, codec_ctx->time_base, stream->time_base);&#xA;        pkt->stream_index = stream->index;&#xA;        ret = av_interleaved_write_frame(format_ctx, pkt);&#xA;        av_packet_unref(pkt);&#xA;        if (ret &lt; 0) {&#xA;            std::cerr &lt;&lt; "Error writing packet to output file: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;            av_frame_free(&amp;frame);&#xA;            av_frame_free(&amp;converted_frame);&#xA;            sws_freeContext(converter);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            return;&#xA;        }&#xA;    }&#xA;&#xA;    // Write the trailer to the output file&#xA;    ret = av_write_trailer(format_ctx);&#xA;    if (ret &lt; 0) {&#xA;        std::cerr &lt;&lt; "Error writing trailer to output file: " &lt;&lt; av_err2str(ret) &lt;&lt; std::endl;&#xA;    }&#xA;&#xA;    // Free all resources&#xA;    av_frame_free(&amp;frame);&#xA;    av_frame_free(&amp;converted_frame);&#xA;    sws_freeContext(converter);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_free_context(format_ctx);&#xA;}&#xA;&#xA;</avframe>

    &#xA;

    ** I know it is not the prettiest way to write this code, I just wanted to try and do something like that.

    &#xA;

    ** This is an altered version of the function as the original one was inside class. I changed it so you could compile it, but it might has some errors if I forgot to change something

    &#xA;

    Any help would be appreciated.

    &#xA;

  • Open letter to the European Parliament’s LIBE committee

    28 novembre 2019, par Joselyn Khor — Uncategorized

    An open letter to the European Parliament’s LIBE committee

    e-evidence newsletter

    In an effort to stem the tide of external control over user privacy, Matomo has rallied with other like-minded companies like Protonmail, NextCloud, Tutanota and Mailfence, to advocate for pro-privacy changes to the European Commission’s “e-evidence” proposal.

    Excerpt from the letter : 

    “The Commission’s e-evidence proposal threatens the competitive advantage European tech businesses have over their American counterparts by undermining the protections we can provide to our customers. It breaks with the long-standing rule that only trusted national judicial authorities can order companies to hand over customer data for criminal investigations. Instead, the Commission’s e-evidence proposal would allow any foreign law enforcement agency from across the EU to force us to hand out customer data without our own authorities doublechecking the foreign order.

    “Different from American Big Tech firms, European privacy tech companies lack the resources to verify the legality of each foreign order. Because of the way the e-evidence proposal is phrased, we would not even be able to properly authenticate foreign authorities to ensure that we are not replying to a malicious actor – let alone object to an order if we found it to be unwarranted.”

    Matomo Founder, Matthieu Aubry emphasises, “It is time that privacy-minded tech companies work together to defend their users, their businesses, and the values they are founded on. This is why we are supporting Privacy Tech Europe.”

    Read our open letter to members of the LIBE Committee in full.

  • Neutral net or neutered

    4 juin 2013, par Mans — Law and liberty

    In recent weeks, a number of high-profile events, in the UK and elsewhere, have been quickly seized upon to promote a variety of schemes for monitoring or filtering Internet access. These proposals, despite their good intentions of protecting children or fighting terrorism, pose a serious threat to fundamental liberties. Although at a glance the ideas may seem like a reasonable price to pay for the prevention of some truly hideous crimes, there is more than first meets the eye. Internet regulation in any form whatsoever is the thin end of a wedge at whose other end we find severely restricted freedom of expression of the kind usually associated with oppressive dictatorships. Where the Internet was once a novelty, it now forms an integrated part of modern society ; regulating the Internet means regulating our lives.

    Terrorism

    Following the brutal murder of British soldier Lee Rigby in Woolwich, attempts were made in the UK to revive the controversial Communications Data Bill, also dubbed the snooper’s charter. The bill would give police and security services unfettered access to details (excluding content) of all digital communication in the UK without needing so much as a warrant.

    The powers afforded by the snooper’s charter would, the argument goes, enable police to prevent crimes such as the one witnessed in Woolwich. True or not, the proposal would, if implemented, also bring about infrastructure for snooping on anyone at any time for any purpose. Once available, the temptation may become strong to extend, little by little, the legal use of these abilities to cover ever more everyday activities, all in the name of crime prevention, of course.

    In the emotional aftermath of a gruesome act, anything with the promise of preventing it happening again may seem like a good idea. At times like these it is important, more than ever, to remain rational and carefully consider all the potential consequences of legislation, not only the intended ones.

    Hate speech

    Hand in hand with terrorism goes hate speech, preachings designed to inspire violence against people of some singled-out nation, race, or other group. Naturally, hate speech is often to be found on the Internet, where it can reach large audiences while the author remains relatively protected. Naturally, we would prefer for it not to exist.

    To fulfil the utopian desire of a clean Internet, some advocate mandatory filtering by Internet service providers and search engines to remove this unwanted content. Exactly how such censoring might be implemented is however rarely dwelt upon, much less the consequences inadvertent blocking of innocent material might have.

    Pornography

    Another common target of calls for filtering is pornography. While few object to the blocking of child pornography, at least in principle, the debate runs hotter when it comes to the legal variety. Pornography, it is claimed, promotes violence towards women and is immoral or generally offensive. As such it ought to be blocked in the name of the greater good.

    The conviction last week of paedophile Mark Bridger for the abduction and murder of five-year-old April Jones renewed the debate about filtering of pornography in the UK ; his laptop was found to contain child pornography. John Carr of the UK government’s Council on Child Internet Safety went so far as suggesting a default blocking of all pornography, access being granted to an Internet user only once he or she had registered with some unspecified entity. Registering people wishing only to access perfectly legal material is not something we do in a democracy.

    The reality is that Google and other major search engines already remove illegal images from search results and report them to the appropriate authorities. In the UK, the Internet Watch Foundation, a non-government organisation, maintains a blacklist of what it deems ‘potentially criminal’ content, and many Internet service providers block access based on this list.

    While well-intentioned, the IWF and its blacklist should raise some concerns. Firstly, a vigilante organisation operating in secret and with no government oversight acting as the nation’s morality police has serious implications for freedom of speech. Secondly, the blocks imposed are sometimes more far-reaching than intended. In one incident, an attempt to block the cover image of the Scorpions album Virgin Killer hosted by Wikipedia (in itself a dubious decision) rendered the entire related article inaccessible as well as interfered with editing.

    Net neutrality

    Content filtering, or more precisely the lack thereof, is central to the concept of net neutrality. Usually discussed in the context of Internet service providers, this is the principle that the user should have equal, unfiltered access to all content. As a consequence, ISPs should not be held responsible for the content they deliver. Compare this to how the postal system works.

    The current debate shows that the principle of net neutrality is important not only at the ISP level, but should also include providers of essential services on the Internet. This means search engines should not be responsible for or be required to filter results, email hosts should not be required to scan users’ messages, and so on. No mandatory censoring can be effective without infringing the essential liberties of freedom of speech and press.

    Social networks operate in a less well-defined space. They are clearly not part of the essential Internet infrastructure, and they require that users sign up and agree to their terms and conditions. Because of this, they can include restrictions that would be unacceptable for the Internet as a whole. At the same time, social networks are growing in importance as means of communication between people, and as such they have a moral obligation to act fairly and apply their rules in a transparent manner.

    Facebook was recently under fire, accused of not taking sufficient measures to curb ‘hate speech,’ particularly against women. Eventually they pledged to review their policies and methods, and reducing the proliferation of such content will surely make the web a better place. Nevertheless, one must ask how Facebook (or another social network) might react to similar pressure from, say, a religious group demanding removal of ‘blasphemous’ content. What about demands from a foreign government ? Only yesterday, the Turkish prime minister Erdogan branded Twitter ‘a plague’ in a TV interview.

    Rather than impose upon Internet companies the burden of law enforcement, we should provide them the latitude to set their own policies as well as the legal confidence to stand firm in the face of unreasonable demands. The usual market forces will promote those acting responsibly.

    Further reading