Recherche avancée

Médias (1)

Mot : - Tags -/publicité

Autres articles (18)

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

  • Demande de création d’un canal

    12 mars 2010, par

    En fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
    Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

Sur d’autres sites (4489)

  • ffmpeg - escaping single quotes doesn't work [duplicate]

    18 septembre 2022, par XorOrNor

    I've written a small python script for mass converting audio files. It uses ffmpeg. The problem is it doesn't work for files with single quotes in their filenames.

    


    script :

    


    
import os
import subprocess
import sys
from multiprocessing.pool import ThreadPool as Pool

source_dir="/home/kris/Music/test"
output_dir="/home/kris/Music/test_opus"

def worker(file):

    try:    
        dirname=os.path.dirname(file)
        file=file.replace("'","\\\\'")
        filename=file.split('.flac')[0]
        
        input_file=f"'{source_dir}/{file}'"
        output_file=f"'{output_dir}/{filename}.opus'"
        cmd="ffmpeg -n -i "+input_file+" -c:a libopus -b:a 320k "+output_file
        print(cmd)
        result = subprocess.call(cmd,stdout=subprocess.PIPE,shell=True)
    except:
        print('item error')
        

def start():    
    threads=os.cpu_count()  
    pool = Pool(threads)
    files=os.listdir(source_dir)
    for item in files:
        pool.apply_async(worker, (item,))

    pool.close()
    pool.join()
        
start()



    


    Testing :

    


      

    1. Filename : I'm a file.flac

      


    2. 


    3. When escaping single quote ' with double backslashes \\ - file=file.replace("'","\\\\'") the cmd for ffmpeg is :

      


    4. 


    


    ffmpeg -n -i '/home/kris/Music/test/I\\'m a file.flac' -c:a libopus -b:a 320k '/home/kris/Music/test_opus/I\\'m a file.opus'


    


    ffmpeg returns an error : /home/kris/Music/test/I\\m: No such file or directory

    


      

    1. When escaping single quote ' with a single backslash \ - file=file.replace("'","\\'") the cmd for ffmpeg is :
    2. 


    


    ffmpeg -n -i '/home/kris/Music/test/I\'m a file.flac' -c:a libopus -b:a 320k '/home/kris/Music/test_opus/I\'m a file.opus'


    


    I got an error :

    


    /bin/sh: 1: Syntax error: Unterminated quoted string


    


    According to ffmpeg docs : https://ffmpeg.org/ffmpeg-utils.html#toc-Examples escaping with single backslash should work.

    


  • heroku-22 stack discord.py bot doesn't play music

    30 août 2022, par bon ho

    I'm making music bot with discord.py and using heroku. bot is playing music my localhost but heroku host is not playing music.

    


    I found what cause a bug.
It working nicely in heroku-20, but not working in heroku-22 stack.

    


    How can I use heroku-22 stack without error ?
What can I do ?

    


    I'm sorry my english is bad.

    


    my code :

    


    import youtube_dl
import discord
from discord import app_commands,Interaction
import asyncio
import os

class MyClient(discord.Client):
  async def on_ready(self):
    await self.wait_until_ready()
    await tree.sync()
    print(f"login at {self.user}")
        
intents= discord.Intents.all()
client = MyClient(intents=intents)
tree = app_commands.CommandTree(client)

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',  # 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 = data.get('url')

    @classmethod
    async def from_url(cls, url, *, loop=None, stream=True):
        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['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)
queue={}
@tree.command(name="play", description="play music")
async def playmusic(interaction:Interaction,url_title:str,playfirst:bool=False):
  await interaction.response.send_message("I'm looking for music!!")
  guild=str(interaction.guild.id)
  try:
    queue[guild]
  except KeyError:
    queue[guild]=[]
  if interaction.user.voice is None:
    await interaction.edit_original_response(content="you must join any voice channel")
  else:
    voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    if voice_client == None:
      await interaction.user.voice.channel.connect()
      voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=interaction.guild)
    player = await YTDLSource.from_url(url_title, loop=None)
    if playfirst and len(queue[guild])>1:
      queue[guild].insert(1,player)
    else:
      queue[guild].append(player)
    if not voice_client.is_playing():
      voice_client.play(player,after=None)
      await interaction.edit_original_response(content=f"{player.title} playing!!")
    else:
      await interaction.edit_original_response(content=f"{player.title} enqueued!")
    await asyncio.sleep(7)
    await interaction.delete_original_response()

client.run(token)


    


  • How to run ffmpeg command in python ; vscode ?

    20 septembre 2022, par Jun Ha

    i'd like to run this command

    


    for /R %f IN (/*.mp4) DO ffmpeg -i "%f" -f wav -bitexact -acodec pcm_s16le -ar 22050 -ac 1 %~nf.wav


    


    inside this script, like this :

    


    import os
from datetime import date

today = date.today()
today = today.strftime('%m-%d-%Y')
dir_name = f"C:/Users/lucan/Automatically/{today}/"

def extract(user):
  test = os.listdir(dir_name)
  command = "for /R %f IN (/*.mp4) DO ffmpeg -i "%f" -f wav -bitexact -acodec pcm_s16le -ar 22050 -ac 1 %~nf.wav"
  os.system(command)
  for item in test:
    if item.endswith(".wav"):
      os.remove(os.path.join(dir_name, item))


extract("businessbarista")


    


    when i do so this is the error message I get :

    


    


    command = "for /R %f IN (/*.mp4) DO ffmpeg -i "%f" -f wav -bitexact
-acodec pcm_s16le -ar 22050 -ac 1 % nf.wav" TypeError : must be real number, not str

    


    


    the command runs fine in command prompt, but not in powershell. can you help me figure out what went wrong ?