Advanced search

Medias (91)

Other articles (68)

  • Websites made ​​with MediaSPIP

    2 May 2011, by

    This page lists some websites based on MediaSPIP.

  • Creating farms of unique websites

    13 April 2011, by

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

  • Les tâches Cron régulières de la ferme

    1 December 2010, by

    La gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
    Le super Cron (gestion_mutu_super_cron)
    Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)

On other websites (12678)

  • C++ ffmpeg lib version 7.0 - runtime error

    1 September 2024, by Chris P

    I want to make a C++ lib named cppdub which will mimic the python module pydub.

    


    One main function is to export the AudioSegment to a file with a specific format (example: mp3).

    


    The code is:

    


    void check_av_error(int error_code, const std::string&amp; msg) {&#xA;    if (error_code &lt; 0) {&#xA;        char errbuf[AV_ERROR_MAX_STRING_SIZE];&#xA;        av_strerror(error_code, errbuf, sizeof(errbuf));&#xA;        throw std::runtime_error(msg &#x2B; ": " &#x2B; errbuf);&#xA;    }&#xA;}&#xA;&#xA;std::string av_err2str_(int errnum) {&#xA;    char buf[AV_ERROR_MAX_STRING_SIZE];&#xA;    av_strerror(errnum, buf, sizeof(buf));&#xA;    return std::string(buf);&#xA;}&#xA;&#xA;void log_error(const std::string&amp; msg) {&#xA;    std::cerr &lt;&lt; "Error: " &lt;&lt; msg &lt;&lt; std::endl;&#xA;}&#xA;&#xA;std::ofstream cppdub::AudioSegment::export_segment(&#xA;    std::string&amp; out_f,&#xA;    const std::string&amp; format,&#xA;    const std::string&amp; codec,&#xA;    const std::string&amp; bitrate,&#xA;    const std::vector&amp; parameters,&#xA;    const std::map&amp; tags,&#xA;    const std::string&amp; id3v2_version,&#xA;    const std::string&amp; cover) {&#xA;&#xA;    av_log_set_level(AV_LOG_DEBUG);&#xA;    avformat_network_init();&#xA;&#xA;    AVFormatContext* format_ctx = nullptr;&#xA;    int ret = avformat_alloc_output_context2(&amp;format_ctx, nullptr, format.c_str(), out_f.c_str());&#xA;    check_av_error(ret, "Could not allocate format context");&#xA;&#xA;    if (!(format_ctx->oformat->flags &amp; AVFMT_NOFILE)) {&#xA;        ret = avio_open(&amp;format_ctx->pb, out_f.c_str(), AVIO_FLAG_WRITE);&#xA;        check_av_error(ret, "Could not open output file");&#xA;    }&#xA;&#xA;    AVStream* stream = avformat_new_stream(format_ctx, nullptr);&#xA;    if (!stream) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Could not allocate stream");&#xA;    }&#xA;&#xA;    const AVCodec* codec_obj = avcodec_find_encoder_by_name(codec.c_str());&#xA;    if (!codec_obj) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Codec not found");&#xA;    }&#xA;&#xA;    AVCodecContext* codec_ctx = avcodec_alloc_context3(codec_obj);&#xA;    if (!codec_ctx) {&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Could not allocate codec context");&#xA;    }&#xA;&#xA;    codec_ctx->sample_rate = this->get_frame_rate();&#xA;    AVChannelLayout ch_layout_1;&#xA;    av_channel_layout_uninit(&amp;ch_layout_1);&#xA;    av_channel_layout_default(&amp;ch_layout_1, 2);&#xA;    codec_ctx->ch_layout = ch_layout_1; // Adjust based on your needs&#xA;    codec_ctx->bit_rate = std::stoi(bitrate);&#xA;    codec_ctx->sample_fmt = codec_obj->sample_fmts[0];&#xA;&#xA;    if (format_ctx->oformat->flags &amp; AVFMT_GLOBALHEADER) {&#xA;        codec_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;&#xA;    }&#xA;&#xA;    ret = avcodec_open2(codec_ctx, codec_obj, nullptr);&#xA;    check_av_error(ret, "Could not open codec");&#xA;&#xA;    stream->time_base = { 1, codec_ctx->sample_rate };&#xA;    ret = avcodec_parameters_from_context(stream->codecpar, codec_ctx);&#xA;    check_av_error(ret, "Could not set codec parameters");&#xA;&#xA;    ret = avformat_write_header(format_ctx, nullptr);&#xA;    check_av_error(ret, "Error occurred when writing header");&#xA;&#xA;    AVPacket pkt;&#xA;    av_init_packet(&amp;pkt);&#xA;    pkt.data = nullptr;&#xA;    pkt.size = 0;&#xA;&#xA;    int frame_size = av_samples_get_buffer_size(nullptr, codec_ctx->ch_layout.nb_channels,&#xA;        codec_ctx->frame_size, codec_ctx->sample_fmt, 0);&#xA;    check_av_error(frame_size, "Could not calculate frame size");&#xA;&#xA;    AVFrame* frame = av_frame_alloc();&#xA;    if (!frame) {&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Error allocating frame");&#xA;    }&#xA;&#xA;    frame->format = codec_ctx->sample_fmt;&#xA;    frame->ch_layout = codec_ctx->ch_layout;&#xA;    frame->sample_rate = codec_ctx->sample_rate;&#xA;    frame->nb_samples = codec_ctx->frame_size;&#xA;&#xA;    ret = av_frame_get_buffer(frame, 0);&#xA;    if (ret &lt; 0) {&#xA;        av_frame_free(&amp;frame);&#xA;        avcodec_free_context(&amp;codec_ctx);&#xA;        avformat_free_context(format_ctx);&#xA;        throw std::runtime_error("Error allocating frame buffer: " &#x2B; av_err2str_(ret));&#xA;    }&#xA;&#xA;    size_t data_offset = 0;&#xA;&#xA;    while (data_offset &lt; this->raw_data().size()) {&#xA;        int samples_to_process = std::min(frame_size, static_cast<int>(this->raw_data().size()) - static_cast<int>(data_offset));&#xA;&#xA;        // Fill the frame with audio data&#xA;        ret = avcodec_fill_audio_frame(frame, codec_ctx->ch_layout.nb_channels, codec_ctx->sample_fmt,&#xA;            reinterpret_cast<const>(this->raw_data().data()) &#x2B; data_offset,&#xA;            samples_to_process, 0);&#xA;        if (ret &lt; 0) {&#xA;            log_error("Error filling audio frame: " &#x2B; av_err2str_(ret));&#xA;            av_frame_free(&amp;frame);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            throw std::runtime_error("Error filling audio frame: " &#x2B; av_err2str_(ret));&#xA;        }&#xA;&#xA;        data_offset &#x2B;= samples_to_process;&#xA;&#xA;        ret = avcodec_send_frame(codec_ctx, frame);&#xA;        if (ret &lt; 0) {&#xA;            log_error("Error sending frame for encoding: " &#x2B; av_err2str_(ret));&#xA;            av_frame_free(&amp;frame);&#xA;            avcodec_free_context(&amp;codec_ctx);&#xA;            avformat_free_context(format_ctx);&#xA;            throw std::runtime_error("Error sending frame for encoding: " &#x2B; av_err2str_(ret));&#xA;        }&#xA;&#xA;        while (ret >= 0) {&#xA;            ret = avcodec_receive_packet(codec_ctx, &amp;pkt);&#xA;            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {&#xA;                break;&#xA;            }&#xA;            check_av_error(ret, "Error receiving packet");&#xA;&#xA;            pkt.stream_index = stream->index;&#xA;&#xA;            ret = av_interleaved_write_frame(format_ctx, &amp;pkt);&#xA;            check_av_error(ret, "Error writing encoded frame to output file");&#xA;&#xA;            av_packet_unref(&amp;pkt);&#xA;        }&#xA;    }&#xA;&#xA;    // Flush the encoder&#xA;    avcodec_send_frame(codec_ctx, nullptr);&#xA;    while (avcodec_receive_packet(codec_ctx, &amp;pkt) == 0) {&#xA;        pkt.stream_index = stream->index;&#xA;        av_interleaved_write_frame(format_ctx, &amp;pkt);&#xA;        av_packet_unref(&amp;pkt);&#xA;    }&#xA;&#xA;    av_write_trailer(format_ctx);&#xA;&#xA;    av_frame_free(&amp;frame);&#xA;    avcodec_free_context(&amp;codec_ctx);&#xA;    avformat_free_context(format_ctx);&#xA;&#xA;    return std::ofstream(out_f, std::ios::binary);&#xA;}&#xA;</const></int></int>

    &#xA;

    The runtime error is:

    &#xA;

    Exception thrown at 0x00007FF945137C9B (avcodec-61.dll) in cppdub_test.exe: 0xC0000005: Access violation reading location 0x0000024CBCD25080.

    &#xA;

    for line:

    &#xA;

        ret = avcodec_send_frame(codec_ctx, frame);&#xA;

    &#xA;

    Call stack:

    &#xA;

        avcodec-61.dll!00007ff945137c9b()   Unknown&#xA;    avcodec-61.dll!00007ff9451381bb()   Unknown&#xA;    avcodec-61.dll!00007ff945139679()   Unknown&#xA;    avcodec-61.dll!00007ff94371521d()   Unknown&#xA;    avcodec-61.dll!00007ff9434a80c2()   Unknown&#xA;    avcodec-61.dll!00007ff9434a84a6()   Unknown&#xA;    avcodec-61.dll!00007ff9434a8749()   Unknown&#xA;>   cppdub_test.exe!cppdub::AudioSegment::export_segment(std::string &amp; out_f, const std::string &amp; format, const std::string &amp; codec, const std::string &amp; bitrate, const std::vector> &amp; parameters, const std::map,std::allocator>> &amp; tags, const std::string &amp; id3v2_version, const std::string &amp; cover) Line 572  C&#x2B;&#x2B;&#xA;    cppdub_test.exe!main() Line 33  C&#x2B;&#x2B;&#xA;    [External Code] &#xA;&#xA;

    &#xA;

    Autos:

    &#xA;

    &#x2B;       this    0x000000d3a08ff690 {data_="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0... ...} cppdub::AudioSegment *&#xA;&#x2B;       bitrate "128000"    const std::string &amp;&#xA;&#x2B;       ch_layout_1 {order=AV_CHANNEL_ORDER_NATIVE (1) nb_channels=2 u={mask=3 map=0x0000000000000003 {id=??? name=... opaque=...} } ...}   AVChannelLayout&#xA;&#x2B;       codec   "libmp3lame"    const std::string &amp;&#xA;&#x2B;       codec_ctx   0x0000024cbc78c240 {av_class=avcodec-61.dll!0x00007ff94789c760 {class_name=0x00007ff94789c740 "AVCodecContext" ...} ...}    AVCodecContext *&#xA;&#x2B;       codec_obj   avcodec-61.dll!0x00007ff9477fa4c0 (load symbols for additional information) {name=0x00007ff9477fa47c "libmp3lame" ...}  const AVCodec *&#xA;&#x2B;       cover   ""  const std::string &amp;&#xA;        data_offset 9216    unsigned __int64&#xA;&#x2B;       format  "mp3"   const std::string &amp;&#xA;&#x2B;       format_ctx  0x0000024cbc788a40 {av_class=avformat-61.dll!0x00007ff99eb09fe0 {class_name=0x00007ff99eb09fc0 "AVFormatContext" ...} ...}  AVFormatContext *&#xA;&#x2B;       frame   0x0000024cbc787380 {data=0x0000024cbc787380 {0x0000024cbcd25080 <error reading="reading" characters="characters" of="of">, ...} ...}    AVFrame *&#xA;        frame_size  9216    int&#xA;&#x2B;       id3v2_version   "4" const std::string &amp;&#xA;&#x2B;       out_f   "ha-ha-ha.mp3"  std::string &amp;&#xA;&#x2B;       parameters  { size=0 }  const std::vector> &amp;&#xA;&#x2B;       pkt {buf=0x0000000000000000 <null> pts=-9223372036854775808 dts=-9223372036854775808 ...}   AVPacket&#xA;        ret 9216    int&#xA;        samples_to_process  9216    int&#xA;&#x2B;       stream  0x0000024cbc789bc0 {av_class=avformat-61.dll!0x00007ff99eb09840 {class_name=0x00007ff99eb09820 "AVStream" ...} ...} AVStream *&#xA;&#x2B;       tags    { size=0 }  const std::map,std::allocator>> &amp;&#xA;</null></error>

    &#xA;

  • FFmpeg 6.0 won't work because the header files can't connect or interact with each other. How do I fix the files?

    11 September 2023, by Señor Tonto

    I am creating a win32 API C++ application with Microsoft Visual Studio 2022 in a .sln file. I've got quite far in basic functionalities & decided to try out video decoding & playing; I've practiced this before but not with C++. So, I looked to see good libraries & found FFmpeg. Of course, I thought this would be quite straightforward - just import the headers & code, right? No. Firstly, the FFmpeg I'm using is one of the pre-built binaries. The 'ffmpeg-master-latest-win64-gpl-shared.zip' From the BtbN Github repository. I decompressed it with WinRar & placed the files in Program Files (x86). Later on, I realised my mistake of placing it with 32-bit programs since it's a 64-bit build. So I transferred it to Program Files. Even after this though my issue persists. The issue being that the .h files of FFmpeg cannot communicate with each other. For some reason, they can't navigate to where the header files are. I am quite sure the reason for this may have something to do with where I save the files, the directory. Nowhere on the FFmpeg website can I see where you're expected to have the file directory at. I am sure there's a preset file path that is expected. Maybe I've named the FFmpeg folder incorrectly? Or maybe it's not meant to go in Program Files? The current directory for the FFmpeg folder for me is: C:\Program Files\FFmpeg. Below I will provide pictures of the errors I get where the code can't connect to other .h files as well as the file path. I'll also provide my code.

    &#xA;

    #include  //imports the main win32 API library&#xA;#include  //imports macros for handling Unicode &amp; ASCII char sets&#xA;#include  //defines the common control classes&#xA;#include  //imports the standard C library&#xA;#include &#xA;#include &#xA;#include <iostream>&#xA;#include <fstream>&#xA;#include <string>&#xA;&#xA;extern "C"&#xA;{&#xA;#include &#xA;#include &#xA;#include &#xA;#include &#xA;}&#xA;&#xA;#pragma comment(lib, "Comctl32.lib") //tells the linker to include Comctl32.lib in the .exe&#xA;#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avcodec.lib")&#xA;#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avformat.lib")&#xA;#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\avutil.lib")&#xA;#pragma comment(lib, "C:\\Program Files\\FFmpeg\\lib\\swscale.lib")&#xA;&#xA;#define EDIT_CONTROL 1&#xA;#define OPEN_FILE_BTN 2&#xA;#define SAVE_FILE_BTN 3&#xA;#define EMBOLDEN_BTN 4&#xA;#define ITALICISE_BTN 5&#xA;#define SCROLL_CONTAINER 6&#xA;#define FILEMENU_OPEN_FILE_BTN 7&#xA;#define ADD_ROW_BTN 8&#xA;#define CELL_1_ID 9&#xA;#define CELL_2_ID 10&#xA;#define CELL_3_ID 11&#xA;#define SCROLL_CONTAINER_TBL 12&#xA;// 946 0759 0609 | 163 739&#xA;&#xA;HINSTANCE g_hInstance;&#xA;HWND g_hWndMain, g_hWndTabs, openFileBtn, saveFileBtn, hOpenFileEdit, hScrollContainer, hEditControl, tabHandle, emboldenBtn, italiciseBtn, FilemenuOpenFileBtn, tableContainer, tblHeaderOne,&#xA;tblHeaderTwo, tblHeaderThree, addRowBtn, hAddRowDialogue, hWnd, hWndCell1Label, hWndCell1Edit, hWndCell2Label, hWndCell2Edit, hWndCell3Label, hWndCell3Edit, hWndOkButton, hWndCancelButton, hRow, hCell1, hCell2, hCell3,&#xA;hWMP, OpenMp4Btn, hWMPContainer, hPlayBtn;&#xA;HMENU  hMenu, hSubMenu;&#xA;bool isBold = false, isItalic = false;&#xA;&#xA;&#xA;const int startX = 0;&#xA;const int startY = 60;&#xA;const int ROW_HEIGHT = 20;&#xA;const int CELL_WIDTH = 110;&#xA;static int numRows = 1;&#xA;static int numCols = 3;&#xA;&#xA;LRESULT CALLBACK WindowProcessMessages(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);&#xA;INT_PTR CALLBACK AddRowDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);&#xA;&#xA;int WINAPI wWinMain(&#xA;    _In_ HINSTANCE currentInstance,&#xA;    _In_opt_ HINSTANCE previousInstance,&#xA;    _In_ LPWSTR cmdLine,&#xA;    _In_ int cmdCount)&#xA;{&#xA;    const wchar_t* CLASS_NAME = L"Windows App";&#xA;    WNDCLASS wc{};&#xA;    wc.hInstance = currentInstance;&#xA;    wc.lpszClassName = CLASS_NAME;&#xA;    wc.hCursor = LoadCursor(nullptr, IDC_ARROW);&#xA;    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;&#xA;    wc.lpfnWndProc = WindowProcessMessages;&#xA;    RegisterClass(&amp;wc);&#xA;&#xA;    g_hWndMain = CreateWindow(CLASS_NAME, L"Windows App",&#xA;        WS_OVERLAPPEDWINDOW,&#xA;        CW_USEDEFAULT, CW_USEDEFAULT,&#xA;        800, 600,&#xA;        nullptr, nullptr, nullptr, nullptr);&#xA;&#xA;    if (g_hWndMain == NULL) {&#xA;        return 0;&#xA;    }&#xA;&#xA;    // Initialize common controls&#xA;    INITCOMMONCONTROLSEX icex;&#xA;    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);&#xA;    icex.dwICC = ICC_TAB_CLASSES;&#xA;    InitCommonControlsEx(&amp;icex);&#xA;&#xA;    // Create tab control&#xA;    g_hWndTabs = CreateWindow(WC_TABCONTROL, L"",&#xA;        WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | TCS_SINGLELINE,&#xA;        0, 0, 800, 600,&#xA;        g_hWndMain, nullptr, currentInstance, nullptr);&#xA;&#xA;    if (g_hWndTabs == NULL) {&#xA;        return 0;&#xA;    }&#xA;&#xA;    // Add tabs to tab control, seperate tab later&#xA;    TCITEM tcitem;&#xA;    tcitem.mask = TCIF_TEXT;&#xA;&#xA;    wchar_t buf1[] = L"Table View";&#xA;    tcitem.pszText = buf1;&#xA;    TabCtrl_InsertItem(g_hWndTabs, 0, &amp;tcitem);&#xA;&#xA;    wchar_t buf2[] = L"Text Files";&#xA;    tcitem.pszText = buf2;&#xA;    TabCtrl_InsertItem(g_hWndTabs, 1, &amp;tcitem);&#xA;&#xA;    wchar_t buf3[] = L"mp4 Files";&#xA;    tcitem.pszText = buf3;&#xA;    TabCtrl_InsertItem(g_hWndTabs, 2, &amp;tcitem);&#xA;&#xA;&#xA;&#xA;    //original location of button intitialisation&#xA;&#xA;&#xA;    ShowWindow(g_hWndMain, SW_SHOWDEFAULT);&#xA;    UpdateWindow(g_hWndMain);&#xA;&#xA;    MSG msg{};&#xA;    while (GetMessage(&amp;msg, nullptr, 0, 0)) {&#xA;        TranslateMessage(&amp;msg);&#xA;        DispatchMessage(&amp;msg);&#xA;    }&#xA;    return 0;&#xA;}&#xA;&#xA;</string></fstream></iostream>

    &#xA;

    I severely doubt my code has anything to do with the issue though. It's probably directory-based. I just placed wWinmain here to keep with the character limit.

    &#xA;

    The .h files can't find each other&#xA;The file path for the FFmpeg files

    &#xA;

  • Revision 29902: - mise à jour de l’appel des #SAISIE (celles qui risquent un plantage en ...

    16 July 2009, by marcimat@… — Log

    - mise à jour de l’appel des #SAISIE (celles qui risquent un plantage en priorité)
    - mise à jour du plugin.xml