
Recherche avancée
Autres articles (111)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa 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 (...)
Sur d’autres sites (6421)
-
Need help to create a queue system with a discord.py bot
19 août 2024, par Zamvim trying to create a bot with discord.py, i'll start saying that the bot is for personal use so please don't point out that i shouldn't use ydl in the comments, ty :
Also, im a beginner, so please tell me what I can improve and any errors there are, I will be happy to listen.
That said, i've been stuck on trying to create this queue system for songs for the past 3 days, 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, but please i really need to know how to make this work


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)



thanks in advance, i will try to read and answer any questions as soon as possible


-
Different results between windows and Linux in opencv c++
24 mars 2020, par SamerI have tried this opencv and ffmpeg C++ code to demux a video and edit it and mux it back again but it doesn’t seem to work properly on windows (using Visual Studio)
the problem occurs by skipping some frames especially at the end of the video and increasing the video output size not on all windows PCs. We have tried it on a 35 MB video and when we did the editing the output video size was 2.8GB on some windows PCs and the last frames skipped (the problem) and some other PCs the output video size was 500MB and there were no skipped frames (all fine).
so the question is, why would the same code with the same build and windows versions behave differently and produce problems on some Pcs ?
(we also did it on linux ubuntu and macos and it was working fine on different PCs)
https://github.com/WajdiMuh/parallelalgo for the files
https://gjuedujo-my.sharepoint.com/personal/m_albizreh1_gju_edu_jo/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fm%5Falbizreh1%5Fgju%5Fedu%5Fjo%2FDocuments%2FParallel%20Project%2Fbinr&originalPath=aHR0cHM6Ly9nanVlZHVqby1teS5zaGFyZXBvaW50LmNvbS86ZjovZy9wZXJzb25hbC9tX2FsYml6cmVoMV9nanVfZWR1X2pvL0VzaHFWNDJCVThkQ25KOFV0dm82NHJNQmdoOWdCeEZOblkwQWtRMkQ0MU5UV3c_cnRpbWU9TTl4Zi1YblAxMGc for the release version (vidd.MP4 is the video)
Thanks in Advance
-
FFmpeg truncates untrunc'ed video
18 mars 2020, par petrpulcBackground : Colleague's Panasonic consumer camera had issues with high-capacity SD card and yielded two different types of truncated files (
mp4
andmdt
) with both header and index corrupted. Both were "fixable" with following steps :


- 

- Locate with hex editor the ascii sequence "mdat" in both a truncated and a corresponding known good file. In
mp4
the "mdat" is quite deep in the file as it contains some (but bad) headers, themdt
type almost starts with it. - Replace everything up to the "mdat" sequence with known good header. BUT this also means that metadata on length are copied over.
- Run https://github.com/ponchio/untrunc on the file with corrected header (it refused to run on original files).
- Profit ! VLC plays the file fine, ffprobe shows correct length. BUT ffmpeg encoding stops at the end timecode of the file I taken the known good header from in step 2.
- A somewhat ugly solution is to recode the file in VLC (video copy seems to be breaking file up again).













I am wondering if I overlooked something ; big time. I guess I do, but simple timecode operations on input file do not seem to have any effect at all.



Is there a way to persuade ffmpeg to encode the whole file that ffprobe and VLC see ?



Files may be provided for analysis on personal basis only, sorry.


- Locate with hex editor the ascii sequence "mdat" in both a truncated and a corresponding known good file. In