Recherche avancée

Médias (2)

Mot : - Tags -/media

Autres articles (99)

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

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (13281)

  • Segmentation fault caused by FFMPEG / SFML on Macos

    12 avril 2024, par Med ali Damergi ReTr0

    I'm trying to code a basic video player function to use it in a game it's supposed to get a sfml window and a video link as inputs and run the video :

    


    extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libswscale></libswscale>swscale.h>&#xA;#include <libavutil></libavutil>imgutils.h>&#xA;}&#xA;&#xA;#include <sfml></sfml>Graphics.hpp>&#xA;#include <iostream>&#xA;&#xA;const AVCodec* pCodec = nullptr;&#xA;&#xA;&#xA;void lecteurVideo(const std::string&amp; videoPath, sf::RenderWindow&amp; window) {&#xA;    // Open the video file&#xA;    AVFormatContext* pFormatCtx = avformat_alloc_context();&#xA;    if (avformat_open_input(&amp;pFormatCtx, videoPath.c_str(), nullptr, nullptr) != 0) {&#xA;        std::cerr &lt;&lt; "Failed to open video file" &lt;&lt; std::endl;&#xA;        return;&#xA;    }&#xA;&#xA;    // Retrieve stream information&#xA;    if (avformat_find_stream_info(pFormatCtx, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to retrieve stream information" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Find the first video stream&#xA;    int videoStreamIndex = -1;&#xA;    for (unsigned int i = 0; i &lt; pFormatCtx->nb_streams; i&#x2B;&#x2B;) {&#xA;        if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {&#xA;            videoStreamIndex = i;&#xA;            break;&#xA;        }&#xA;    }&#xA;    if (videoStreamIndex == -1) {&#xA;        std::cerr &lt;&lt; "Failed to find video stream" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Get the codec parameters for the video stream&#xA;    AVCodecParameters* pCodecParams = pFormatCtx->streams[videoStreamIndex]->codecpar;&#xA;&#xA;    // Find the decoder for the video stream&#xA;    const AVCodec* pCodec = avcodec_find_decoder(pCodecParams->codec_id);&#xA;    if (pCodec == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to find video decoder" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Allocate a codec context for the decoder&#xA;    AVCodecContext* pCodecCtx = avcodec_alloc_context3(pCodec);&#xA;    if (pCodecCtx == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate codec context" &lt;&lt; std::endl;&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Initialize the codec context with the codec parameters&#xA;    if (avcodec_parameters_to_context(pCodecCtx, pCodecParams) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to initialize codec context" &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Open the codec&#xA;    if (avcodec_open2(pCodecCtx, pCodec, nullptr) &lt; 0) {&#xA;        std::cerr &lt;&lt; "Failed to open codec" &lt;&lt; std::endl;&#xA;        avcodec_free_context(&amp;pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a frame to hold the decoded video data&#xA;    AVFrame* pFrame = av_frame_alloc();&#xA;    if (pFrame == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate frame" &lt;&lt; std::endl;&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a packet for reading compressed video data&#xA;    AVPacket* pPacket = av_packet_alloc();&#xA;    if (pPacket == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to allocate packet" &lt;&lt; std::endl;&#xA;        av_frame_free(&amp;pFrame);&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create a software scaler context for converting the video frame format&#xA;    SwsContext* pSwsCtx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt,&#xA;                                         pCodecCtx->width, pCodecCtx->height, AV_PIX_FMT_RGB24,&#xA;                                         SWS_BILINEAR, nullptr, nullptr, nullptr);&#xA;    if (pSwsCtx == nullptr) {&#xA;        std::cerr &lt;&lt; "Failed to create software scaler context" &lt;&lt; std::endl;&#xA;        av_packet_free(&amp;pPacket);&#xA;        av_frame_free(&amp;pFrame);&#xA;        avcodec_close(pCodecCtx);&#xA;        avformat_close_input(&amp;pFormatCtx);&#xA;        return;&#xA;    }&#xA;&#xA;    // Create an SFML texture and sprite for displaying the video frames&#xA;    sf::Texture texture;&#xA;    sf::Sprite sprite;&#xA;&#xA;    // Read frames from the video file and display them in the SFML window&#xA;    while (av_read_frame(pFormatCtx, pPacket) >= 0) {&#xA;        if (pPacket->stream_index == videoStreamIndex) {&#xA;            // Decode the video packet into a frame&#xA;            if (avcodec_send_packet(pCodecCtx, pPacket) &lt; 0) {&#xA;                std::cerr &lt;&lt; "Failed to send packet to decoder" &lt;&lt; std::endl;&#xA;                break;&#xA;            }&#xA;            if (avcodec_receive_frame(pCodecCtx, pFrame) &lt; 0) {&#xA;                std::cerr &lt;&lt; "Failed to receive frame from decoder" &lt;&lt; std::endl;&#xA;                break;&#xA;            }&#xA;&#xA;            // Convert the frame format to RGB24&#xA;            uint8_t* rgbBuffer = new uint8_t[pCodecCtx->width * pCodecCtx->height * 3];&#xA;            uint8_t* rgbPlanes[1] = { rgbBuffer };&#xA;            int rgbStrides[1] = { pCodecCtx->width * 3 };&#xA;            sws_scale(pSwsCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height,&#xA;                      rgbPlanes, rgbStrides);&#xA;&#xA;            // Update the SFML texture with the RGB24 data&#xA;            texture.create(pCodecCtx->width, pCodecCtx->height);&#xA;            texture.update(rgbBuffer);&#xA;&#xA;            // Display the texture in the SFML window&#xA;            sprite.setTexture(texture);&#xA;            window.clear();&#xA;            window.draw(sprite);&#xA;            window.display();&#xA;&#xA;            delete[] rgbBuffer;&#xA;        }&#xA;&#xA;        av_packet_unref(pPacket);&#xA;    }&#xA;&#xA;    // Clean up resources&#xA;    av_packet_free(&amp;pPacket);&#xA;    av_frame_free(&amp;pFrame);&#xA;    avcodec_close(pCodecCtx);&#xA;    avformat_close_input(&amp;pFormatCtx);&#xA;    sws_freeContext(pSwsCtx);&#xA;}&#xA;&#xA;int main() {&#xA;    sf::RenderWindow window(sf::VideoMode(800, 600), "Lecteur Video SFML");&#xA;    lecteurVideo("/Users/mac/cours/spaceRevolution/Videos/58e62585-c143-483a-9149-b401ebc01d02.mp4", window);&#xA;    return 0;&#xA;}&#xA;</iostream>

    &#xA;

    It works on my other computer running on ubuntu but not on my main laptop on macOS : It dosent open any window and instantly cause a segmentation fault.

    &#xA;

    I've tried tu run valgrind on it but valgrind dosent run well on macOS.

    &#xA;

    Could anybody help me with this ?

    &#xA;

  • How do i gain access to subproccess.py ?

    15 décembre 2023, par Kronik71

    So, my bot for some reason wants to access a folder in \WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\Lib called subproccess.py but it always gives the error : PermissionError: [WinError 5] Access is denied. I think it has to do with ffmpeg.

    &#xA;

    Here's the full traceback (kinda long) :

    &#xA;

    Traceback (most recent call last):&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py", line 1900, in __dispatch_interaction&#xA;    response = await callback&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\client\client.py", line 1771, in _run_slash_command&#xA;    return await command(ctx, **ctx.kwargs)&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\command.py", line 132, in __call__&#xA;    await self.call_callback(self.callback, context)&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\application_commands.py", line 802, in call_callback&#xA;    return await self.call_with_binding(callback, ctx)&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\interactions\models\internal\callback.py", line 43, in call_with_binding&#xA;    return await callback(*args, **kwargs)&#xA;  File "C:\Users\myuser\OneDrive\Desktop\button.py", line 38, in press&#xA;    voice_client.play(discord.FFmpegPCMAudio(executable=r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin", source=audiosource))&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.Bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 290, in __init__&#xA;    super().__init__(source, executable=executable, args=args, **subprocess_kwargs)&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 166, in __init__&#xA;    self._process = self._spawn_process(args, **kwargs)&#xA;  File "C:\Users\myuser\AppData\Local\Packages\PythonSoftwareFoundation.Python.bunch_of_numbers\LocalCache\local-packages\Python310\site-packages\discord\player.py", line 180, in _spawn_process&#xA;    process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs)&#xA;  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\lib\subprocess.py", line 971, in __init__&#xA;    self._execute_child(args, executable, preexec_fn, close_fds,&#xA;  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.bunch_of_numbers\lib\subprocess.py", line 1456, in _execute_child&#xA;    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,&#xA;PermissionError: [WinError 5] Access is denied&#xA;

    &#xA;

    heres my code :

    &#xA;

    import interactions&#xA;import discord&#xA;from discord import FFmpegPCMAudio&#xA;import tracemalloc&#xA;&#xA;ffmpegexec = r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin\ffmpeg.exe"&#xA;&#xA;audiosource = r"C:\Users\myuser\Downloads\seatbelt-online-audio-converter.mp3"&#xA;&#xA;source = discord.FFmpegPCMAudio(audiosource)&#xA;&#xA;token = "my_token"&#xA;&#xA;bot = interactions.Client(token=token)&#xA;&#xA;tracemalloc.start()&#xA;&#xA;@interactions.slash_command(&#xA;    name="joinvc",&#xA;    description="starts the game"&#xA;)&#xA;&#xA;async def joinvc(ctx: interactions.ComponentContext):&#xA;    await ctx.send("Joining vc. Please make sure you are currently in a vc!")&#xA;    vc = ctx.author.voice.channel&#xA;    await vc.connect()&#xA;&#xA;@interactions.slash_command(&#xA;    name="press",&#xA;    description="Press the button"&#xA;)&#xA;&#xA;async def press(ctx: interactions.ComponentContext):&#xA;    await ctx.send(f"{ctx.author.mention} has pressed the button")&#xA;    vc = ctx.author.voice.channel&#xA;    voice_client = await vc.connect()  # Connect to the voice channel&#xA;&#xA;voice_client.play(discord.FFmpegPCMAudio(executable=r"C:\Users\myuser\OneDrive\Desktop\ffmpeg-6.1-essentials_build\bin", source=audiosource))&#xA;&#xA;&#xA;bot.start(token)&#xA;

    &#xA;

    All of my code is above. I'm not exactly good at writing python, might just be something I'm misunderstanding. I just want it to play a noise in a discord voice chat when the /press command is used.

    &#xA;

  • avcodec/sanm : codec37 : reimplement comp4

    11 mars, par Manuel Lauss
    avcodec/sanm : codec37 : reimplement comp4
    

    Compression 4 code 0 means copy from delta buffer without mv,
    AND start of a skip run. This gets rid of the extra case and column
    index manipulation and implements this as it is implemented in the
    original game exe, i.e. as a special case for after mv copy.

    Signed-off-by : Manuel Lauss <manuel.lauss@gmail.com>

    • [DH] libavcodec/sanm.c