
Recherche avancée
Médias (2)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
-
Carte de Schillerkiez
13 mai 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
Autres articles (56)
-
ANNEXE : Les extensions, plugins SPIP des canaux
11 février 2010, parUn plugin est un ajout fonctionnel au noyau principal de SPIP. MediaSPIP consiste en un choix délibéré de plugins existant ou pas auparavant dans la communauté SPIP, qui ont pour certains nécessité soit leur création de A à Z, soit des ajouts de fonctionnalités.
Les extensions que MediaSPIP nécessite pour fonctionner
Depuis la version 2.1.0, SPIP permet d’ajouter des plugins dans le répertoire extensions/.
Les "extensions" ne sont ni plus ni moins que des plugins dont la particularité est qu’ils se (...) -
Gestion de la ferme
2 mars 2010, parLa ferme est gérée dans son ensemble par des "super admins".
Certains réglages peuvent être fais afin de réguler les besoins des différents canaux.
Dans un premier temps il utilise le plugin "Gestion de mutualisation" -
Possibilité de déploiement en ferme
12 avril 2011, parMediaSPIP peut être installé comme une ferme, avec un seul "noyau" hébergé sur un serveur dédié et utilisé par une multitude de sites différents.
Cela permet, par exemple : de pouvoir partager les frais de mise en œuvre entre plusieurs projets / individus ; de pouvoir déployer rapidement une multitude de sites uniques ; d’éviter d’avoir à mettre l’ensemble des créations dans un fourre-tout numérique comme c’est le cas pour les grandes plate-formes tout public disséminées sur le (...)
Sur d’autres sites (7494)
-
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)


-
How to restream IPTV playlist with Nginx RTMP, FFmpeg, and Python without recording, but getting HTTP 403 error ? [closed]
1er avril, par boyuna1720I have an IPTV playlist from a provider that allows only one user to connect and watch. I want to restream this playlist through my own server without recording it and in a lightweight manner. I’m using Nginx RTMP, FFmpeg, and Python TCP for the setup, but I keep getting an HTTP 403 error when trying to access the stream.


Here’s a summary of my setup :


Nginx RTMP : Used for streaming.


FFmpeg : Used to handle the video stream.


Python TCP : Trying to handle the connection between my server and the IPTV source.


#!/usr/bin/env python3

import sys
import socket
import threading
import requests
import time

def accept_connections(server_socket, clients, clients_lock):
 """
 Continuously accept new client connections, perform a minimal read of the
 client's HTTP request, send back a valid HTTP/1.1 response header, and
 add the socket to the broadcast list.
 """
 while True:
 client_socket, addr = server_socket.accept()
 print(f"[+] New client connected from {addr}")
 threading.Thread(
 target=handle_client,
 args=(client_socket, addr, clients, clients_lock),
 daemon=True
 ).start()

def handle_client(client_socket, addr, clients, clients_lock):
 """
 Read the client's HTTP request minimally, send back a proper HTTP/1.1 200 OK header,
 and then add the socket to our broadcast list.
 """
 try:
 # Read until we reach the end of the request headers
 request_data = b""
 while b"\r\n\r\n" not in request_data:
 chunk = client_socket.recv(1024)
 if not chunk:
 break
 request_data += chunk

 # Send a proper HTTP response header to satisfy clients like curl
 response_header = (
 "HTTP/1.1 200 OK\r\n"
 "Content-Type: application/octet-stream\r\n"
 "Connection: close\r\n"
 "\r\n"
 )
 client_socket.sendall(response_header.encode("utf-8"))

 with clients_lock:
 clients.append(client_socket)
 print(f"[+] Client from {addr} is ready to receive stream.")
 except Exception as e:
 print(f"[!] Error handling client {addr}: {e}")
 client_socket.close()

def read_from_source_and_broadcast(source_url, clients, clients_lock):
 """
 Continuously connect to the source URL (following redirects) using custom headers
 so that it mimics a curl-like request. In case of connection errors (e.g. connection reset),
 wait a bit and then try again.
 
 For each successful connection, stream data in chunks and broadcast each chunk
 to all connected clients.
 """
 # Set custom headers to mimic curl
 headers = {
 "User-Agent": "curl/8.5.0",
 "Accept": "*/*"
 }

 while True:
 try:
 print(f"[+] Fetching from source URL (with redirects): {source_url}")
 with requests.get(source_url, stream=True, allow_redirects=True, headers=headers) as resp:
 if resp.status_code >= 400:
 print(f"[!] Got HTTP {resp.status_code} from the source. Retrying in 5 seconds.")
 time.sleep(5)
 continue

 # Stream data and broadcast each chunk
 for chunk in resp.iter_content(chunk_size=4096):
 if not chunk:
 continue
 with clients_lock:
 for c in clients[:]:
 try:
 c.sendall(chunk)
 except Exception as e:
 print(f"[!] A client disconnected or send failed: {e}")
 c.close()
 clients.remove(c)
 except requests.exceptions.RequestException as e:
 print(f"[!] Source connection error, retrying in 5 seconds: {e}")
 time.sleep(5)

def main():
 if len(sys.argv) != 3:
 print(f"Usage: {sys.argv[0]} <port>")
 sys.exit(1)

 source_url = sys.argv[1]
 port = int(sys.argv[2])

 # Create a TCP socket to listen for incoming connections
 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
 server_socket.bind(("0.0.0.0", port))
 server_socket.listen(5)
 print(f"[+] Listening on port {port}...")

 # List of currently connected client sockets
 clients = []
 clients_lock = threading.Lock()

 # Start a thread to accept incoming client connections
 t_accept = threading.Thread(
 target=accept_connections,
 args=(server_socket, clients, clients_lock),
 daemon=True
 )
 t_accept.start()

 # Continuously read from the source URL and broadcast to connected clients
 read_from_source_and_broadcast(source_url, clients, clients_lock)

if __name__ == "__main__":
 main()
</port>


When i write command
python3 proxy_server.py 'http://channelurl' 9999

I getting error.

[+] Listening on port 9999...
[+] Fetching from source URL (with redirects): http://ate91060.cdn-akm.me:80/dc31a19e5a6a/fc5e38e28e/325973
[!] Got HTTP 403 from the source. Retrying in 5 seconds.
^CTraceback (most recent call last):
 File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 127, in <module>
 main()
 File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 124, in main
 read_from_source_and_broadcast(source_url, clients, clients_lock)
 File "/home/namepirate58/nginx-1.23.1/proxy_server.py", line 77, in read_from_source_and_broadcast
 time.sleep(5)
KeyboardInterrupt
</module>


-
How to Use SVG Image Files Directly in FFmpeg ? [closed]
10 mars, par Pubg MobileI generated a bar chart race using the Flourish Studio website and captured the frames as a PDF sequence using a Python Playwright script. Then, I converted all the PDF files into SVG format using the following Python script, because SVG is the only image format that maintains quality without loss when zoomed in :


import os
import subprocess
import multiprocessing

# Define paths
pdf2svg_path = r"E:\Desktop\dist-64bits\pdf2svg.exe" # Full path to pdf2svg.exe
input_dir = r"E:\Desktop\New folder (4)\New folder"
output_dir = r"E:\Desktop\New folder (4)\New folder (2)"

# Ensure output directory exists
os.makedirs(output_dir, exist_ok=True)

def convert_pdf_to_svg(pdf_file):
 """ Convert a single PDF file to SVG. """
 input_pdf = os.path.join(input_dir, pdf_file)
 output_svg = os.path.join(output_dir, os.path.splitext(pdf_file)[0] + ".svg")

 try:
 subprocess.run([pdf2svg_path, input_pdf, output_svg], check=True)
 print(f"Converted: {pdf_file} -> {output_svg}")
 except FileNotFoundError:
 print(f"Error: Could not find {pdf2svg_path}. Make sure the path is correct.")
 except subprocess.CalledProcessError:
 print(f"Error: Conversion failed for {pdf_file}")

if __name__ == "__main__":
 # Get list of PDF files in input directory
 pdf_files = [f for f in os.listdir(input_dir) if f.lower().endswith(".pdf")]

 # Use multiprocessing to speed up conversion
 with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
 pool.map(convert_pdf_to_svg, pdf_files)

 print("All conversions completed!")



Problem :


Now, I want to use these SVG images in FFmpeg to create a high-quality video file. However, FFmpeg does not support SVG files directly, and I have read that I must convert SVG files into PNG before using them in FFmpeg. The problem is that PNG images reduce quality, especially when zooming in, which is why I want to avoid converting to PNG.


Is there any way to use SVG files directly in FFmpeg or another method to convert them into a high-quality video while maintaining full resolution ? Any ideas or suggestions would be greatly appreciated !