Recherche avancée

Médias (2)

Mot : - Tags -/plugins

Autres articles (92)

  • MediaSPIP 0.1 Beta version

    25 avril 2011, par

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

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

Sur d’autres sites (7483)

  • How to insert commands for randomization and action after a given time

    26 avril 2021, par Señor Egg

    Right now in my code, I have it written out to play audio files after a !join command. I would like to change it to a command like after every 40 minutes, and I would like to be able to choose a random file to play out of a list. Help on how to ajust my code would be great !

    


    My code :

    


    from discord.ext import commands
from discord import FFmpegPCMAudio
 
client = commands.Bot(command_prefix = '!')
@client.command(pass_context=True)
async def join(ctx):
    if (ctx.author.voice):
        channel = ctx.message.author.voice.channel
        voice = await channel.connect()
        source = FFmpegPCMAudio('AUDIO FILE')
        player = voice.play(source)
    else:
        await ctx.send("User not in a voice channel, unable to connect.")
 
@client.command(pass_context=True)
async def leave(ctx):
    if (ctx.voice_client):
        await ctx.guild.voice_client.disconnect()
        await ctx.send("I have left the voice channel.")
    else:
         await ctx.send("I am not in a voice channel.")
 
 
 
client.run('BOT TOKEN')```


    


  • Estimating number of frames and fps in opencv

    11 mai 2021, par mrgloom

    I have some .mp4 video, ffmpeg shows me this info :

    


      Duration: 00:00:07.02, start: 0.000000, bitrate: 18001 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709/bt709/iec61966-2-1, progressive), 886x1920, 14299 kb/s, 22.54 fps, 60 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      rotate          : 270
      creation_time   : 2021-04-30T13:56:51.000000Z
      handler_name    : Core Media Video
      encoder         : 'avc1'
    Side data:
      displaymatrix: rotation of 90.00 degrees


    


    So as I understand it should be 7.02 sec * 22.54 fps 158 frames

    


    When I try to read it in opencv :

    


    def print_info_cap_reading(video_filepath):
    cap = cv2.VideoCapture(video_filepath)

    fps = cap.get(cv2.CAP_PROP_FPS)
    n_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

    print('fps:', round(fps, 2))
    print('n_frames', n_frames)

    counter = 0
    while True:
        ret, frame = cap.read()
        if ret == False:
            break
        counter += 1

    print('counter:', counter)


    


    It shows me

    


    # fps: 22.54
# n_frames 199
# counter: 175


    


    When I tried to convert it to separate frames via ffmpeg it produce 422 frames :

    


    ffmpeg -i source1.mp4 tmp/img%03d.jpg


    


    So I wonder :

    


      

    1. Why fps is float value and not int value ?
    2. 


    3. What is the right way to estimate fps and number of frames ?
    4. 


    5. Why cv2.CAP_PROP_FRAME_COUNT in opencv and actually reading frames produce different number of frames ?
    6. 


    


    Update :

    


    -ignore_editlist 1 not helped, ffmpeg still produce 422 frames :

    


     ffmpeg -i source1.mp4 tmp1/img%03d.jpg
 ffmpeg -i source1.mp4 -ignore_editlist 1 tmp2/img%03d.jpg


    


    Here is some ffmpeg output :

    


    Output #0, image2, to 'tmp1/img%03d.jpg':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    com.apple.quicktime.author: ReplayKitRecording
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1920x886, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 mjpeg
      creation_time   : 2021-04-30T13:56:51.000000Z
      handler_name    : Core Media Video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
      displaymatrix: rotation of -0.00 degrees
frame=  422 fps=224 q=24.8 Lsize=N/A time=00:00:07.03 bitrate=N/A dup=247 drop=0 speed=3.74x
video:13709kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown


    


    Update :

    


    mkdir tmp3 && ffmpeg -ignore_editlist 1 -i source1.mp4 tmp3/img%03d.jpg produce even more frames - 529.

    


    Output #0, image2, to 'tmp3/img%03d.jpg':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    com.apple.quicktime.author: ReplayKitRecording
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1920x886, q=2-31, 200 kb/s, 60 fps, 60 tbn, 60 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 mjpeg
      creation_time   : 2021-04-30T13:56:51.000000Z
      handler_name    : Core Media Video
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
      displaymatrix: rotation of -0.00 degrees
frame=  529 fps=221 q=24.8 Lsize=N/A time=00:00:08.81 bitrate=N/A dup=330 drop=0 speed=3.68x
video:16178kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown


    


  • How do I send pydub audio segment raw data using discord.py to a voice channel ? I get error, hear nothing or gibberish noise depending on parameters

    8 mai 2021, par Hiello

    As the title says, I've been trying to send chunks audio data using discord.py to a voice channel. So using pydub I basically load an mp3 file (and playback works so file is ok), make chunks, send them as packages.
And then I tried to convert the mp3 file to opus file. It's playing too. Both files are ok.

    


    There are a few stuff :

    


    So the issue is, after I make the raw audio chunks list and try to send each element in it :

    


    a) With Encode=True, I get an error about NoneType object not having encode attribute.

    


    b) With Encode=False, it actually sends the data but I don't hear anything at all.

    


    c) With Encode=False, but when loading the mp3 file with additional codec="opus" parameter, I hear gibberish noise. So it's not for conversion i guess okay...

    


    d) With Encode=False, but when loading the opus file with additional codec="opus" parameter (without that codec="opus" i cant play the audio anyway), it's still the NoneType error.

    


    -I have all the 3 executables (ffmpeg.exe, ffplay.exe and ffprobe.exe) in the same directory as the script. But not in PATH. (Didn't tell me anything about it and playback worked, plus i heard the gibberish noise too at least so no problem here)

    


    -I also have m1.mp3 and m1.opus in the same directory as the script. It's ok.

    


    -There are no subdirectories or anything else.

    


    -I have PyNaCl and discord.py[audio] installed.

    


    I don't know where I'm doing wrong. What kind of data was i supposed to send if not this ? Can I encode the raw audio myself to opus without too much work and definitely not saving a file even if it is temp ?
I don't want to just load the mp3 file all at once and play, I need to be able to make chunks. I don't want to save these chunks anywhere either.

    


    Here is the code :

    


    import discord
import pydub
import os
from pydub.utils import make_chunks
import asyncio

TOKEN = ":("


base_path = os.getcwd()
pydub.AudioSegment.ffmpeg = os.path.join(base_path, "ffmpeg.exe")
pydub.AudioSegment.ffprobe = os.path.join(base_path, "ffprobe.exe")
pydub.AudioSegment.ffplay = os.path.join(base_path, "ffplay.exe")
pydub.AudioSegment.converter = os.path.join(base_path, "ffmpeg.exe")

#audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.mp3"), format="mp3")#, codec="opus")
audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.opus"), codec="opus") #dont add format="opus". format isnt extension ig. https://github.com/jiaaro/pydub/issues/257
#audio = pydub.AudioSegment.from_file(os.path.join(base_path, "m1.opus")) #didnt hear anything at all evn with play(audio) below.

audio = audio[:9*1000] #first 9 seconds

#let me be sure that it actually plays.
from pydub.playback import play #needs simpleaudio to work idk...
play(audio)

chunks = make_chunks(audio, (1/20)*1000)

client = discord.Client()

@client.event
async def on_ready():
    print("Ready.")

@client.event
async def on_message(message):
    if message.content.startswith(",test"):

        #connect to vc
        vp = await message.author.voice.channel.connect()

        #i tried with chunk._data as well. they are same anyway. 
        chunks_raw = [chunk.raw_data for chunk in chunks]
        #print(chunks_raw == [chunk._data for chunk in chunks]) #it's True
        
        print("Sending?")
        for i, chunk in enumerate(chunks_raw, start=1):
            vp.send_audio_packet(chunk, encode=True) #false --> not heard, true --> weird error (that occurs no matter if i have codec="opus" or not)
            print("Sent", i, "out of", len(chunks), "chunks.")
            await asyncio.sleep(1/20)

        vp.cleanup()
        await vp.disconnect()

        await message.channel.send("Playback is over.")
        
client.run(TOKEN)


    


    so if encode=True i get this (and i have no idea why) :

    


    Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\h\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\h\Desktop\randomly lying pys\bas\broken_audio_showcase.py", line 38, in on_message
    vp.send_audio_packet(chunk, encode=True) #false --> not heard, true --> weird error
  File "C:\Users\h\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\voice_client.py", line 633, in send_audio_packet
    encoded_data = self.encoder.encode(data, self.encoder.SAMPLES_PER_FRAME)
AttributeError: 'NoneType' object has no attribute 'encode'


    


    and if encode=False i can see "Sent i out of len(chunks) chunks" in console, yet i cant hear anything. I also see "Playback is over" message when it ends so it actually sends something...
if i go ahead and change the voice_client.py myself to add this to the first line of send_audio_packet function :

    


    self.encoder = opus.Encoder() #manually added

    


    and then i set encode to True, then it actually sends a hearable voice. of course its gibberish again, but at least i hear something from discord voice chat.

    


    can anyone actually help me with this ?

    


    Well I knew sound would be confusing, but never expected it to be this hard. I have no idea what counts as opus if not an opus file itself that's been converted via ffmpeg, not by literally changing the extension or anything.