Recherche avancée

Médias (29)

Mot : - Tags -/Musique

Autres articles (103)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • De l’upload à la vidéo finale [version standalone]

    31 janvier 2010, par

    Le chemin d’un document audio ou vidéo dans SPIPMotion est divisé en trois étapes distinctes.
    Upload et récupération d’informations de la vidéo source
    Dans un premier temps, il est nécessaire de créer un article SPIP et de lui joindre le document vidéo "source".
    Au moment où ce document est joint à l’article, deux actions supplémentaires au comportement normal sont exécutées : La récupération des informations techniques des flux audio et video du fichier ; La génération d’une vignette : extraction d’une (...)

  • Encodage et transformation en formats lisibles sur Internet

    10 avril 2011

    MediaSPIP transforme et ré-encode les documents mis en ligne afin de les rendre lisibles sur Internet et automatiquement utilisables sans intervention du créateur de contenu.
    Les vidéos sont automatiquement encodées dans les formats supportés par HTML5 : MP4, Ogv et WebM. La version "MP4" est également utilisée pour le lecteur flash de secours nécessaire aux anciens navigateurs.
    Les documents audios sont également ré-encodés dans les deux formats utilisables par HTML5 :MP3 et Ogg. La version "MP3" (...)

Sur d’autres sites (6438)

  • ffmpeg video streaming issue

    20 avril, par Personboiii

    I 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 Use SVG Image Files Directly in FFmpeg ? [closed]

    10 mars, par Pubg Mobile

    I 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 !

    


  • How to Capture a Sequence of High-Quality PDF Frames from a Website (Without Screen Recording) ?

    9 mars, par Pubg Mobile

    In Firefox, I can take very high-quality screenshots of a webpage by using Ctrl + P and saving the page as a PDF. This method preserves the text, images, and code in excellent resolution.

    


    Now, I have created a movable bar chart race in Flourish Studio and want to convert it into a high-quality video. However, I do not want to use screen recording tools.

    


    My Goal :
    
I want to capture 30 high-resolution PDF frames from the website at different points in time (like a video sequence). Ideally, I need a tool or script that can automate the process of saving multiple PDFs from the website as it plays the animation.

    


    What I Tried :
    
I attempted to write a Python script that :

    


    Opens the local HTML file of my Flourish chart in Firefox using Selenium.
    
Waits for the page to load.
    
Listens for the F1 key and triggers Ctrl + P to print the page as a PDF.
    
However, the script does not save the PDF file in the output folder. I'm not sure why.

    


    Here is my code :

    


    import time
import keyboard
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options

# Define paths
html_file_path = r"E:\Desktop\New folder (4)\20250309101616805.html"
geckodriver_path = r"E:\Desktop\New folder (4)\geckodriver.exe"
save_path = r"E:\Desktop\New folder (4)\New folder\output.pdf"  # Save PDF location

# Set up Firefox options
options = Options()
options.set_preference("print.always_print_silent", True)  # Silent printing
options.set_preference("print.show_print_progress", False)  # Hide progress
options.set_preference("print.print_to_file", True)  # Print to file
options.set_preference("print.save_print_settings", True)  # Save settings
options.set_preference("print.printer_PDF", "Save as PDF")  # Set printer
options.set_preference("print.print_to_file", True)  # Enable saving print output to file
options.set_preference("print.print_file_name", save_path)  # Define the save location for PDF

# Start WebDriver
service = Service(executable_path=geckodriver_path)
driver = webdriver.Firefox(service=service, options=options)

# Open the HTML file
driver.get("file:///" + html_file_path)

# Wait for the page to load
time.sleep(2)

print("Press F1 to save as PDF.")

# Listen for F1 key press
while True:
    if keyboard.is_pressed('F1'):
        print("F1 pressed, saving as PDF...")
        
        # Trigger print command (Ctrl + P)
        body = driver.find_element(By.TAG_NAME, 'body')
        body.send_keys(Keys.CONTROL + 'p')
        
        # Wait for the print dialog to process
        time.sleep(2)

        print("PDF should be saved to:", save_path)
        break

# Close browser
driver.quit()


    


    My Questions :

    


    Why is my script not saving the PDF in the specified output folder ?

    


    Is there a better way to automate capturing 30 sequential PDFs from the website at different animation frames ?

    


    Is there any tool or script that can generate a sequence of PDFs (like 30 frames per second) from a webpage ?

    


    Important :

    


    I do NOT want to use screen recording tools.

    


    I only need high-quality PDF frames that can later be converted into a video.

    


    Any help would be greatly appreciated !