Recherche avancée

Médias (2)

Mot : - Tags -/doc2img

Autres articles (61)

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

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (7565)

  • Feeding raw image bytes into ffmpeg rawvideo fails with Invalid buffer size on linux only

    13 février 2021, par cherouvim

    I have a nodejs program which generates raw (rgb24) image(s), which I then pipe into ffmpeg so it saves as png or mp4. My code looks like this :

    


    const fs = require("fs");
// ...
const outputBuffer = Buffer.alloc(outputPngWidth * 3 * outputPngHeight);
// ... write data into outputBuffer
fs.writeSync(process.stdout.fd, outputBuffer);


    


    I then do the following in CLI :

    


    node generate | ffmpeg -f rawvideo -pixel_format rgb24 -video_size 1000x1000 -i - test.png


    


    Alternatively, if I generate lots of images from my program, I do this to generate the video file :

    


    node generate | ffmpeg -f rawvideo -pixel_format rgb24 -video_size 1000x1000 -r 60 -i - -codec:v libx265 test.mp4


    


    On windows this works flawlessly. On linux (either on Ubuntu 20 VM, or Ubuntu 20 installed directly on a physical machine), it consistently fails with :

    


    pipe:: corrupt input packet in stream 0
[rawvideo @ 0x55f5256c8040] Invalid buffer size, packet size 65536 < expected frame_size 3000000
Error while decoding stream #0:0: Invalid argument


    


    If I split this in 2 phases like so, then it works perfectly on linux as well :

    


    node generate > test.raw
cat test.raw | ffmpeg -f rawvideo -pixel_format rgb24 -video_size 1000x1000 -i - test.png


    


    By looking at the error "packet size 65536 < expected frame_size 3000000" it seems that node's fs.writeSync only sends 65536 bytes at a time, but ffmpeg expects 3000000 bytes (that is 1000 width * 1000 height * 3 channels).

    &#xA;

    If I reduce my image size to something small, e.g 50x50 or 100x100, then it works. As soon as x * y * 3 exceeds 65536, it fails (eg. 160x160 fails with "packet size 65536 < expected frame_size 76800" because 160 * 160 * 3 = 76800).

    &#xA;

    What I've tried so far to solve the issue without luck :

    &#xA;

      &#xA;
    • Force node to spit out the whole buffer at once :
    • &#xA;

    &#xA;

    fs.writeSync(process.stdout.fd, outputBuffer, 0, outputBuffer.length);&#xA;

    &#xA;

    &#xA;

    Is there a way to overcome this ?

    &#xA;

  • How to create a queue system with a discord.py bot

    20 août 2024, par Zamv

    I'm trying to create a bot with discord.py.

    &#xA;

    Also, I'm a beginner, so I'll be interested in what I can improve and any errors there are.

    &#xA;

    I've been stuck on trying to create this queue system for songs, the bot was working perfectly fine and played some urls before I implemented the play_next function. Now it doesn't even play the first song, even if it sends confirmation messages both in the terminal that in the discord channel. I know that the code might be a little confusing.

    &#xA;

    I wrote two main functions : "play_next" to play the next song in the queue and "play", the main command. Here is my play_next function :

    &#xA;

    async def play_next(self,ctx):&#xA;        if not ctx.voice_client.is_playing: #(don&#x27;t know if this is correct as I also check if the bot isn&#x27;t                     playing anything in the play function)&#xA;            &#xA;            if self.song.queue: &#xA;                next_song = self.song_queue.pop(0) #deleting the first element of the queue, so if we have (song_0, song_1 and song_2) the bot should delete (song_0) making in fact song_1 the "next" song_0&#xA;                try:&#xA;                    ctx.voice_client.play(discord.FFmpegPCMAudio(next_song), &#xA;                                          after=lambda e: self.bot.loop.create_task(self.play_next(ctx))) #Not gonna lie here, i asked chat gpt for this line, it should make the bot automatically play the next song one after another, correct me if I am wrong&#xA;&#xA;#this is not important&#xA;                    embed = discord.Embed(&#xA;                        title="Song",&#xA;                        description=f"Now playing {next_song}",&#xA;                        color = 0x1DB954&#xA;                    )&#xA;                    await ctx.send(embed=embed)&#xA;                except Exception as e:&#xA;                    print(f"Error playing the next song: {e}")&#xA;&#xA;            else:&#xA;                await ctx.voice_client.disconnect()  # disconnecting from the voice channel if the queue is empty&#xA;                print("Disconnected from the voice channel as the queue is empty.")&#xA;

    &#xA;

    I think that the main problem of my bot is the play_next function, but here it is my "play" function :

    &#xA;

        @commands.command(pass_context=True)&#xA;    async def play(self, ctx, url: str):  &#xA;        if ctx.author.voice:  # first checking if the user is in a voice channel&#xA;            if not ctx.voice_client: #then checking if the bot is already connected to a voice channel&#xA;                channel = ctx.message.author.voice.channel &#xA;                try:&#xA;                    await channel.connect()  #then joining&#xA;                    print("I joined the voice channel!")&#xA;                except Exception as e:&#xA;                    print(f"Failed to connect to the voice channel: {e}")&#xA;                    return&#xA;&#xA;            song_path = f"song_{self.song_index}.mp3" #note, im using cogs, i declared self.song_index with the value of 0 &#xA;            self.song_index &#x2B;= 1 #i thought that this was the easiest way of creating a new file for each song&#xA;&#xA;            ydl_opts = {&#xA;                &#x27;format&#x27;: &#x27;bestaudio/best&#x27;,&#xA;                &#x27;postprocesors&#x27;: [{&#xA;                    &#x27;key&#x27;: &#x27;FFmpegExtractAudio&#x27;,&#xA;                    &#x27;preferredcodec&#x27;: &#x27;mp3&#x27;,&#xA;                    &#x27;preferredquality&#x27;: &#x27;192&#x27;,&#xA;                }],&#xA;                &#x27;outtmpl&#x27;: song_path&#xA;            }&#xA;            try:&#xA;                with youtube_dl.YoutubeDL(ydl_opts) as ydl:&#xA;                    print("Starting download...")&#xA;                    ydl.download([url]) #this is where it should download the song provided by the url&#xA;                    print("Download finished.")&#xA;            except Exception as e:&#xA;                await ctx.send(f"Failed to download the song: {e}")&#xA;                return&#xA;&#xA;#i think that the next two if statements are the main threats&#xA;            if os.path.exists(song_path): #if there is atleast 1 song in the queue&#xA;                self.song_queue.append(song_path) #append the next one&#xA;                embed = discord.Embed(&#xA;                    title="Added to Queue!",&#xA;                    description = f"{url} has been added to the queue.",&#xA;                    color=0x33ff33&#xA;                )&#xA;                await ctx.send(embed=embed)&#xA;&#xA;&#xA;                if not ctx.voice_client.is_playing(): #checking if the bot is already playing something, don&#x27;t know if i should put this if statement here&#xA;                    print("Starting playback...")&#xA;                    await self.play_next(ctx) #if nothing is playing, then the bot should play the next song&#xA;&#xA;&#xA;&#xA;            else:&#xA;                await ctx.send("Failed to download or find the audio file.")&#xA;&#xA;        else:&#xA;            embed = discord.Embed(&#xA;                title="❌You must be in a voice channel",&#xA;                color=0xff6666&#xA;            )&#xA;            await ctx.send(embed=embed)&#xA;

    &#xA;

  • Why doesn't the ffmpeg output display the stream in the browser ? [closed]

    10 mai 2024, par Tebyy

    Why is it that when I create a livestream in Python using ffmpeg, and then I open the browser and visit the page, the page keeps loading continuously, and in PyCharm logs, I see binary data ? There are no errors displayed, and the code seems correct to me. I even tried saving to a file for testing purposes, and when I play the video, everything works fine. Does anyone know what might be wrong here ?

    &#xA;

    Code :

    &#xA;

    def generate_frames():&#xA;    cap = cv2.VideoCapture(os.path.normpath(app_root_dir().joinpath("data/temp", "video-979257305707693982.mp4")))&#xA;    while cap.isOpened():&#xA;        ret, frame = cap.read()&#xA;        if not ret:&#xA;            break&#xA;&#xA;        yield frame&#xA;&#xA;&#xA;@app.route(&#x27;/video_feed&#x27;)&#xA;def video_feed():&#xA;    ffmpeg_command = [&#xA;        &#x27;ffmpeg&#x27;, &#x27;-f&#x27;, &#x27;rawvideo&#x27;, &#x27;-pix_fmt&#x27;, &#x27;bgr24&#x27;,&#xA;        &#x27;-s:v&#x27;, &#x27;1920x1080&#x27;, &#x27;-r&#x27;, &#x27;60&#x27;,&#xA;        &#x27;-i&#x27;, &#x27;-&#x27;, &#x27;-vf&#x27;, &#x27;setpts=2.5*PTS&#x27;, # Video Speed&#xA;        &#x27;-c:v&#x27;, &#x27;libvpx-vp9&#x27;, &#x27;-g&#x27;, &#x27;60&#x27;, &#x27;-keyint_min&#x27;, &#x27;60&#x27;,&#xA;        &#x27;-b:v&#x27;, &#x27;6M&#x27;, &#x27;-minrate&#x27;, &#x27;4M&#x27;, &#x27;-maxrate&#x27;, &#x27;12M&#x27;, &#x27;-bufsize&#x27;, &#x27;8M&#x27;,&#xA;        &#x27;-crf&#x27;, &#x27;0&#x27;, &#x27;-deadline&#x27;, &#x27;realtime&#x27;, &#x27;-tune&#x27;, &#x27;psnr&#x27;, &#x27;-quality&#x27;, &#x27;good&#x27;,&#xA;        &#x27;-tile-columns&#x27;, &#x27;6&#x27;, &#x27;-threads&#x27;, &#x27;8&#x27;, &#x27;-lag-in-frames&#x27;, &#x27;16&#x27;,&#xA;        &#x27;-f&#x27;, &#x27;webm&#x27;, &#x27;-&#x27;&#xA;    ]&#xA;    ffmpeg_process = subprocess.Popen(ffmpeg_command, stdin=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=-1)&#xA;    frames_generator = generate_frames()&#xA;    for frame in frames_generator:&#xA;        ffmpeg_process.stdin.write(frame)&#xA;        ffmpeg_process.stdin.flush()&#xA;&#xA;    ffmpeg_process.stdin.close()&#xA;    ffmpeg_process.wait()&#xA;&#xA;    def generate_video_stream(process):&#xA;        startTime = time.time()&#xA;        buffer = []&#xA;        sentBurst = False&#xA;        for chunk in iter(lambda: process.stderr.read(4096), b&#x27;&#x27;):&#xA;            buffer.append(chunk)&#xA;&#xA;            # Minimum buffer time, 3 seconds&#xA;            if sentBurst is False and time.time() > startTime &#x2B; 3 and len(buffer) > 0:&#xA;                sentBurst = True&#xA;                for i in range(0, len(buffer) - 2):&#xA;                    print("Send initial burst #", i)&#xA;                    yield buffer.pop(0)&#xA;&#xA;            elif time.time() > startTime &#x2B; 3 and len(buffer) > 0:&#xA;                yield buffer.pop(0)&#xA;&#xA;            process.poll()&#xA;            if isinstance(process.returncode, int):&#xA;                if process.returncode > 0:&#xA;                    print(&#x27;FFmpeg Error&#x27;, process.returncode)&#xA;&#xA;                break&#xA;&#xA;    return Response(stream_with_context(generate_video_stream(ffmpeg_process)), mimetype=&#x27;video/webm&#x27;, content_type="video/webm; codecs=vp9", headers=Headers([("Connection", "close")]))&#xA;&#xA;

    &#xA;