Recherche avancée

Médias (1)

Mot : - Tags -/musée

Autres articles (86)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains 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 ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

Sur d’autres sites (11995)

  • Extracting audio from a video from ".m3u8" URL

    12 février 2021, par leo

    I am trying to extract audio from a video from ".m3u8" URL. It works with this command which is stated below but I could not find how can I do that with a C# wrapper library, like Xabe.FFmpeg, FFMPEGCore. Does anybody know how to do that ?

    


    PS : I am using .net core

    


    ffmpeg -i "https://blablabla/playlist.m3u8" -acodec mp3 -ab 128k test.mp3

    


  • FFmpeg python doesn't merge

    24 avril 2021, par MaLoLHDX

    I was making this youtube downloader GUI with Python : it asks for the URL, gives you a list with the possible quality settings and downloads the selected video file and the best audio file with youtube-dl. However, when I tell ffmpeg to merge the two separate downloaded files, it doesn't do anything and it doesn't say anything in the console either. Is there anything I'm missing ?

    


    Here's the relevant part of the code (starts at line 153) :

    


                #Adding input arguments for ffmpeg
            ffmpeg_video = ffmpeg.input(self.video_title)
            ffmpeg_audio = ffmpeg.input(self.audio_title)
            output_ffmpeg_title = './videos/' + self.youtube_title
            #Merging with ffmpeg
            out = ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec='copy', acodec='aac')
            out.run


    


    Here's the full code :

    


    import youtube_dl
import tkinter as tk
import operator
import ffmpeg
class GUI:
    def __init__(self):
        #Creating initial window
        self.window = tk.Tk()
        self.window.title('YTDL')
        self.window.geometry('300x70')
        
        self.urlbox = tk.Entry(self.window)
        self.urlbox.pack(padx=5,pady=5)
        #Creating download button, which will open the format selection window
        downbutton = tk.Button(self.window, text="Download", command= self.check_url)
        downbutton.pack(padx=5, pady=5)
        #Creating a variable to keep track of the point in the GUI options selection
        self.format_select_process = False
        
        self.window.mainloop()
    def check_url(self):
        #Saving selected URL to variable
        self.selected_url = self.urlbox.get()
        self.urlbox.delete(0, 'end')
        #If something was written in the URL box, try to go the next step
        if len(self.selected_url) != 0:
            self.get_formats(self.selected_url)
        else:
            print('URL box is empty!')
    def get_formats(self, x):
        with youtube_dl.YoutubeDL() as ydl:
            meta = ydl.extract_info(x, download=False)
            #Save formats from 'meta' to 'self.formats'
            self.formats = meta.get('formats', [meta])
            self.youtube_title = meta.get('title', [meta])
            #Creating two dictionaries for the list of format sizes and extensions
            self.f_list_size_dict = {}
            self.f_list_ext_dict = {}
            #Creating audio format list
            self.audio_format_list = []
        #For every format in self.formats, add its format, extension, fps and filesize to self.f_list
        for f in self.formats:
            self.f_list = '-' + f['format']+ ' -' + f['ext'] + ' -' + str(f['fps']) + ' ' + str(f['filesize'])
            if 'audio only' in f['format']:
                #Add an element to each dictonary whose name is the format ID and whose value is its filesize/extension
                self.f_list_size_dict[f['format'].split(' -')[0]] = f['filesize']
                self.f_list_ext_dict[f['format'].split(' -')[0]] = f['ext']
                #Add to the audio format list the current audio format ID
                self.audio_format_list.append(f['format'].split(' -')[0])
        print('Audio format list:')
        print(self.audio_format_list)
        print('Size list dict:')
        print(self.f_list_size_dict)
        print('Ext list size dict:')
        print(self.f_list_ext_dict)
        """
        #Making a new list which only contains the audio format IDs
        self.audio_format_list = str(self.f_list_size_dict.keys()).split('([')[1]
        self.audio_format_list = self.audio_format_list.split('])')[0]
        self.audio_format_list = self.audio_format_list.replace("'", "")
        self.audio_format_list = self.audio_format_list.split(', ')
        print('Cleaned up audio format list:')
        print(self.audio_format_list)
        """
        #Here the program starts looking for the best audio format
        #In the try block, the program gets the best audio format's ID from the size dict and extension from the ext dict
        #In the except block, the program gets the ID from the audio format list and the extension from the ext dict
        try:
            self.highest_audio = max(self.f_list_size_dict.items(), key=operator.itemgetter(1))[0]
            self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)
            print('Best audio format ID: ' + self.highest_audio)
            print('Best audio format extension: ' + self.highest_audio_ext)
        except:
            self.highest_audio = max(self.audio_format_list)
            self.highest_audio_ext = self.f_list_ext_dict.get(self.highest_audio)
            print(self.highest_audio)
            print(self.highest_audio_ext)
        #Going to next sted of the code, which renders the format choice window
        self.format_select()
    def format_select(self):
        self.window.withdraw()
        format_select_window = tk.Toplevel()
        format_select_window.attributes('-topmost', True)
        format_select_window.geometry("300x350")
        format_select_window_label = tk.Label(format_select_window, text="Select the video format")
        format_select_window_label.pack(padx=5, pady=5)
        format_select_window.protocol('WM_DELETE_WINDOW', lambda: exit())

        self.format_listbox = tk.Listbox(format_select_window, height=15, width=40, yscrollcommand=1)
        self.format_listbox.pack(padx=10, pady=10)
        for index, item in enumerate(self.f_list):
            self.f_list_lenght = index
        download_button = tk.Button(format_select_window, text='Download', command=self.download)
        download_button.pack(padx=10, pady=10)
        #Adding options to the listbox
        for f in self.formats:
            #If it is adding an audio only format, it will add the ID, filesize (if possible with try block) and extension
            if 'audio only' in f['format'] + ' ' + str(f['fps']) + ' FPS ' + f['ext']:
                try:
                    mb_filesize = round(f['filesize'] / 1024 / 1024, 2)
                    self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(mb_filesize) + ' MiB  ' + f['ext']) 
                except:
                    self.format_listbox.insert(self.f_list_lenght, f['format'] + '  ' + f['ext'])
            #If it is adding a video format, it will add the ID, FPS, filesize (if possible with the try block) and extension
            else:
                try:
                    mb_filesize = round(f['filesize'] / 1024 / 1024, 2)
                    self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(f['fps']) + ' FPS' + ' ' + str(mb_filesize) + ' MiB  ' + f['ext'])
                except:
                    self.format_listbox.insert(self.f_list_lenght, f['format'] + ' ' + str(f['fps']) + ' FPS  ' + f['ext'])
    def download(self):
        #Getting the list position of the selected format
        selected_format_list_position = self.format_listbox.curselection()
        #Getting the text of the selected format list item
        selected_format = self.format_listbox.get(selected_format_list_position)
        print('Selected format: ' + selected_format)
        #Cutting from the selected format list item text everything past ' -' to only get the format's ID
        selected_format_id = selected_format.split(' -')[0]
        print('Selected format ID: ' + selected_format_id)
        #Converting the ID to string
        final_selected_format_id = str(selected_format_id)
        print('Final selected format: ' + final_selected_format_id)
        #Cutting from the selected format list item text everything before '  ' to only get the extension
        final_ext = selected_format.split('  ')[1]
        print('Final video extension: ' + final_ext)
        if 'audio only' in selected_format:
            #Creating the download options dictionary (not working):
            #Setting the download location to the videos folder,
            #preventing the program from downloading a whole playlist,
            #telling youtube-dl to extract audio ('x'),
            #giving youtube-dl the requested format (which is only audio).
            self.ydl_opts = {'outtmpl':'./videos/%(title)s.%(ext)s', 'noplaylist': True, 'x': True, 'format': final_selected_format_id}
            #Downloading
            with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
                ydl.download([self.selected_url])
        elif 'audio only' not in selected_format:
            #Adding '+bestaudio' to the selected format ID (which is only a video ID in this case)
            final_selected_format_id_video_audio = str(selected_format_id) + '+bestaudio'
            #Creating the download options dictionary:
            #Setting the download location to the videos folder,
            #preventing the program from downloading a whole playlist,
            #giving youtube-dl the requested format with audio.
            self.ydl_opts = {'outtmpl':'./videos/%(title)s.%(ext)s', 'noplaylist': True, 'format': final_selected_format_id_video_audio}
            #Predicting the video file title and location for future ffmpeg merge
            self.video_title = './videos/' + self.youtube_title + '.f' + str(selected_format_id) + '.' + final_ext
            print('Video file title: ' + self.video_title)
            #Predicting the audio file title and location for future ffmpeg merge
            self.audio_title = './videos/' + self.youtube_title + '.f' + str(self.highest_audio) + '.' + self.highest_audio_ext
            print('Audio file title: ' + self.audio_title)
            #Downloading with youtube-dl
            with youtube_dl.YoutubeDL(self.ydl_opts) as ydl:
                ydl.download([self.selected_url])
            #Adding input arguments for ffmpeg
            ffmpeg_video = ffmpeg.input(self.video_title)
            ffmpeg_audio = ffmpeg.input(self.audio_title)
            output_ffmpeg_title = './videos/' + self.youtube_title
            #Merging with ffmpeg
            ffmpeg.output(ffmpeg_video, ffmpeg_audio, output_ffmpeg_title, vcodec='copy', acodec='aac')
GUI()


    


    If there is a better way of integrating ffmpeg with youtube-dl in Python, please tell me.

    


  • Discord.py : Access files on the computer of the person who sent a message. Play a song from the local drive of any user on the server

    7 avril 2021, par daDib

    I have a bot that can play music from my computer. Is there a way to play a song from the computer of the person who sent the message ? My thought would be using message.author to somehow access the person's session and get into their drive. Here is my bot. It can join a voice channel, create playlists from local file paths, start a playlist or individual file with stop/pause/play/next/previous controls :

    


    import discord
import os.path
import logging
import asyncio
from os import path

global ready 
global vc
global source
global songQueue
global songIndex
global commandList
global stopPlaylist

ready = False
stopPlaylist = False
songQueue = []
songIndex = 0

logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='D:\DnD\DiscordBot\discord.log', encoding='utf-8', mode='w')
handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)

client = discord.Client()
commands = [
    '!connect\nConnect to a voice channel by channel id. Use !channels to find the desired id.\nExample Command: !connect 827202170973323305\n\n',
    '!channels\nLists all voice channels and their connection id.\n\n',
    '!add\nAdd a file path to the playlist.\nExample Command: !add D:\\DnD\\DiscordBot\\mySong.mp3\n\n',
    '!delete\nDeletes the last song added to the playlist.\n\n',
    '!view\nDisplays the current playlist, in order.\n\n',
    '!playlist\nStarts the playlist from the beginning, or optionally add a number as the start position.\nExample Command: !playlist 3\n\n',
    '!playSong\nPlays a specified file.\nExample Command: !playSong D:\\DnD\\DiscordBot\\mySong.mp3\n\n',
    '!next\nPlays next song in playlist.\n\n',
    '!prev\nPlays previous song in playlist.\n\n',
    '!stop\nStops all music song. Playlist will restart from the beginning.\n\n',
    '!pause\nPauses the current song. Restart with !resumeSong.\n\n',
    '!resume\nResumes the current song.\n\n'
    '!status\nLets you know if the bot thinks it is playing music.'
    ]
commandList=''
for command in commands:
    commandList+=command

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    global ready 
    global vc
    global source
    global songQueue
    global songIndex
    global commandList
    global stopPlaylist

    if message.author == client.user:
        return
#!help
    if message.content.startswith('!help'):
        await message.channel.send('{0}'.format(commandList))
        return
#!connect
    if message.content.startswith('!connect'):  
        if ready:
            await message.channel.send('Bot [{0}] is already connected to a voice channel.'.format(client.user))
            return
        channel = int(message.content[9:])
        vc = await client.get_channel(channel).connect()
        ready = True
        await message.channel.send('Bot [{0}] is connecting to voice.'.format(client.user))
        return
#!channels
    if message.content.startswith('!channels'):
        channelList = ''
        for channel in client.get_all_channels():
            if channel.type == discord.ChannelType.voice:
                channelList += 'name: ' + channel.name + '\n'
                channelList += 'id: ' + str(channel.id) + '\n\n'
        await message.channel.send('{0}'.format(channelList))
        return
#!add
    if message.content.startswith('!add'):
        song = message.content[5:]
        if not path.exists(song):
            await message.channel.send('Song not found or invalid path specified.\nSpecified Path: {0}\nExample command: !addSong C:\\Users\\Public\\Music\\mySong.mp3'.format(song))
            return
        songQueue.append(song)
        await message.channel.send('Song added: {0}\nCurrent playist length: {1} song(s)'.format(song,len(songQueue)))
        return
#!delete
    if message.content.startswith('!delete'):
        if len(songQueue) == 0:
            await message.channel.send('Playlist is empty. Use !addSong, !viewList, and !playList to manage playlists.')
            return
        await message.channel.send('Removed song: {0}'.format(songQueue.pop()))
        return
#!view
    if message.content.startswith('!view'):
        if len(songQueue) == 0:
            await message.channel.send('Playlist is empty. Use !addSong, !deleteSong, and !playList to manage playlists.')
            return
        await message.channel.send('Current Playlist:\n{0}'.format('\n'.join(songQueue)))
        return
#play commands
    if message.content.startswith('!play'):
        if not ready:
            await message.channel.send('Bot [{0}] is not connected to a voice channel.'.format(client.user))
            return
#!playlist  
        if message.content.startswith('!playlist'):
            try:
                songIndex = int(message.content[10:]) - 1
                if songIndex >= len(songQueue):
                    songIndex = len(songQueue) - 1
            except:
                pass    
            playSong()
            return
#!playSong
        if message.content.startswith('!playSong'):
            song = message.content[10:]
            if not path.exists(song):
                await message.channel.send('Song not found or invalid path specified.\nSpecified Path: {0}\nExample command: !play C:\\Users\\Public\\Music\\mySong.mp3'.format(song))
                return
            source = discord.FFmpegPCMAudio(song)
            vc.play(source, after=None)
            await message.channel.send('Playing song: {0}'.format(song))
            return
#!next
    if message.content.startswith('!next'):
        vc.stop()
#!prev
    if message.content.startswith('!prev'):
        songIndex -= 2
        if songIndex < -1:
            songIndex = -1
        vc.stop()
#!stop
    if message.content.startswith('!stop'):
        if not ready:
            await message.channel.send('Bot [{0}] is not connected to a voice channel.'.format(client.user))
            return
        vc.stop()
        songIndex = 0
        stopPlaylist = True
        await message.channel.send('Stopping music.')
        return
#!pause
    if message.content.startswith('!pause'):
        if not ready:
            await message.channel.send('Bot [{0}] is not connected to a voice channel.'.format(client.user))
            return
        vc.pause()
        await message.channel.send('Pausing music.')
        return
#!resume
    if message.content.startswith('!resume'):
        if not ready:
            await message.channel.send('Bot [{0}] is not connected to a voice channel.'.format(client.user))
            return
        vc.resume()
        await message.channel.send('Resuming music.')
        return
#!status
    if message.content.startswith('!status'):
        if not ready:
            await message.channel.send('Bot [{0}] is not connected to a voice channel.'.format(client.user))
            return
        if vc.is_playing():
            await message.channel.send('Something is playing.')
            return
        await message.channel.send('Nothing is playing.')
        return

def playSong():
    global songQueue
    global songIndex
    global vc
    try:
        song = songQueue[songIndex]
        source = discord.FFmpegPCMAudio(song)
        vc.play(source, after=nextSong)
    except Exception as e:
        print('playSong error {0}'.format(e))

def nextSong(error):
    global songQueue
    global songIndex
    global stopPlaylist
    try:
        songIndex += 1
        if songIndex >= len(songQueue):
            stopPlaylist = True
        if stopPlaylist:
            songIndex = 0
            stopPlaylist = False
            return
        futureFunction = asyncio.run_coroutine_threadsafe(playSong(), client.loop)
        futureFunction.result()
    except Exception as e:
        print('nextSong error {0}'.format(e))

#@client.event
#async def on_logout(user)
#   global ready
#   if user == client.user:
#       ready = False

client.run('TOKEN')