
Recherche avancée
Médias (29)
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#3 The Safest Place
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#4 Emo Creates
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#2 Typewriter Dance
15 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (111)
-
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
-
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 (...) -
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 (...)
Sur d’autres sites (10115)
-
How to dynamically overlay images with ffmpeg
23 mai, par RorschyAs a part of a bigger project, I'm trying to stream a live feed using ffmpeg through RTSP while also dynamically changing subtitles depending on the situation.


As of now, I'm able to live stream with no issue. I also came across a solution for the subtitles by using a text file.


However, I'd like to avoid having this text file in my project. I thought about creating a picture with the subtitles and overlaying it with the screen stream. However, with my current solution, the data is streamed only when I kill the running code (data streamed for a few seconds).


Here is the current code for this problem :


import subprocess
import threading
import string
import random
import time
import io
from PIL import Image, ImageDraw, ImageFont

RTSP_URL = "..."
ffmpeg = None

def generate_subtitle():
 width = 640
 height = 100
 font_size = 32
 while True:
 if ffmpeg:
 try:
 text = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))

 image = Image.new("RGBA", (width, height), (0, 0, 0, 128))
 draw = ImageDraw.Draw(image)

 try:
 font = ImageFont.truetype("arial.ttf", font_size)
 except IOError:
 font = ImageFont.load_default()

 bbox = draw.textbbox((0, 0), text, font=font)
 text_width = bbox[2] - bbox[0]
 text_height = bbox[3] - bbox[1]

 x = (width - text_width) // 2
 y = (height - text_height) // 2

 draw.text((x, y), text, font=font, fill=(255, 255, 255, 255))
 buffer = io.BytesIO()
 image.save(buffer, format="PNG")
 ffmpeg.stdin.write(buffer.getvalue())
 ffmpeg.stdin.flush()
 time.sleep(5)
 except Exception as e:
 print("Erreur d'envoi d'image :", e)
 break
 else:
 time.sleep(1)

def run_ffmpeg():
 global ffmpeg
 ffmpeg = subprocess.Popen([
 'ffmpeg',

 # Input 0: capture desktop
 "-f", "gdigrab",
 "-offset_x", "0",
 "-offset_y", "0",
 "-video_size", "1920x1080",
 "-i", "desktop",

 # Input 1: PNG overlay from stdin
 "-f", "image2pipe",
 "-vcodec", "png",
 "-i", "-",

 # Filter to overlay Input 1 on Input 0
 "-filter_complex", "[0:v][1:v]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)-10",

 # Output settings
 "-vcodec", "libx264",
 "-preset", "ultrafast",
 "-tune", "zerolatency",
 "-g", "30",
 "-sc_threshold", "0",
 "-f", "rtsp",
 RTSP_URL
 ], stdin=subprocess.PIPE)

threading.Thread(target=run_ffmpeg, daemon=True).start()

threading.Thread(target=generate_subtitle, daemon=True).start()

while True:
 time.sleep(1)




My question is how can I stream the data correctly ?
If there is another solution to change dynamically the subtitles without using a text file or a temporary file I'd be glad to hear it.


-
avcodec/mpegvideo_dec : Move memcpy'ing ctx to mpeg4videodec.c
29 avril, par Andreas Rheinhardtavcodec/mpegvideo_dec : Move memcpy'ing ctx to mpeg4videodec.c
When the destination MpegEncContext in ff_mpeg_update_thread_context()
is not initialized, the source MpegEncContext is simply copied
over it before (potentially) calling ff_mpv_common_init().
This leads to data races when this code is executed which is why
it should be replaced with only copying the necessary fields
(this is for future commits).Given that the RV30 and RV40 decoders always call said function
with an already initialized MpegEncContext (they use context_reinit
in case of frame size changes), they don't need this ugly
initialization (and are therefore race-free). This means that
this code can be moved to the only decoder that actually needs it :
MPEG-4. This commit does so.Signed-off-by : Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-
ffmpeg video streaming issue
20 avril, par PersonboiiiI am trying to embed an adb video stream into an html site with flask, and the code I have keeps on returning this same error :


FFmpeg: [mjpeg @ 0x156631c10] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown)): unspecified size
FFmpeg: Consider increasing the value for the 'analyzeduration' (1000000) and 'probesize' (5000000) options
FFmpeg: Input #0, mjpeg, from 'pipe:0':
FFmpeg: Duration: N/A, bitrate: N/A
FFmpeg: Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), 25 fps, 1200k tbr, 1200k tbn
FFmpeg: Output #0, mpegts, to 'pipe:1':
FFmpeg: [out#0/mpegts @ 0x156632110] Output file does not contain any stream
FFmpeg: Error opening output file pipe:1.
FFmpeg: Error opening output files: Invalid argument



this is my code :



from flask import Flask, Response
import subprocess
import json
import threading

app = Flask(__name__)

with open("data_file.json", "r") as f:
 config_data = json.load(f)

user = config_data["Users"]["Test User 1"]


def log_ffmpeg_errors(proc):
 for line in iter(proc.stderr.readline, b''):
 if line:
 print("FFmpeg:", line.decode(), end='')


def connect_device(ip, port):
 try:
 # Reconnect if device is offline
 subprocess.run(["adb", "tcpip", str(port)])
 subprocess.run(["adb", "connect", ip])
 # Check if the device is online
 devices = subprocess.check_output(["adb", "devices"]).decode()
 if "offline" in devices:
 raise Exception("Device is offline")
 except Exception as e:
 print(f"Error connecting device: {e}")


def generate_video_stream():
 adb_cmd = ["adb", "exec-out", "screenrecord", "--output-format=mjpeg"] # Use MJPEG output
 ffmpeg_cmd = [
 "ffmpeg",
 "-f", "mjpeg",
 "-analyzeduration", "1000000", 
 "-probesize", "5000000", 
 "-i", "pipe:0", 
 "-q:v", "5",
 "-r", "10",
 "-vcodec", "mjpeg", 
 "-s", "1280x720", 
 "-f", "mpegts", 
 "pipe:1" 
 ]

 adb_proc = subprocess.Popen(adb_cmd, stdout=subprocess.PIPE)
 ffmpeg_proc = subprocess.Popen(ffmpeg_cmd, stdin=adb_proc.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

 threading.Thread(target=log_ffmpeg_errors, args=(ffmpeg_proc,), daemon=True).start()

 try:
 while True:
 frame = ffmpeg_proc.stdout.read(4096)
 if not frame:
 break
 yield (b'--frame\r\n'
 b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')

 finally:
 adb_proc.terminate()
 ffmpeg_proc.terminate()

@app.route('/video_feed')
def video_feed():
 return Response(generate_video_stream(), mimetype='multipart/x-mixed-replace; boundary=frame')

if __name__ == "__main__":
 connect_device(user["IP"], user["port"])
 app.run(debug=True, host='0.0.0.0', port=8080)




I also changed it so that it is adb_cmd = ["adb","exec-out","screenrecord", "-output-format=h264","-"] and the error left but now the site header just keeps on loading and the embed in the html shows nothing. (ngrok for the site page says 200 ok)