Recherche avancée

Médias (91)

Autres articles (10)

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

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

  • Other interesting software

    13 avril 2011, par

    We don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
    The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
    We don’t know them, we didn’t try them, but you can take a peek.
    Videopress
    Website : http://videopress.com/
    License : GNU/GPL v2
    Source code : (...)

Sur d’autres sites (3322)

  • OSError : [Errno 9] Bad file descriptor when downloading using pytube and playing with discord.py

    15 septembre 2022, par Trevor Mathisen

    When using pytube to download a YouTube video and discord.py to play it, I am getting a OSError : [Errno 9] Bad file descriptor error. I've had this working at one point and can't seem to figure out what I changed which broke it.

    


    Full traceback :

    


    2022-09-15 20:20:44 INFO       discord.voice_client The voice handshake is being terminated for Channel ID 902294184994693224 (Guild ID 902294184994693220)
2022-09-15T20:20:44.010142763Z 2022-09-15 20:20:44 INFO     discord.voice_client Disconnecting from voice normally, close code 1000.
2022-09-15T20:20:44.058592513Z 2022-09-15 20:20:44 ERROR    discord.player Exception in voice thread Thread-5
2022-09-15T20:20:44.058623864Z Traceback (most recent call last):
2022-09-15T20:20:44.058629130Z   File "/usr/local/lib/python3.10/dist-packages/discord/player.py", line 698, in run
2022-09-15T20:20:44.058632003Z     self._do_run()
2022-09-15T20:20:44.058634500Z   File "/usr/local/lib/python3.10/dist-packages/discord/player.py", line 691, in _do_run
2022-09-15T20:20:44.058637013Z     play_audio(data, encode=not self.source.is_opus())
2022-09-15T20:20:44.058639334Z   File "/usr/local/lib/python3.10/dist-packages/discord/voice_client.py", line 683, in send_audio_packet
2022-09-15T20:20:44.058648759Z     self.socket.sendto(packet, (self.endpoint_ip, self.voice_port))
2022-09-15T20:20:44.058653057Z OSError: [Errno 9] Bad file descriptor
2022-09-15T20:20:44.058673762Z 2022-09-15 20:20:44 INFO     discord.player ffmpeg process 12 has not terminated. Waiting to terminate...
2022-09-15T20:20:44.062083854Z 2022-09-15 20:20:44 INFO     discord.player ffmpeg process 12 should have terminated with a return code of -9.


    


    Dockerfile :

    


    ENV MEDIA_DIR='/media/'
RUN mkdir -p /media


    


    Download function (check_path returns True, showing the file is there) :

    


    def download_videos(stream, filename):
    print(f'downloading {filename}')
    filepath = stream.download(output_path=config_db.environ_path, filename=f'{filename}.mp4')
    print(f'completed download of {filepath}')
    check_path = Path(filepath)
    if check_path.is_file():
        print(check_path)
    return filepath


    


    Play function :

    


    async def play(voice_channel, message, control = None):
    vc = get_vc()
    if not vc:
        vc = await voice_channel.connect()
    next_yt = YouTube(next_song)
    next_file = sub(r'\W+', '', next_yt.title.replace(' ', '_').replace('__', '_')).lower()
    next_song_path = download_videos(next_yt.streams.filter(only_audio=True, file_extension='mp4')[0], next_file)

    await message.channel.send(f'Done getting ready, I\'ll be there in a moment.')

while next_song:
    while vc.is_playing():
        await asynciosleep(0.5)
        continue

    try:
        vc.play(FFmpegPCMAudio(next_song_path))
        print(f'Playing {next_song_path} with latency of {vc.average_latency}')
        vc.source = PCMVolumeTransformer(vc.source, volume=0.15)
    except Exception as e:
        print(e)
        await vc.disconnect()
        next_song = None
        return
    next_song = sounds_db.get_next_song()
    next_yt = YouTube(next_song) if next_song else None
    next_file = sub(r'\W+', '', next_yt.title.replace(' ', '_').replace('__', '_')).lower() if next_song else None
    next_song_path = download_videos(next_yt.streams.filter(only_audio=True, file_extension='mp4')[0], next_file) if next_song else None


    


    I've mounted the /media/ dir during docker -v and can see the file is getting downloaded and when I copy the file to my local machine I can play it in an audio player.

    


    The program can access the SQLite database right next to the files in question just fine.

    


    I've deployed the container locally and to two different VPS's with the same file structure with the same behavior. I'm ripping my hair out.

    


  • How To Make A Music Command Discord.py

    14 juin 2021, par Coder999

    I'm trying to make a music bot, but it just doesn't seem to work. Here's what I have so far.

    


    import asyncio
import functools
import itertools
import math
import random
from keep_alive import keep_alive
import discord
import nacl
import youtube_dl
from async_timeout import timeout
from discord.ext import commands
import os

bot = commands.Bot(command_prefix='+')

@bot.event
async def on_ready():
    print('Logged in as:\n{0.user.name}\n{0.user.id}'.format(bot))

youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
    'format': 'bestaudio/best',
    'restrictfilenames': True,
    'noplaylist': True,
    'nocheckcertificate': True,
    'ignoreerrors': False,
    'logtostderr': False,
    'quiet': True,
    'no_warnings': True,
    'default_search': 'auto',
    'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
}

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 = ""

    @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, download=not stream))
        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]
        filename = data['title'] if stream else ytdl.prepare_filename(data)
        return filename

@bot.command(name='join', help='Tells the bot to join the voice channel')
async def join(ctx):
    if not ctx.message.author.voice:
        await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))
        return
    else:
        channel = ctx.message.author.voice.channel
        await channel.connect()
        await ctx.send(f'Joined channel `{channel}`')

@bot.command(name='leave', help='To make the bot leave the voice channel')
async def leave(ctx):
    voice_client = ctx.message.guild.voice_client
    if voice_client.is_connected():
        channel = ctx.message.author.voice.channel
        await voice_client.disconnect()
        await ctx.send(f'Left channel `{channel}`')
    else:
        await ctx.send("The bot is not connected to a voice channel.")

@bot.command(name='play', help='To play song')
async def play(ctx,url):
    try :
        server = ctx.message.guild
        voice_channel = server.voice_client

        async with ctx.typing():
            filename = await YTDLSource.from_url(url, loop=bot.loop)
            voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename))
        await ctx.send('**Now playing:** {}'.format(filename))
    except:
        await ctx.send("The bot is not connected to a voice channel.")


    


    I have installed PyNaCl and all that stuff and my leave and join commands are working but my play command isnt. It says that it's not connected to a channel but it clearly is.

    


    enter image description here

    


  • ffmpeg player in discord.py (python) automatically leave

    25 octobre 2018, par Rastasplif

    I have created a discord bot that on certain messages either sends back a message or plays a sound (like a soundboard)

    The crucial line of code is :

            soundboard_player = voice_client.create_ffmpeg_player("doh.mp3")
            soundboard_player.start()
            await client.send_message(message.channel, "Playing DOH...")

    This works absolutely fine but i kept trying to add the line
    after=voice_client.disconnect()
    I put this inside the ("doh.mp3", * I PUT IT HERE *) brackets.
    I wanted the bot to leave after it was done.

    When I run the code with the ’after’ statement included, the bot joins and I get the error message :

    TypeError: disconnect() takes 1 positional argument but 2 were given

    I know you can use soundboard_player.is_done() to check the status of the bot but I couldn’t figure out a way to check the status without trapping the code in a loop

    By trapping the code in the loop I cant execute a STOP command to stop it playing the song (soundbite) half way through.

    Any help with the after=voice_client.disconnect() command for the ffmpeg player
    or a creative way to periodically check the status without getting trapped in the loop ?