Recherche avancée

Médias (1)

Mot : - Tags -/belgique

Autres articles (64)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Participer à sa traduction

    10 avril 2011

    Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
    Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
    Actuellement MediaSPIP n’est disponible qu’en français et (...)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (11948)

  • How to Convert 16:9 Video to 9:16 Ratio While Ensuring Speaker Presence in Frame ?

    28 avril 2024, par shreesha

    I am tried so many time to figure out the problem in detecting the face and also it's not so smooth enough to like other tools out there.

    


    So basically I am using python and Yolo in this project but I want the person who is talking and who the ROI (region of interest) is.

    


    Here is the code :

    


    from ultralytics import YOLO
from ultralytics.engine.results import Results
from moviepy.editor import VideoFileClip, concatenate_videoclips
from moviepy.video.fx.crop import crop

# Load the YOLOv8 model
model = YOLO("yolov8n.pt")

# Load the input video
clip = VideoFileClip("short_test.mp4")

tacked_clips = []

for frame_no, frame in enumerate(clip.iter_frames()):
    # Process the frame
    results: list[Results] = model(frame)

    # Get the bounding box of the main object
    if results[0].boxes:
        objects = results[0].boxes
        main_obj = max(
            objects, key=lambda x: x.conf
        )  # Assuming the first detected object is the main one

        x1, y1, x2, y2 = [int(val) for val in main_obj.xyxy[0].tolist()]

        # Calculate the crop region based on the object's position and the target aspect ratio
        w, h = clip.size
        new_w = int(h * 9 / 16)
        new_h = h

        x_center = x2 - x1
        y_center = y2 - y1

        # Adjust x_center and y_center if they would cause the crop region to exceed the bounds
        if x_center + (new_w / 2) > w:
            x_center -= x_center + (new_w / 2) - w
        elif x_center - (new_w / 2) < 0:
            x_center += abs(x_center - (new_w / 2))

        if y_center + (new_h / 2) > h:
            y_center -= y_center + (new_h / 2) - h
        elif y_center - (new_h / 2) < 0:
            y_center += abs(y_center - (new_h / 2))

        # Create a subclip for the current frame
        start_time = frame_no / clip.fps
        end_time = (frame_no + 1) / clip.fps
        subclip = clip.subclip(start_time, end_time)

        # Apply cropping using MoviePy
        cropped_clip = crop(
            subclip, x_center=x_center, y_center=y_center, width=new_w, height=new_h
        )

        tacked_clips.append(cropped_clip)

reframed_clip = concatenate_videoclips(tacked_clips, method="compose")
reframed_clip.write_videofile("output_video.mp4")


    


    So basically I want to fix the face detection with ROI detection where it can detect the face and make that face and the body on to the frame and making sure that the speaker who is speaking is brought to the frame

    


  • Discord.py bot joins voice channel but when using voicechannel.play i get error:Command raised an exception : ClientException : Not connected to voice

    25 mai 2023, par AudibleDruid

    So i've managed to get my discord bot to join a voice channel but when i use the play command it gives me an error that its not conencted to voice Command raised an exception: ClientException: Not connected to voice.

    


    Here is my code :

    


    import discord
import random
import glob
from discord.ext import commands

##discord intents 
intents = discord.Intents()
intents.members = True
intents.messages = True
intents.guilds = True
intents.voice_states = True


    


    connect the bot to a voice channel :

    


        
##called when user wants bot to join voice channel
@bot.command(name ='join', help = 'Make the bot join a voice channel')
async def join(context):
    
    botVoice = context.message.guild.voice_client
    if context.guild.voice_client:
        botvoicechannel = context.message.guild.voice_client.channel
    else:
        botvoicechannel = None
    authorVoice = context.author.voice
    if context.author.voice:
        authorvoicechannel = context.author.voice.channel
    else:
        authorvoicechannel = None
    
    ##await context.reply('bot voice channel: {}\n\nbot voice:\n{}\n\nauthor voice channel: {}\n\nauthor voice voice:\n{}\n\n'.format(botvoicechannel, botVoice, authorvoicechannel, authorVoice))
    
    if not authorVoice and not botVoice:
        await context.reply('Connect to a voice channel first.')
        return
    elif authorVoice and not botVoice:
        await context.reply('Connecting to {}'.format(authorvoicechannel))
        await authorvoicechannel.connect()
        return
    elif not authorVoice and botVoice:
        await context.reply("You aren't in a channel, I'm in {}".format(botvoicechannel))
        return
    elif authorVoice and botVoice:
        if (botvoicechannel == authorvoicechannel):
            await context.reply("I'm already in here.")
            return
        else:
            await context.reply('Moving to you!')
            await botVoice.move_to(authorvoicechannel)
            return
        return


    


    and have it play a url :

    


    @bot.command(name ='play', help = 'Make the bot play a url')
async def play(context, url):
    botVoice = context.message.guild.voice_client
    audioSource = discord.FFmpegPCMAudio(url, executable="ffmpeg")
    botVoice.play(audioSource, after = None)


    


    the code works and the bot joins the voice channel. i see it in the voice channel with me, however i get an error when it gets to botVoice.play(audioSource, after = None)

    


    the error message is :
error: Command raised an exception: ClientException: Not connected to voice.

    


    i changed botVoice = context.message.guild.voice_client from botVoice = context.guild.voice_client but that didnt seem to change anything. not sure what to try next. It seems like it wants to play the url the bot just doesnt realize its in the voice channel with me.

    


    maybe a related error. if i kill my python script the bot remains in the channel even though its not running. then when i start it up and do the !join command it says its joining even though its already in the channel with me. its weird because on the join command it checks to see if its already in a voice channel so it should know that its in there with me. idk what to try next. thanks for any suggestions. i only posted relevant code. let me know if you think im missing something else.

    


    thanks for the help

    


  • Telegram Bot - Editing Video in Channel Changes Aspect Ratio to Square

    11 octobre 2024, par Shayki Abramczyk

    I'm working on a Telegram bot that processes videos by adding a watermark and then edits the original message to replace the video in a channel post. The issue I'm encountering is that when I edit the message with the new video, the aspect ratio changes, and the video becomes a square, even though the original video is in vertical format.

    


    Here’s a simplified version of the code I’m using to edit the message with the processed video :

    


    video_file = await video.get_file()
print(video_file)
random = randint(0,9999)
input_path = f"input_{user_id}_{random}.mp4"
output_path = f"output_{user_id}_{random}.mp4"
await video_file.download_to_drive(input_path)

loop = asyncio.get_event_loop()
executor = ThreadPoolExecutor()
await loop.run_in_executor(executor, process_video_sync, input_path, output_path, watermark_path, settings)

try:
    if return_file:
        return open(output_path, 'rb')
    if channel:
        chat_id = post.chat_id
        message_id = post.message_id
        caption = post.caption if post.caption else ""
        if settings['has_signature']:
            signature = settings['signature']
        else:
            caption = post.caption_html if post.caption_html else (post.caption or "")
        video_clip = VideoFileClip(output_path)
        await context.bot.edit_message_media(
            chat_id=chat_id,
            message_id=message_id,
            media=InputMediaVideo(media=open(output_path, 'rb'), width=video_clip.w, height=video_clip.h, caption=caption, parse_mode="HTML")
        )
    elif update.message:
        caption = update.message.caption if update.message.caption else ""
        video_clip = VideoFileClip(output_path)
        
        with open(output_path, 'rb') as video_file:
            await update.message.reply_video(
                video=InputFile(video_file),
                caption=caption,
                width=video_clip.w,
                height=video_clip.h,
                supports_streaming=True
            )
except Exception as e:
    logger.error("Error in sending video. Exception Type:", e.args[0][0], "Message:", e.args[0][1])
finally:
    os.remove(input_path)
    os.remove(output_path)


    


    When editing the message in a channel, the video’s aspect ratio changes from vertical to square (if the video is horizonal it's ok). However, if I send the video as a new message, the aspect ratio remains correct.

    


    How can I ensure that when I edit the video in the channel, the aspect ratio stays the same as the original, and doesn’t get cropped or turned into a square ?