
Recherche avancée
Autres articles (112)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains 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 ;
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP 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" (...)
Sur d’autres sites (14984)
-
aacsbr : optimize sine level addition
3 juin 2012, par Michael Niedermayeraacsbr : optimize sine level addition
-
Discord bot stops playing music at a certain iteration
3 mai 2023, par denisnumbI'm using the following code to play music in a discord voice channel :


import discord
import asyncio
from yt_dlp import YoutubeDL

YDL_OPTIONS = {
 'format': 'bestaudio/best', 
}

FFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 
 'options': '-vn'
}

bot = discord.Client(intents=discord.Intents.all())

async def get_source_url(url: str) -> str:
 with YoutubeDL(YDL_OPTIONS) as ydl:
 return ydl.extract_info(url, download=False).get('url')

@bot.slash_command(name='play')
async def __play(ctx, url: str) -> None:
 source = await get_source_url(url)
 vc = await ctx.author.voice.channel.connect()
 vc.play(discord.FFmpegPCMAudio(source=source, **FFMPEG_OPTIONS))

 while vc.is_playing() or vc.is_paused():
 await asyncio.sleep(1)

 await vc.disconnect()

bot.run('TOKEN')



The principle of operation is as follows :


- 

-
The
/play
command handler receives aurl
argument, in the form of a link to a live stream from YouTube : https://youtu.be/jfKfPfyJRdk (or any other video)

-
The link is passed to the
get_source_url
function, which, using theyt-dlp
library, returns a direct link to the sound from the video

-
The direct link is passed via
discord.FFmpegPCMAudio
to theffmpeg
program, which then returns audio bytes for transmission to the discord voice channel via thevc.play
method










Problem :


Bot is hosted on the virtual hosting server aeza, OS -
Ubuntu Server 22.04
. I installed theffmpeg
version4.4.2
with the commandsudo apt install ffmpeg
.

On the first day everything worked fine, but the next day the bot began to steadily stop playing music at the same moment in different videos (this moment is different for each video). Restarting the bot or server did not help.


Only reinstalling the operating system helps, but also only for one day.


Specific problem :


I checked the execution of every single line of the
discord.VoiceClient.play
method, including all methods called internally. It turned out that the bot hangs every time on the same iteration of the cycle of receiving and sending bytes. Namely, on the first line of thediscord.FFmpegPCMAudio.read
method, that is does not receive data fromffmpeg
and waits indefinitely.


Source of the problem :


The problem is not with a specific
ffmpeg
:

- 

- I also installed
ffmpeg
on another version5.1.2
and the problem was repeated on it.




The problem is not
Ubuntu Server
:

- 

- I changed OS
Ubuntu Server
toDebian 11
and it's the same there




The problem is not in
Linux
:

- 

- When I put the same OS on my virtual machine, everything worked fine with any version of
ffmpeg
.





So the problem is on the hosting side ? I asked those. support to change the server itself and the location of the location. Changed from Sweden to Germany - the same result.


If the data does not come from
ffmpeg
, then you need to find out what is wrong in the program itself. When calling, I pass the-loglevel debug
argument, which shows the most detailed report on the program's operation - all debugging information is displayed, but there are no errors on the "hung" iteration.

What could be the problem ?



UPD 03.05.2023 : I reinstalled OS Ubuntu Server again and the bot works now. But obviously not for long. Maybe I need to clear some cache ?


-
-
Evolution #2969 : Retourner message_ok et message_erreur sur un traitement CVT
18 novembre 2013, par cam.lafit -Salut
Oui retourner une erreur si il y a est logique :) Je ne remettais pas
en doute ce point.
C’est le fait de ne pouvoir dire que le verre est à moitié plein et à
moitié vide. Pour le moment c’est soit plein soit vide.Si on injecte le résultat positif dans le message d’erreur, il se
retrouver noyé dans le bloc erreur et ne profite pas de la mise en
forme réussie. On peut trouver des cas où l’erreur n’interdit pas la
réussite et vice versa.