Recherche avancée

Médias (91)

Autres articles (89)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

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

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

  • ffmpeg doesn't work, when starting up it doesn't play music, it gives errors

    14 août 2024, par Оля Михеева
    import discord&#xA;from discord import FFmpegPCMAudio&#xA;import os&#xA;import random&#xA;from gtts import gTTS&#xA;import asyncio&#xA;&#xA;TOKEN="***"&#xA;VOICE_CHANNEL_ID=11122224444&#xA;&#xA;class Voice_Bot(discord.Client):&#xA;    def __init__(self):&#xA;        intents = discord.Intents.default()&#xA;        intents.message_content = True&#xA;        intents.voice_states=True&#xA;        super().__init__(intents=intents)&#xA;        print(os.getcwd())&#xA;        self.sounds_hello = os.listdir(os.path.join(&#x27;sounds&#x27;,&#x27;hello&#x27;))&#xA;        self.sounds_bye = os.listdir(&#x27;sounds\\bye&#x27;)&#xA;        self.sounds = os.listdir(&#x27;sounds\\nature&#x27;)&#xA;&#xA;    async def on_ready(self):        &#xA;        self.voice_channel = self.get_channel(VOICE_CHANNEL_ID) &#xA;        if self.voice_channel == None:&#xA;            print(&#x27;Не удалось подключиться к голосовому каналу.&#x27;)&#xA;            return&#xA;        self.voice_client = await self.voice_channel.connect()&#xA;        print(&#x27;Бот подключен к голосовому каналу&#x27;)&#xA;        await self.text_to_speech("Lets play Guess the Tune")&#xA;        &#xA;    async def on_message(self,message):&#xA;        if message.author==self.user:&#xA;            return&#xA;        if message.content.startswith("game"):&#xA;            await self.text_to_speech("let&#x27;s start the game guess the melody")&#xA;            music=os.listdir("sounds\\music")&#xA;            self.melody=random.choice(music)&#xA;            await self.play_sound(f"sounds\\music\\{self.melody}")&#xA;        elif message.content==self.melody[0:len(self.melody)-4]:&#xA;            if (self.voice_client.is_playing()):&#xA;                self.voice_client.stop()&#xA;            await self.text_to_speech(f"Congratulations, {message.author.name} answered correctly! To continue, type game")&#xA;        else:&#xA;            if (self.voice_client.is_playing()):&#xA;                self.voice_client.stop()&#xA;            await self.text_to_speech(f"Unfortunately, {message.author.name} did not guess. To continue, write game")&#xA;&#xA;&#xA;    async def on_voice_state_update(self,member,before,after):&#xA;        if member.id ==self.user.id:&#xA;            print(&#x27;Someone entered or left the voice channel.&#x27;)&#xA;        else:&#xA;            try:&#xA;                if before.channel == None:&#xA;                    print(f&#x27;{member.name} entered the voice channel {after.channel}.&#x27;)&#xA;                    await self.play_sound(f&#x27;sounds\\hello\\{random.choice(self.sounds_hello)}&#x27;)&#xA;                elif after.channel == None:&#xA;                    print(f&#x27;{member.name} left the voice channel {before.channel}.&#x27;)&#xA;                    await self.play_sound(f&#x27;sounds\\bye\\{random.choice(self.sounds_bye)}&#x27;)&#xA;            except Exception as e:&#xA;                print(f"Error in on_voise_state_update: {e}")&#xA;&#xA;    async def text_to_speech(self,text):&#xA;        try:&#xA;            tts = gTTS(text=text, lang ="en")&#xA;            tts.save("text.mp3")&#xA;        except Exception as e:&#xA;            print(f"Error e: {e}")&#xA;        await self.voice_channel.send(text)&#xA;        await self.play_sound("text.mp3")&#xA;&#xA;    def play_sound(self,path):&#xA;        print(path)&#xA;        source=discord.FFmpegPCMAudio(source=path, executable="ffmpeg\\bin\\ffmpeg.exe")&#xA;        if (self.voice_client.is_playing()):&#xA;            self.voice_client.stop()&#xA;        self.voice_client.play(source)                &#xA;&#xA;client = Voice_Bot()&#xA;client.run(TOKEN)&#xA;

    &#xA;

    [enter image description here](https://i.sstatic.net/ys8Xza0w.jpg)

    &#xA;

  • avcodec/sanm : better frame size detection for old codecs

    11 mars, par Manuel Lauss
    avcodec/sanm : better frame size detection for old codecs
    

    The size of the video frame (FOBJ) of the old codecs (ANIMv0/1/2) can
    very reliably be determined :
    - ANIMv0/1 (=Rebel Assault 1) uses a 384x242 internal buffer for
    everything. The codec parameters only describe the size and offset
    of the specific FOBJ on that buffer.
    - ANIMv2 titles usually use one of the fullscreen codecs (37/47/48)
    as first FOBJ, and their dimensions can generally be trusted.
    - RA2 uses 424x260 as internal buffer, use that if encountered :
    08PLAY.SAN does not use codec37 so we need to guess using the
    codec coordinates.
    - ignore sizes smaller than 2x2 or larger than 800x600.
    - some game videos have an initial fobj with either 1x1 or -1x-1
    pixels in size, ignore them with a warning (Full Throttle
    and the Rebel Assault 2 xxRETRY.SAN videos).

    Once a known/valid dimension set has been discovered, use it and
    don't change it for subsequent FOBJs, rather clamp the large frame
    to the determined dimensions.

    Tested with RA1, RA2, Full Throttle, Dig, Outlaws, SotE and MotS
    videos.

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

    • [DH] libavcodec/sanm.c