
Recherche avancée
Autres articles (66)
-
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. -
Support audio et vidéo HTML5
10 avril 2011MediaSPIP utilise les balises HTML5 video et audio pour la lecture de documents multimedia en profitant des dernières innovations du W3C supportées par les navigateurs modernes.
Pour les navigateurs plus anciens, le lecteur flash Flowplayer est utilisé.
Le lecteur HTML5 utilisé a été spécifiquement créé pour MediaSPIP : il est complètement modifiable graphiquement pour correspondre à un thème choisi.
Ces technologies permettent de distribuer vidéo et son à la fois sur des ordinateurs conventionnels (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP 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 (...)
Sur d’autres sites (6968)
-
Editing Caption in Video Message Changes Aspect Ratio to Square
12 octobre 2024, par Shayki AbramczykI'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 ?


EDIT :


I found it's because I editing the video caption and added there some HTML elements which cause it.


If I just add a simple text it's ok.


Why ?


-
Docker fails to import FFMPEG or does not find it
8 décembre 2022, par stxssSo I'm trying to create a telegram bot using python and ffmpeg and I want to deploy it to a server through a docker image.


I already looked through a lot of resources as I've been looking at the same 5 lines of code for the past three days and neither discords, stack overflow previous answers have helped me.


This is my dockerfile where half of the program works (apart from the ffmpeg functionality).


FROM python:3.9

RUN mkdir /app
WORKDIR /app

COPY requirements.txt ./
RUN pip3 install --no-cache-dir --user -r requirements.txt

COPY . .

ENTRYPOINT ["/usr/bin/python3", "./app.py" ]



With this code I get the following error when trying to use a function that invokes ffmpeg functionality.


Traceback (most recent call last):
File "/root/.local/lib/python3.9/site-packages/pyrogram/dispatcher.py", line 240, in handler_worker
await handler.callback(self.client, *args)
File "/app/./app.py", line 274, in choice_from_inline
await helpers.trim_file(trim_length, "audio", chat_id_for_join.strip())
File "/app/helpers.py", line 53, in trim_file
output = ffmpeg.output(
File "/root/.local/lib/python3.9/site-packages/ffmpeg/_run.py", line 313, in run
process = run_async(
File "/root/.local/lib/python3.9/site-packages/ffmpeg/_run.py", line 284, in run_async
return subprocess.Popen(
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'



Another issue is that when changing the ENTRYPOINT (or using CMD) to
["python3", "./app.py" ]
everything works well locally but as soon as I try to deploy, the deployment/docker container just doesn't work or crash because I get the error ofModuleNotFoundError: No module named 'ffmpeg'
.

I have already tried setting up different ENV PATH and ENV PYTHONPATH, does absolutely nothing.
I have tried to use
COPY --from=jrottenberg/ffmpeg /usr/local ./
and it also doesn't work.
I have tried to explicitly useRUN apt-get install -y ffmpeg
and similar commands, pip, pip3, etc.. it just doesn't work.

I tried to use the copy command to access the
/root/.local/lib/python3.9/site-packages/ffmpeg/_run.py
but I either get a permission denied or a file does not exist error.

I am also using the ffmpeg-python wrapper and am using a windows machine if that's of any importance.


At this point I'm contemplating of finding another way of implementing the functionality I want without using ffmpeg.


I think I added everything I had, if needed more I can provide.


-
Editing Video in Channel Changes Aspect Ratio to Square
11 octobre 2024, par Shayki AbramczykI'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 ?