Recherche avancée

Médias (0)

Mot : - Tags -/formulaire

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (33)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • Contribute to documentation

    13 avril 2011

    Documentation is vital to the development of improved technical capabilities.
    MediaSPIP welcomes documentation by users as well as developers - including : critique of existing features and functions articles contributed by developers, administrators, content producers and editors screenshots to illustrate the above translations of existing documentation into other languages
    To contribute, register to the project users’ mailing (...)

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

Sur d’autres sites (2546)

  • Combining Video and Audio Buffers in Memory Using FFmpeg and Python

    22 août 2024, par RUBICK

    I need to combine video and audio streams into a single MP4 file. My goal is to handle this entirely in memory and then send the resulting file directly to the user without storing any files on disk.

    


    I am consistently facing problems with the FFmpeg process when trying to combine the video and audio streams

    


    @bot.callback_query_handler(func=lambda call: call.data.startswith("download_mp4"))
def handle_download_mp4(call):
    itag, url = call.data.split("|")[1:]
    yt = YouTube(url)
    
    video_stream = yt.streams.get_by_itag(itag)
    audio_stream = yt.streams.filter(only_audio=True).first()

    video_buffer = io.BytesIO()
    audio_buffer = io.BytesIO()

    # downloading video and audio to memory
    video_stream.stream_to_buffer(video_buffer)
    audio_stream.stream_to_buffer(audio_buffer)

    video_buffer.seek(0)
    audio_buffer.seek(0)
    combined_buffer = io.BytesIO()

    process = None
    try:
        process = (
            ffmpeg
            .input('pipe:0')
            .input('pipe:1')
            .output('pipe:2', format='mp4', vcodec='libx264', acodec='aac')
            .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True)
        )

        # video and audio buffers to ffmpeg stdin
        process.stdin.write(video_buffer.read())
        process.stdin.write(audio_buffer.read())
        process.stdin.close()

        combined_buffer.write(process.stdout.read())
        process.wait()
        combined_buffer.seek(0)
        
    except Exception as e:
        bot.send_message(call.message.chat.id, f"Error during processing: {str(e)}")
        if process:
            process.kill()
        return

    file_size = combined_buffer.getbuffer().nbytes

    if file_size > MAX_FILE_SIZE:
        bot.send_message(call.message.chat.id, "The combined file is too large to download :(")
        combined_buffer.close()
        return

    # sending combined bufer to user
    bot.send_document(call.message.chat.id, combined_buffer, visible_file_name=f"{yt.title}.mp4")


    


    Here's the workflow I'm aiming for :

    


    1. Download video and audio streams from YouTube.
2. Combine these streams in memory using FFmpeg.
3. Send the combined MP4 file to the user.

    


    Im using pytube to download the video and audio streams and ffmpeg to merge them. However, I'm encountering issues with the combination process. Specifically, I’m struggling with how to correctly handle merging the video and audio streams using in-memory buffers

    


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

    


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

    


    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.

    


    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 :

    


    async def play_next(self,ctx):
        if not ctx.voice_client.is_playing: #(don't know if this is correct as I also check if the bot isn't                     playing anything in the play function)
            
            if self.song.queue: 
                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
                try:
                    ctx.voice_client.play(discord.FFmpegPCMAudio(next_song), 
                                          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

#this is not important
                    embed = discord.Embed(
                        title="Song",
                        description=f"Now playing {next_song}",
                        color = 0x1DB954
                    )
                    await ctx.send(embed=embed)
                except Exception as e:
                    print(f"Error playing the next song: {e}")

            else:
                await ctx.voice_client.disconnect()  # disconnecting from the voice channel if the queue is empty
                print("Disconnected from the voice channel as the queue is empty.")


    


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

    


        @commands.command(pass_context=True)
    async def play(self, ctx, url: str):  
        if ctx.author.voice:  # first checking if the user is in a voice channel
            if not ctx.voice_client: #then checking if the bot is already connected to a voice channel
                channel = ctx.message.author.voice.channel 
                try:
                    await channel.connect()  #then joining
                    print("I joined the voice channel!")
                except Exception as e:
                    print(f"Failed to connect to the voice channel: {e}")
                    return

            song_path = f"song_{self.song_index}.mp3" #note, im using cogs, i declared self.song_index with the value of 0 
            self.song_index += 1 #i thought that this was the easiest way of creating a new file for each song

            ydl_opts = {
                'format': 'bestaudio/best',
                'postprocesors': [{
                    'key': 'FFmpegExtractAudio',
                    'preferredcodec': 'mp3',
                    'preferredquality': '192',
                }],
                'outtmpl': song_path
            }
            try:
                with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                    print("Starting download...")
                    ydl.download([url]) #this is where it should download the song provided by the url
                    print("Download finished.")
            except Exception as e:
                await ctx.send(f"Failed to download the song: {e}")
                return

#i think that the next two if statements are the main threats
            if os.path.exists(song_path): #if there is atleast 1 song in the queue
                self.song_queue.append(song_path) #append the next one
                embed = discord.Embed(
                    title="Added to Queue!",
                    description = f"{url} has been added to the queue.",
                    color=0x33ff33
                )
                await ctx.send(embed=embed)


                if not ctx.voice_client.is_playing(): #checking if the bot is already playing something, don't know if i should put this if statement here
                    print("Starting playback...")
                    await self.play_next(ctx) #if nothing is playing, then the bot should play the next song



            else:
                await ctx.send("Failed to download or find the audio file.")

        else:
            embed = discord.Embed(
                title="❌You must be in a voice channel",
                color=0xff6666
            )
            await ctx.send(embed=embed)


    


  • Scalable Webinar Features Using Open-Source Tools ? [closed]

    31 janvier, par Firas Ben said

    I am searching for a scalable webinar solution that can handle 1000+ concurrent users. I have explored platforms like BigBlueButton but encountered limitations with scalability in real-world scenarios.

    


    My requirements include :

    


      

    • Support for RTMP and HLS streaming.
    • 


    • Chat and screen-sharing functionalities.
    • 


    • Ability to integrate with custom APIs.
    • 


    


    I’d like to know how to address these challenges using open-source tools. For instance :

    


      

    • What configurations are necessary to scale tools like BigBlueButton for large audiences ?
    • 


    • Are there specific architectural patterns or server setups recommended for handling this user load ?
    • 


    


    Any guidance or examples would be appreciated.