
Recherche avancée
Médias (91)
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
-
USGS Real-time Earthquakes
8 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
SWFUpload Process
6 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
-
Creativecommons informational flyer
16 mai 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (62)
-
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains 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 ;
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)
Sur d’autres sites (8759)
-
ffmpeg split by silence (with logic to achieve 12 split segments)
14 mars 2023, par Martinhttps://github.com/MartinBarker/split_by_silence


I am trying to automate the process of splitting a single audio file into 12 tracks. you can see in the below image that this 35:62 length mp3 file has 11 visible split points (where the audio more quiet), which means 12 distinct segments.



I'd like to be able to run a script to automatically find these split points and split my file, my first split point should be around
159
seconds, and second around360
, third around540
, 4th around780
, 5th around960
, and so on for a total of 11 split points :

1 159
2 360
3 540
4 780
5 960
6 1129
7 1309
8 1500
9 1680
10 1832
11 1980



but my test results have not been working so good :


- Goal:
11 split points found
12 tracks rendered

- Test 1
SD_PARAMS="-24dB"
MIN_FRAGMENT_DURATION="3"
5 split points found: 361.212,785.811,790.943,969.402,2150.24`
6 tracks rendered

-Test 2
SD_PARAMS="-24dB"
MIN_FRAGMENT_DURATION="3"
10 split points found: 151.422,155.026,158.526,361.212,534.254,783.667,967.253,1128.91,2150.2
11 tracks rendered



- 

- Test 2 Problem :
Even though 12 tracks were rendered, some split points are very close


leading to tracks being exported that are very short, such as 3, 5, and 2 seconds. as well as one long track being 16 minutes





So I added a variable
MIN_SEGMENT_LENGTH
and ran another test

- Test 3
SD_PARAMS="-18dB"
MIN_FRAGMENT_DURATION="3"
MIN_SEGMENT_LENGTH=120 (02:00)

log:
_______________________
Determining split points...
split points list= 150.482,155.026,158.526,361.212,530.019,534.254,783.667,967.245,1127.67,2144.57,2150.2
1. The difference between 150.482 and 155.026 is 4.544
 diff is less than MIN_SEGMENT_LENGTH=120
2. The difference between 155.026 and 158.526 is 3.500
 diff is less than MIN_SEGMENT_LENGTH=120
3. The difference between 158.526 and 361.212 is 202.686
4. The difference between 361.212 and 530.019 is 168.807
5. The difference between 530.019 and 534.254 is 4.235
 diff is less than MIN_SEGMENT_LENGTH=120
6. The difference between 534.254 and 783.667 is 249.413
7. The difference between 783.667 and 967.245 is 183.578
8. The difference between 967.245 and 1127.67 is 160.425
9. The difference between 1127.67 and 2144.57 is 1016.90
10. The difference between 2144.57 and 2150.2 is 5.63
 diff is less than MIN_SEGMENT_LENGTH=120
_______________________
Exporting 12 tracks with ffmpeg...



I'm unsure how to change my script and vars so that by running it, are calculating the split points, if any of them are too short (less then 120 seconds) to regenerate the split point(s) ?


Here is my audio file :
https://filetransfer.io/data-package/HC7GG07k#link


And here is my script, which can be ran by running
./split_by_silence.sh


# -----------------------
# SPLIT BY SILENCE
# Requirements:
# ffmpeg
# $ apt-get install bc
# How To Run:
# $ ./split_by_silence.sh "full_lowq.flac" %03d_output.flac

# output title format
OUTPUTTITLE="%03d_output.mp3"
# input audio filepath
IN="/mnt/e/martinradio/rips/vinyl/L.T.D. – Gittin' Down/lowquality_example.mp3"
# output audio filepath
OUTPUTFILEPATH="/mnt/e/folder/rips"
# ffmpeg option: split input audio based on this silencedetect value
SD_PARAMS="-18dB"
# split option: minimum fragment duration
MIN_FRAGMENT_DURATION=3
# minimum segment length
MIN_SEGMENT_LENGTH=120

# -----------------------
# step: ffmpeg
# goal: get comma separated list of split points (use ffmpeg to determine points where audio is at SD_PARAMS [-18db] )

echo "_______________________"
echo "Determining split points..." >& 2
SPLITS=$(
 ffmpeg -v warning -i "$IN" -af silencedetect="$SD_PARAMS",ametadata=mode=print:file=-:key=lavfi.silence_start -vn -sn -f s16le -y /dev/null \
 | grep lavfi.silence_start= \
 | cut -f 2-2 -d= \
 | perl -ne '
 our $prev;
 INIT { $prev = 0.0; }
 chomp;
 if (($_ - $prev) >= $ENV{MIN_FRAGMENT_DURATION}) {
 print "$_,";
 $prev = $_;
 }
 ' \
 | sed 's!,$!!'
)
echo "split points list= $SPLITS"
# determine if the difference between any two splits is less than MIN_SEGMENT_LENGTH seconds
IFS=',' read -ra VALUES <<< "$SPLITS"

for (( i=0; i<${#VALUES[@]}-1; i++ )); do
 diff=$(echo "${VALUES[$i+1]} - ${VALUES[$i]}" | bc)
 display_i=$((i+1))
 echo "$display_i. The difference between ${VALUES[$i]} and ${VALUES[$i+1]} is $diff"
 if (( $(echo "$diff < $MIN_SEGMENT_LENGTH" | bc -l) )); then
 echo " diff is less than MIN_SEGMENT_LENGTH=$MIN_SEGMENT_LENGTH"
 fi
done


# using the split points list, calculate how many output audio files will be created 
num=0
res="${SPLITS//[^,]}"
CHARCOUNT="${#res}"
num=$((CHARCOUNT + 2))
echo "_______________________"
echo "Exporting $num tracks with ffmpeg"

ffmpeg -i "$IN" -c copy -map 0 -f segment -segment_times "$SPLITS" "$OUTPUTFILEPATH/$OUTPUTTITLE"

echo "Done."




- Test 2 Problem :
Even though 12 tracks were rendered, some split points are very close

-
discord.py music bot slowing down for longer audio queries
1er janvier 2023, par BoblugeSo I'm trying to make a music bot with discord.py. Shown below is a minimum working example of the bot with the problematic functions :


import os

import discord
from discord.ext import commands
from discord import player as p

import yt_dlp as youtube_dl

intents = discord.Intents.default()
intents.members = True

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

class Music(commands.Cog):
 def __init__(self, bot):
 self.bot = bot
 self.yt-dlp_opts = {
 'format': 'bestaudio/best',
 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
 'restrictfilenames': True,
 'noplaylist': True,
 'playlistend': 1,
 '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
 }
 self.ffmpeg_opts = {
 'options': '-vn',
 # Source: https://stackoverflow.com/questions/66070749/
 "before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
 }
 self.cur_stream = None
 self.cur_link = None

 @commands.command(aliases=["p"])
 async def play(self, ctx, url):
 yt-dlp = youtube_dl.YoutubeDL(self.ytdl_opts)
 data = yt-dlp.extract_info(url, download=False)
 filename = data['url'] # So far only works with links
 print(filename)
 audio = p.FFmpegPCMAudio(filename, **self.ffmpeg_opts)
 self.cur_stream = audio
 self.cur_link = filename

 # You must be connected to a voice channel first
 await ctx.author.voice.channel.connect()
 ctx.voice_client.play(audio)
 await ctx.send(f"now playing")

 @commands.command(aliases=["ff"])
 async def seek(self, ctx):
 """
 Fast forwards 10 seconds
 """
 ctx.voice_client.pause()
 for _ in range(500):
 self.cur_stream.read() # 500*20ms of audio = 10000ms = 10s
 ctx.voice_client.resume()

 await ctx.send(f"fast forwarded 10 seconds")

 @commands.command(aliases=["j"])
 async def jump(self, ctx, time):
 """
 Jumps to a time in the song, input in the format of HH:MM:SS
 """
 ctx.voice_client.stop()
 temp_ffempg = {
 'options': '-vn',
 # Keyframe skipping when passed as an input option (fast)
 "before_options": f"-ss {time} -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
 }
 new_audio = p.FFmpegPCMAudio(self.cur_link, **temp_ffempg)
 self.cur_stream = new_audio
 ctx.voice_client.play(new_audio)
 await ctx.send(f"skipped to {time}")


bot.add_cog(Music(bot))
bot.run(os.environ["BOT_TOKEN"])



My
requirements.txt
file :

discord.py[voice]==1.7.3
yt-dlp==2021.9.2



To play a song in Discord the following format is used :


;p 



Where
is any link that yt-dlp supports. Under normal circumstances, the
;p
command is used with songs that are relatively short, to whichseek()
andjump()
work extremely quickly to do what they are supposed to do. For example if I execute these sequence of commands in Discord :

;p https://www.youtube.com/watch?v=n8X9_MgEdCg <- 4 min song



And when the bot starts playing, spam the following :


;ff
;ff
;ff
;ff
;ff



The bot is able to almost instantly seek five 10-second increments of the song. Additionally, I can jump to the three minute mark very quickly with :


;j 00:03:00



From some experimentation, the
seek()
andjump()
functions seem to work quickly for songs that are under 10 minutes. If I try the exact same sequence of commands but with a 15 minute song likehttps://www.youtube.com/watch?v=Ks9Ck5LfGWE
or longerhttps://www.youtube.com/watch?v=VThrx5MRJXA
(10 hours classical music), there is an evident slowdown when running the;ff
command. However, when I include a few seconds of delay between firings of the;ff
command, the seeking is just as fast as previously mentioned. I'm not exactly sure what is going on with yt-dlp/FFmpeg behind the scenes when streaming, but I speculate that there is some sort of internal buffer, and songs that pass a certain length threshold are processed differently.

For longer songs, the
seek()
command takes longer to get to the desired position, which makes sense since this site specifies that-ss
used as an input option loops through keyframes (as there must be more keyframes in longer songs). However, if the following commands are run in Discord :

;p https://www.youtube.com/watch?v=VThrx5MRJXA <- 10 hour classical music
;j 09:00:00 <- jump to 9 hour mark
;j 00:03:00 <- jump to 3 minute mark



The first seek command takes around 5 to 10 seconds to perform a successful seek, which isn't bad, but it could be better. The second seek command takes around the same time as the first command, which doesn't make sense to me, because I thought less keyframes were skipped in order to reach the 3 minute mark.


So I'm wondering what's going on, and how to potentially solve the following :


- 

- What is actually going on with the
seek()
command ? My implementation ofseek()
uses discord.py'sdiscord.player.FFmpegPCMAudio.read()
method, which apparently runs slower if the song's length is longer ? Why ? - Why does input seeking for long YouTube videos take almost the same time no matter where I seek to ?
- How the yt-dlp and FFmpeg commands work behind the scenes to stream a video from YouTube (or any other website that YTDL supports). Does yt-dlp and FFmpeg behave differently for audio streams above a certain length threshold ?
- Potential ways to speed up
seek()
andjump()
for long songs. I recall some well-known discord music bots were able to do this very quickly.










- What is actually going on with the
-
avfilter/vf_libplacebo : fix format query
7 février 2023, par Niklas Haasavfilter/vf_libplacebo : fix format query
We need to construct the output format list separatedly from the input
format list, because we need to adhere to two extra requirements :1. Big-endian output formats are always unsupported (runtime error)
2. Combining 'vulkan' with an explicit out_format that is not supported
by the vulkan frame allocation code is illegal and will crash (abort)As a free side benefit, this rewrite fixes a possible memory leak in the
`fail` path that was present in the old code.Signed-off-by : Niklas Haas <git@haasn.dev>