Recherche avancée

Médias (91)

Autres articles (111)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

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

  • Support audio et vidéo HTML5

    10 avril 2011

    MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
    Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
    Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
    Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...)

Sur d’autres sites (10737)

  • ffmpeg crop in a loop crops files incrementally

    13 septembre 2014, par Voprosnik

    I have a very large audio mp4 file that contains several songs.

    I have generated a script which reads a text file with the times and the song names and successfully assigns starttime, endtime and songtitle in 3 variables. The script successfully echoes the variables and returns the following format :

    00:00:00 00:10:15 Song1
    00:10:15 00:14:20 Song2

    and so on...

    Now I am intending to use this script with ffmpeg and crop each part of the big file into smaller audio files.

    The script thus, after feeding the variables in a while loop, it reaches to the command

    ffmpeg -ss $START -t $END -i ${1} -acodec copy $SONGNAME.mp4

    Then I realized that the -t option doesn’t refer to the end point of the excerpt, but the duration. Eg. when I attempted to crop a song from 10:00 to 12:00 it resulted to a 12 minutes long sound file, far longer than the song itself. This resulted in increasingly bigger files.

    Therefore I found some date-manipulating algorithms. Subtracting $START from $END results to an integer with the song’s duration in seconds. I tested it by echoing the results and it resulted to realisting figures (around 100-200).

    However when I replaced the -t option with $DUR instead of $END, this resulted also to increasingly larger files. I didn’t measure the exact length of each, but it seems that the duration increased itself by each loop. I also added an echo $DUR line, which returned the realistic amounts it should. However the ffmpeg -t $DUR did not seem to agree.

    PS. -t has two options, input (before -i) and output (after -i). When I use it after the -i as output (i.e. the duration of the output file) it SEEMS to work, at least it generates realisticly sized files. The question remains why it behaves strangely in the first place.

  • Why is my discord bot not able to find the file that is there when I open the folder manually ?

    22 juin 2021, par Toma

    I made a discord bot that should play music using ffmpeg.

    


    It's connecting and downloading the youtube webm file after which it should convert and rename it to song.mp3 but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

    


      

    1. Am I using the replace command correctly to move the file ?
    2. 


    3. I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
    4. 


    5. Is there another mistake in the code that'd prevent the file from being found by the bot ?
    6. 


    


    My code :

    


    import discord
from discord.ext import commands
import youtube_dl #for url music command
import os

client = commands.Bot(command_prefix = '><')

#connect to voice channel
@client.command(aliases = ['c'])
async def connect(ctx, vcName):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
    if voice == None: #if voice is not connected to any channel
        await voiceChannel.connect()
    else:
        if voice.channel == vcName: #if trying to connect to the same channel
            await ctx.send('already connected to this channel')
        else:
            await voice.move_to(vcName)

@client.command(aliases = ['d'])
async def delFile(ctx):
    song_there = os.path.exists(os.getcwd()+'/music/current/song.mp3') #true when song.mp3 exists in 'current' folder in 'music' folder
    if song_there:
        await ctx.send('song was detected')
        os.remove('song.mp3')
        if song_there:
            await ctx.send('song was not deleted')
    else:
        await ctx.send('File is not found. check the name again')

#play music from url

@client.command(aliases = ['p'])
async def playMusic(ctx, vcName, url : str): #play music file
    song_there = os.path.exists(os.path.join(os.getcwd(),'/music/current/song.mp3'))
    try:
        if song_there:
            print('previous song found')
            os.remove(os.path.join(os.getcwd(),'/music/current/song.mp3')) #removes the song in current to make room for a new song
            if song_there:
                print('song was not deleted')
            else:
                print('song deleted')
    except PermissionError:
        await ctx.send('A song is currently playing')
        return
    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }]
    }


   for file in os.listdir('./'):
        if file.endswith('.mp3'):       #if song.mp3 already exists delete it to make room for a new download
            os.remove('song.mp3')
        else:                           #download the file from youtube
            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                ydl.download([url])
    for file in os.listdir('./'):       #after downloading rename the file and move it to current folder
        if not file == ('song.mp3') and file.endswith('.mp3'):
            os.rename(file, 'song.mp3')
            print(os.path.join(os.getcwd(), 'song.mp3'))
            print(os.path.join(os.getcwd(), '/music/current/song.mp3'))
            os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3'))   #move file to current

    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    if not voice is None:               #if voice is already created
        if not voice.is_connected():    #and is not connected
            await voiceChannel.connect()
        voice.play(discord.FFmpegPCMAudio('song.mp3'))
    else:
        await ctx.send('Bot made an oopsy. Cast mending and heal bot.')
client.run('token')


    


    Error :

    


    [youtube] wkJ7oDMqz0A: Downloading webpage
[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded
[download] 100% of 5.13MiB
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00                   
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00                  
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
C:.....song.mp3 -> **C:/music/current/song.mp3**
Ignoring exception in command playMusic:
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:...tut-bot.py", line 84, in playMusic
    os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3'))   #move file to current
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\....\\song.mp3' -> 'C:/music/current/song.mp3'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\...\\song.mp3' -> 'C:/music/current/song.mp3'


    


  • Why does my discord bot not able to find the file that is there when I open the folder manually ?

    22 juin 2021, par Toma

    I made a discord bot that should play music using ffmpeg.

    


    It's connecting and downloading the youtube webm file after which it should convert and rename it to song.mp3 but it doesn't manage to do so. I check the folder and the error message doesn't match what I see - the file is there and has been renamed.

    


      

    1. Am I using the replace command correctly to move the file ?
    2. 


    3. I'd note that I'm using windows10 and that the folders are all read only and that although I'm the admin I can't change that no matter what I do (I guess it's a win10 bug). Does that have anything to do with it ?
    4. 


    5. Is there another mistake in the code that'd prevent the file from being found by the bot ?
    6. 


    


    My code :

    


    import discord
from discord.ext import commands
import youtube_dl #for url music command
import os

client = commands.Bot(command_prefix = '><')

#connect to voice channel
@client.command(aliases = ['c'])
async def connect(ctx, vcName):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
    if voice == None: #if voice is not connected to any channel
        await voiceChannel.connect()
    else:
        if voice.channel == vcName: #if trying to connect to the same channel
            await ctx.send('already connected to this channel')
        else:
            await voice.move_to(vcName)

@client.command(aliases = ['d'])
async def delFile(ctx):
    song_there = os.path.exists(os.getcwd()+'/music/current/song.mp3') #true when song.mp3 exists in 'current' folder in 'music' folder
    if song_there:
        await ctx.send('song was detected')
        os.remove('song.mp3')
        if song_there:
            await ctx.send('song was not deleted')
    else:
        await ctx.send('File is not found. check the name again')

#play music from url

@client.command(aliases = ['p'])
async def playMusic(ctx, vcName, url : str): #play music file
    song_there = os.path.exists(os.path.join(os.getcwd(),'/music/current/song.mp3'))
    try:
        if song_there:
            print('previous song found')
            os.remove(os.path.join(os.getcwd(),'/music/current/song.mp3')) #removes the song in current to make room for a new song
            if song_there:
                print('song was not deleted')
            else:
                print('song deleted')
    except PermissionError:
        await ctx.send('A song is currently playing')
        return
    voiceChannel = discord.utils.get(ctx.guild.channels, name=str(vcName))
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }]
    }


   for file in os.listdir('./'):
        if file.endswith('.mp3'):       #if song.mp3 already exists delete it to make room for a new download
            os.remove('song.mp3')
        else:                           #download the file from youtube
            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                ydl.download([url])
    for file in os.listdir('./'):       #after downloading rename the file and move it to current folder
        if not file == ('song.mp3') and file.endswith('.mp3'):
            os.rename(file, 'song.mp3')
            print(os.path.join(os.getcwd(), 'song.mp3'))
            print(os.path.join(os.getcwd(), '/music/current/song.mp3'))
            os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3'))   #move file to current

    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    if not voice is None:               #if voice is already created
        if not voice.is_connected():    #and is not connected
            await voiceChannel.connect()
        voice.play(discord.FFmpegPCMAudio('song.mp3'))
    else:
        await ctx.send('Bot made an oopsy. Cast mending and heal bot.')
client.run('token')


    


    Error :

    


    [youtube] wkJ7oDMqz0A: Downloading webpage
[download] The Minor Bee-wkJ7oDMqz0A.webm has already been downloaded
[download] 100% of 5.13MiB
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00                   
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
[youtube] wkJ7oDMqz0A: Downloading webpage
[download] Destination: The Minor Bee-wkJ7oDMqz0A.webm
[download] 100% of 5.13MiB in 00:00                  
[ffmpeg] Destination: The Minor Bee-wkJ7oDMqz0A.mp3
Deleting original file The Minor Bee-wkJ7oDMqz0A.webm (pass -k to keep)
C:.....song.mp3 -> **C:/music/current/song.mp3**
Ignoring exception in command playMusic:
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:...tut-bot.py", line 84, in playMusic
    os.replace(os.path.join(os.getcwd(), 'song.mp3'), os.path.join(os.getcwd(), '/music/current/song.mp3'))   #move file to current
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\....\\song.mp3' -> 'C:/music/current/song.mp3'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Program Files\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\...\\song.mp3' -> 'C:/music/current/song.mp3'