
Recherche avancée
Médias (2)
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
Autres articles (94)
-
Les vidéos
21 avril 2011, parComme les documents de type "audio", Mediaspip affiche dans la mesure du possible les vidéos grâce à la balise html5 .
Un des inconvénients de cette balise est qu’elle n’est pas reconnue correctement par certains navigateurs (Internet Explorer pour ne pas le nommer) et que chaque navigateur ne gère en natif que certains formats de vidéos.
Son avantage principal quant à lui est de bénéficier de la prise en charge native de vidéos dans les navigateur et donc de se passer de l’utilisation de Flash et (...) -
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;
Sur d’autres sites (7118)
-
Can't seem to find a proper way of splitting a huge (really huge) video into 1 hour chunks without any loss in quality
31 octobre 2023, par bit_scientistI have backed up a video from Milestone system in mkv format. It's a 106 hours-video with 37 GB size. I have searched for way to split into one-hour chunks without any quality loss. However, I am facing two problems :


- 

- A python code with
subprocess
has produced videos in arbitrary lengths such as 11 minutes, 1.5 hours, 55 minutes, etc. - The produced videos look corrupt. When played I can't use forward or backward (5s) functions, it instantly leaps to the end of the video. There is no such an issue when original video is played.
Here is the code I used to do the job :






import subprocess
import math

input_file = "video.mkv"
output_prefix = "output"
segment_duration = 60 * 60

ffprobe_command = [
 "ffprobe",
 "-v",
 "error",
 "-show_entries",
 "format=duration",
 "-of",
 "default=noprint_wrappers=1:nokey=1",
 input_file,
]
total_duration = float(subprocess.check_output(ffprobe_command))

num_segments = int(total_duration / segment_duration)

for i in range(num_segments):
 start_time = i * segment_duration
 output_file = f"{output_prefix}_{i + 1}.mkv"

 ffmpeg_command = [
 "ffmpeg",
 "-ss",
 str(start_time),
 "-i",
 input_file,
 "-t",
 str(segment_duration),
 "-c:v",
 "copy",
 "-c:a",
 "copy",
 output_file,
 ]

 subprocess.run(ffmpeg_command)



I also tested with ffmpeg command with similar output lengths or some other failures such as
Too many packets buffered for output stream 0:0
.

Could someone suggest a better way to do the splitting in any language ?
I don't mind spending too much time to split the video, all I need is one-hour videos without any corruption or quality loss.
I am on a Windows machine if it helps.


- A python code with
-
The problem is that the music does not play Discord py bot [closed]
7 mai 2023, par ImFoxterWhen I write the command : !yt
Such a mistake :
enter image description here 

I also have FFMPEG, but I don't really understand what to do with it, I've already tried a lot of things and it doesn't work enter image description here

Please help to fix this

I have an operating system : Windows

And the file is created
enter image description here

import asyncio

import discord
import youtube_dl

from discord.ext import commands

youtube_dl.utils.bug_reports_message = lambda: ""

ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0'
}

ffmpeg_options = {"options": "-vn"}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

class YTDLSource(discord.PCMVolumeTransformer):
def __init__(self, source, \*, data, volume=0.5):
super().__init__(source, volume)

 self.data = data
 
 self.title = data.get("title")
 self.url = data.get("url")
 
 @classmethod
 async def from_url(cls, url, *, loop=None, stream=False):
 loop = loop or asyncio.get_event_loop()
 data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url=url, download=not stream))
 
 if "entries" in data:
 data = data["entries"][0]
 
 file_name = data["url"] if stream else ytdl.prepare_filename(data)
 return cls(discord.FFmpegAudio(file_name, **ffmpeg_options), data=data)

class PlayMusicVoiceChannel(commands.Cog):
def __init__(self, bot):
self.bot = bot

 @commands.command(name="j")
 async def joined(self, ifx, *, channel: discord.VoiceChannel):
 if ifx.voice_client is not None:
 return await ifx.voice_client.move_to(channel)
 await channel.connect()
 
 @commands.command(name="p")
 async def playing(self, ifx, *, query):
 source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
 ifx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
 await ifx.send(content=f"New playing: {query}")
 
 @commands.command(name="yt")
 async def youtube(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="stream")
 async def stream(self, ifx, *, url):
 async with ifx.typing():
 player = await YTDLSource.from_url(url=url, loop=self.bot.loop, stream=True)
 ifx.voice_client.play(
 player, after=lambda e: print(f"Player error: {e}") if e else None
 )
 await ifx.send(f"New playing: {player.title}")
 
 @commands.command(name="l")
 async def leave(self, ifx):
 await ifx.voice_client.move_to(None)
 
 @playing.before_invoke
 @youtube.before_invoke
 @stream.before_invoke
 async def ensure_voice(self, ifx: commands.Context):
 if ifx.voice_client is None:
 if ifx.author.voice:
 await ifx.author.voice.channel.connect()
 else:
 await ifx.send(content="You are not connected to a voice channel")
 raise commands.CommandError(message="Author not connected to a voice channel")
 elif ifx.voice_client.is_playing():
 ifx.voice_client.stop()

async def setup(bot: commands.Bot):
await bot.add_cog(PlayMusicVoiceChannel(bot))



-
why ffmpeg process successfully terminated with return code of 1 without play anything
24 juillet 2023, par Exc`I tried replacing youtube_dl with yt_dlp and replaced some of the code, the code worked fine but when using the command, the bot doesn't play music but immediately ffmpeg process 15076 successfully terminated with return code of 1


Is there a problem with my code or the ffmpg option or ytdlp option that doesn't support the yt_dlp library ?`


self.YTDL_OPTIONS = {
 'format': 'bestaudio/best',
 'outtmpl': 'F:/DISCORD BOT/Ex/music/%(extractor)s-%(id)s-%(title)s.%(ext)s',
 'restrictfilenames': True,
 'retry_max': 'auto',
 'noplaylist': True,
 'nocheckcertificate': True,
 'ignoreerrors': True,
 'logtostderr': False,
 'quiet': True,
 'no_warnings': True,
 'default_search': 'auto',
 'source_address': '0.0.0.0',
 'postprocessors': [{
 'key': 'FFmpegExtractAudio',
 'preferredcodec': 'mp3',
 'preferredquality': '192',
 }],
 'youtube_api_key': 'api'
 }
self.FFMPEG_OPTIONS = {
 'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
 'options': '-vn',
 'executable':r'F:\DISCORD BOT\Ex\ffmpeg\bin\ffmpeg.exe'
 }

 
 @commands.hybrid_command(
 name="play",
 aliases=["p"],
 usage="",
 description="KARAUKENAN.",
 
 )
 @app_commands.describe(
 judul_lagu="link ato judul lagunya"
 )
 async def play(self, ctx, judul_lagu:str):
 await ctx.defer()
 voice_channel = ctx.author.voice
 if not voice_channel or not voice_channel.channel:
 await ctx.send("Join voice channel dulu gblk!")
 return

 voice_channel = voice_channel.channel
 song = self.search_song(judul_lagu)
 if not song:
 await ctx.send("Lagnya tdk ditemukan, coba keword lain.")
 return

 if not self.bot.voice_clients:
 voice_client = await voice_channel.connect()
 else:
 voice_client = self.bot.voice_clients[0]
 if voice_client.channel != voice_channel:
 await voice_client.move_to(voice_channel)

 self.music_queue.append([song, voice_client])
 if not self.is_playing:
 await self.play_music(ctx)
 
 async def play_music(self, ctx):
 self.is_playing = True
 while len(self.music_queue) > 0:
 song = self.music_queue[0][0]
 voice_client = self.music_queue[0][1]
 await ctx.send(f"Playing {song['title']}")

 voice_client.play(discord.FFmpegPCMAudio(song['source'], **self.FFMPEG_OPTIONS), after=lambda e: self.play_next())
 voice_client.is_playing()

 while voice_client.is_playing():
 await asyncio.sleep(1)

 self.music_queue.pop(0)
 self.is_playing = False

 await ctx.send("Queue is empty.")
 voice_client.stop()

 def play_next(self):
 if len(self.music_queue) > 0:
 self.is_playing = False

 def search_song(self, judul_lagu):
 ydl = yt_dlp.YoutubeDL(self.YTDL_OPTIONS)
 with ydl:
 try:
 info = ydl.extract_info(f"ytsearch:{judul_lagu}", download=False)['entries'][0]
 return {'source': info['formats'][0]['url'], 'title': info['title']}
 except Exception:
 return None





when i use /play the bot sucess serch song but immediately terminate does not play any music


2023-04-10 13:06:45 INFO discord.voice_client Connecting to voice...
2023-04-10 13:06:45 INFO discord.voice_client Starting voice handshake... (connection attempt 1)
2023-04-10 13:06:46 INFO discord.voice_client Voice handshake complete. Endpoint found singapore11075.discord.media
2023-04-10 13:06:50 INFO discord.player ffmpeg process 15076 successfully terminated with return code of 1.