
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (51)
-
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 -
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette 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.
Sur d’autres sites (7874)
-
Cannot use pydub.AudioSegment on audio files downloaded by youtube-dl library
26 octobre 2018, par Han MAfter I download a audio clip from a youtube link by the youtube-dl library, I cannot use pydub.AudioSegment to slice the audio file. The following is the information about my code.
import youtube_dl
options = {
'format': 'bestaudio/best',
'extractaudio': True, # only keep the audio
'audio-format': "wav", # convert to wav
'outtmpl': whole_path, # name the file the ID of the video
'noplaylist': True, # only download single song, not playlist
'audioquality': 1
}
with youtube_dl.YoutubeDL(options) as ydl:
print('url is:', web_url)
ydl.download([web_url])
from pydub import AudioSegment
audio_data = AudioSegment.from_wav(path_to_downloaded_file)Then, I got an error as follows first on Mac and second on Linux :
b'avconv version 12.3, Copyright (c) 2000-2018 the Libav developers\n built on Jul 26 2018 18:08:50 with Apple LLVM version 9.1.0 (clang-902.0.39.2)\n/Users/***/random17560390.wav: Invalid data found when processing input\n'
b'ffmpeg version 2.8.15-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers\n built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609\n configuration: --prefix=/usr --e
xtra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-
shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-li
bbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmod
plug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-li
bspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --e
nable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv\n libavutil 54. 31.100 / 54.
31.100\n libavcodec 56. 60.100 / 56. 60.100\n libavformat 56. 40.101 / 56. 40.101\n libavdevice 56. 4.100 / 56. 4.100\n libavfilter 5. 40.101 / 5. 40.101\n libavresa
mple 2. 1. 0 / 2. 1. 0\n libswscale 3. 1.101 / 3. 1.101\n libswresample 1. 2.101 / 1. 2.101\n libpostproc 53. 3.100 / 53. 3.100\n[wav @ 0x20854c0] invalid start
code [0][0][0][28] in RIFF header\n/home/users/test_download/random10485395.wav: Invalid data found when processing input\n'I think the problem might be about the encoding on the downloaded files by youtube-dl. I can use pydub.AudioSegment on other normal .wav files. After checking the details of the downloaded file by youtube-dl, I found the following feature :
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
It is different from other normal .wav files, which have the following :
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
-
Music bot returning errors at core.py and bot.py
13 septembre 2021, par LoganoxThe code for the music bot I'm trying to write in python keeps returning an error with the following code :


@bot.command(name='play_song', help='To play song')
async def play(ctx,url):
 
 #if not ctx.message.author.name=="Rohan Krishna" :
 # await ctx.send('NOT AUTHORISED!')
 # return
 if 1==1:#try :
 server = ctx.message.guild
 voice_channel = server.voice_client
 print("try 1 was a success")
 
 async with ctx.typing():
 filename = await YTDLSource.from_url(url, loop=bot.loop)
 #voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename)) #ISSUE HERE
 print("try 2 was a success")
 voice = get(ctx.bot.voice_clients, guild=ctx.guild)
 
 #voice.play(discord.FFmpegPCMAudio('test.mp3'), after=your_check)
 #voice.source = discord.PCMVolumeTransformer(voice.source)
 #voice.source.volume = 0.5
 await ctx.send('**Now playing:** {}'.format(filename))
 if 1==0:#except:
 await ctx.send("The bot is not connected to a voice channel.")
 print("try 3 was unfortunately a success")



It normally has a try/except function but I replaced it with if true and false statements to force it to run instead of breaking to determine the exact line of it breaking. The issue supposedly lies in


voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename)) #ISSUE HERE



The error I get returned is :


Traceback (most recent call last):
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
 ret = await coro(*args, **kwargs)
 File "app2.py", line 75, in play
 voice.play(discord.FFmpegPCMAudio('test.mp3'), after=your_check)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 225, in __init__
 super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 138, in __init__
 self._process = self._spawn_process(args, **kwargs)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\player.py", line 147, in _spawn_process
 raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.

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

Traceback (most recent call last):
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
 await ctx.command.invoke(ctx)
 File "C:\Users\heyin\anaconda3\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
 await injected(*ctx.args, **ctx.kwargs)
 File "C:\Users\heyin\anaconda3\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: ClientException: ffmpeg was not found.



I added the print statements to determine which lines were working so those can obviously be ignored. It seems to be working fine except for this, other commands in the bot are working appropriately.


-
Batch generating spectrograms with ffmpeg or SoX : how to customize their appearance, and is my code so far correct ?
4 mai 2024, par Mark II have a .flac music library, and for organizational and quality assessment reasons I want to have spectrograms of every song in it. After finding out that the program I usually use to view them, Spek, doesn't offer a batch export option, I have found ways to batch generate spectrograms with both SoX and fmpeg. Below you can find the two scripts I've got, which take as an input a folder which contains flac files or subfolders containing flac files, and output their spectrograms (with the same names as their corresponding flacs) to an output folder with the same structure as the input folder :


SoX :


@echo off
setlocal enabledelayedexpansion

REM Root folder containing flac files
set "root_folder=%~1"

REM Output folder for spectrogram images
set "output_folder=0. Spectrograms"

REM Create the output folder if it doesn't exist
mkdir "%output_folder%" 2>nul

REM Loop through all flac files recursively
for /r "%root_folder%" %%F in (*.flac) do (
 REM Get the directory of the flac file
 set "directory=%%~dpF"

 REM Get the relative path of the directory from the root folder
 set "relative_path=!directory:%root_folder%\=!"

 REM Create the corresponding subfolder in the output folder
 mkdir "%output_folder%\!relative_path!" 2>nul

 REM Get the filename without extension
 set "filename=%%~nF"

 REM Get the filename with full path
 set "filename_with_path=%%F"

 REM Generate spectrogram image using sox
 sox "%%F" -n spectrogram -x 640 -y 360 -t "!filename_with_path!" -o "%output_folder%\!relative_path!\!filename!.png"
)




It's slow but it works as intended, this is what the output looks like :


ffmpeg :


@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

:: The root directory of the input files
SET "rootdir=%~1"

:: The output directory where the spectrograms will be saved
SET "outputdir=%rootdir%\0. Spectrograms"

:: Function to create spectrograms recursively
CALL :processFolder "%rootdir%"

GOTO :EOF

:processFolder
FOR /D %%D IN ("%~1\*") DO (
 SET "subdir=%%D"
 SET "spectrodir=!subdir:%rootdir%=%outputdir%!"
 IF NOT EXIST "!spectrodir!" MKDIR "!spectrodir!"
 CALL :processFolder "%%D"
)

FOR %%F IN ("%~1\*.flac") DO (
 SET "filename=%%~nxF"
 SET "spectroname=!filename:.flac=.png!"
 SET "spectropath=!spectrodir!\!spectroname!"
 ffmpeg -i "%%F" -lavfi showspectrumpic=s=1280x720 "!spectropath!"
)
GOTO :EOF



It's much faster, and this is what it outputs :


I added them to the Windows Send To folder, and use both by right clicking the folder containing the subfolders with the flacs, then Send To and then the script I want to use.


I have 3 questions :


- 

- Is my code as optimized as it could be ? Is everything correct ? And is it "folder structure agnostic" ? When outputting the spectrograms will the scripts mimic the structure of the input folder in all cases, or are there flaws in the code that would prevent them from being able to do it in some cases (i.e. if the .flac files are 3 layers under the input folder or something like that) ?
- How do I modify the function calls at each of these scripts (whichever approach I stick with, I'm leaning towards ffmpeg cause it's much faster and appears to be better supported) to have the spectrogram image include some info about the file, customize its font, x axis time format, and other things ? I want it look like what Spek outputs as much as possible. Can't find much in the documentation of SoX and ffmpeg, but Spek uses ffmpeg as its backend right ?
- Is it recommended to show both channels on the spectrograms, like the SoX script does, or is one sufficient for my purposes ?