
Recherche avancée
Autres articles (99)
-
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela. -
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)
Sur d’autres sites (10130)
-
Glitchy mp4 File saved with Matplotlib Animation via ffmpeg
9 janvier 2024, par Jacob IvanovI am attempting to save an
.mp4
file usingmatplotlib.animation
to output some simulation results. The relevent section is as follows :

ANI = FuncAnimation(fig, update, init_func = lambda : None, frames = range(0, 21300, 50))
ANI.save("[removed]/anim/v6 256 unforced 0.02.mp4", dpi = 600, fps = 30, writer = 'ffmpeg')



However, it appears that there is some issue in the produced
.mp4
file, as when I use macOS Quicktime to view the file, it pauses on certain frames, and restarts later on. It appears to consistently pause on the same frame a few seconds in. In order to check if Quicktime was the problem, I opened some random.mp4
files I found in a family group chat, and did not have this issue.

I also tried viewing this
.mp4
file with VLC, which had no issue, and played without any glitches. The Slack media viewer built into the app pauses similar to Quicktime.

The following are all relevant versions :


- 

- macOS : 14.2.1 (23C71)
- Python : 3.10.9 via Homebrew
- Matplotlib : 3.6.2
- ffmpeg : 6.1.1










If it would help, I can also provide the
.mp4
file itself, but I'm not quite sure how to upload it. I will be happy to provide any additional information as well.

Unfortunately, I'm not very familiar with video rendering, but I would appreciate any help anyone could provide. Thank you in advance !


-
How to Synchronize Audio with Video Frames [Python]
19 septembre 2023, par РостиславI want to stream video from URL to a server via socket, which then restreams it to all clients in the room.


This code streams video frame by frame :


async def stream_video(room, url):
 cap = cv2.VideoCapture(url)
 fps = round(cap.get(cv2.CAP_PROP_FPS))

 while True:
 ret, frame = cap.read()
 if not ret: break
 _, img_bytes = cv2.imencode(".jpg", frame)
 img_base64 = base64.b64encode(img_bytes).decode('utf-8')
 img_data_url = f"data:image/jpeg;base64,{img_base64}"

 await socket.emit('segment', { 'room': room, 'type': 'video', 'stream': img_data_url})
 await asyncio.sleep(1/fps)
 
 cap.release()



And this is code for stream audio :


async def stream_audio(room, url):
 sample_size = 14000
 cmd_audio = [
 "ffmpeg",
 "-i", url,
 '-vn',
 '-f', 's16le',
 '-c:a', 'pcm_s16le',
 "-ac", "2",
 "-sample_rate","48000",
 '-ar','48000',
 "-acodec","libmp3lame",
 "pipe:1"
 ]
 proc_audio = await asyncio.create_subprocess_exec(
 *cmd_audio, stdout=subprocess.PIPE, stderr=False
 )

 while True:
 audio_data = await proc_audio.stdout.read(sample_size)
 if audio_data:
 await socket.emit('segment', { 'room': room, 'type': 'audio', 'stream': audio_data})
 await asyncio.sleep(1)




But the problem is : how to synchronize them ? How many bytes need to be read every second from ffmpeg so that the audio matches the frames.


I tried to do this, but the problem with the number of chunks still remained :


while True:
 audio_data = await proc_audio.stdout.read(sample_size)
 if audio_data:
 await socket.emit('segment', { 'room': room, 'type': 'audio', 'stream': audio_data})

 for i in range(fps):
 ret, frame = cap.read()
 if not ret: break
 _, img_bytes = cv2.imencode(".jpg", frame)
 img_base64 = base64.b64encode(img_bytes).decode('utf-8')
 img_data_url = f"data:image/jpeg;base64,{img_base64}"

 await socket.emit('segment', { 'room': room, 'type': 'video', 'stream': img_data_url})
 await asyncio.sleep(1/fps)



I also tried loading a chunk of audio into pydub, but it shows that the duration of my 14000 chunk is 0.07s, which is very small. And if you increase the number of chunks for reading to 192k (as the gpt chat says), then the audio will simply play very, very quickly.
The ideal number of chunks that I was able to achieve is approximately 14000, but the audio is still not synchronous.


-
FFmpeg doesn't play audio, yet no error shown
4 août 2023, par KristupasSo i'm learning Python and don't know much about FFmpeg. I am following a tutorial, which explains everything very clearly. Everything is working, with one exception. Whenever I try to get it to play a sound, it won't.. Here's what it is saying :


INFO discord.player ffmpeg process 2540 successfully terminated with return code of 1.


And here's my code (forgive me for all of the childish things in there, i'm just trying out different features) :



import discord
import discord.ext
from discord import FFmpegPCMAudio
from discord.ext import commands
import random


Token = "No token for you :)"
client = commands.Bot(command_prefix = '!', intents=discord.Intents.all())


@client.event
async def on_ready():
 print(f"we're rolling as {client.user} \n")
 channel = client.get_channel(1022535885851459727)
 await channel.send("Tremble before my might hoomans😤😤")

#Member events:

@client.event
async def on_member_join(member):
 await member.send("Ok comrade, welcome to bot lab, pls not leave. Anways here rules \n1. No swearing \n2. No cursing \n3. No bullying, the owner is a crybaby \n4. No following the rules (u get banned if this one is broken)")
 channel = client.get_channel(1136658873688801302)
 jokes = [f"A failure known as {member} has joined this chat!", 
 f"Another {member} has joined the channel", 
 f"A {member} spawned", 
 f'cout << "{member} has joined teh chat" << endl;', 
 f"OUR great {member} has come to save us" ]
 await channel.send(jokes[random.randint(0,len(jokes))])

@client.event 
async def on_member_remove(member):
 await member.send("Bye our dear comrade")
 channel = client.get_channel(1136663317738442752)
 await channel.send(f"{member} has left the chat :(.)")

#Client commands:
 
@client.command()
async def hello(ctx):
 await ctx.send("Hello, I am pro bot")

@client.command()
async def byelol(ctx):
 await ctx.send("Bye, I am pro bot")
@client.command()
async def ping(ctx):
 await ctx.send(f"**pong** {ctx.message.author.mention}")


@client.event
async def on_message(message):
 message.content = message.content.lower()
 await client.process_commands(message)


#voice channel commands:

@client.command(pass_context = True)
async def micup(ctx):
 if (ctx.author.voice):
 await ctx.send(f"Joining on {ctx.message.author}'s command")
 channel = ctx.message.author.voice.channel
 voice = await channel.connect()
 source = FFmpegPCMAudio('Bluetooth.wav')
 player = voice.play(source)
 
 
 
 else:
 await ctx.send("No.")



@client.command(pass_Context = True)
async def leave(ctx):
 if (ctx.voice_client):
 await ctx.send(f"Leaving on {ctx.message.author}'s command")
 await ctx.guild.voice_client.disconnect()
 else:
 await ctx.send("Nyet. Im not in voice chat u stoopid hooman")


@client.command(pass_Context = True)
async def pause(ctx):
 voice = discord.utils.get(client.voice_clients, guild = ctx.guild)
 if voice.is_playing():
 await ctx.send("Pausing..⏸")
 voice.pause()
 else:
 await ctx.send("I don't think I will.")

@client.command(pass_Context = True)
async def resume(ctx):
 voice = discord.utils.get(client.voice_clients, guild = ctx.guild)
 if voice.is_paused():
 await ctx.send("My ears are bleeding")
 voice.resume()
 else:
 await ctx.send("ALREADY BLASTING MUSIC")

@client.command(pass_Context = True)
async def stop(ctx):
 voice = discord.utils.get(client.voice_clients, guild = ctx.guild)
 await ctx.send("You can stop the song, but you can't stop me!")
 voice.stop()

@client.command(pass_Context = True)
async def play(ctx, arg):
 await ctx.send("Playing..")
 voice = ctx.guild.voice_client
 source = FFmpegPCMAudio(arg)
 player = voice.play(source)

if '__main__' == __name__:
 client.run(Token)



I tried installing different versions of ffmpeg, still nothing. I tried to run the code outside of my venv, but still nothing (i doubt that it's the problem). I changed the path to it to different folders, still nothing.
The only time it DID work is when i entered a full path, but then when you want to play something, you wouldn't want to say " !play D:_Python\DiscordBot\Bluetooth.wav". From what i've seen, it's possible to play it by just saying " !play Bluetooth.wav".


So long story short : I want to make it so that the path i have to specify is just the file name. And when I do, it doesn't play the sound.
(sorry if this is a dupe question, i just couldn't find anything understandable for my amateur brain)