Recherche avancée

Médias (91)

Autres articles (46)

  • Librairies et logiciels spécifiques aux médias

    10 décembre 2010, par

    Pour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
    Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...)

  • Installation en mode ferme

    4 février 2011, par

    Le mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
    C’est la méthode que nous utilisons sur cette même plateforme.
    L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
    Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette 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.

Sur d’autres sites (7081)

  • Seam carving

    9 juin 2010, par Mikko Koppanen — Imagick, PHP stuff

    Today I was reading trough the ImageMagick ChangeLog and noticed an interesting entry. “Add support for liquid rescaling”. I rushed to check the MagickWand API docs and there it was : MagickLiquidRescaleImage ! After about ten minutes of hacking the Imagick support was done. Needless to say ; I was excited :)

    For those who don’t know what seam carving is check the demo here. More detailed information about the algorithm can be found here : “Seam Carving for Content-Aware Image Resizing” by Shai Avidan and Ariel Shamir

    To use this functionality you need to install at least ImageMagick 6.3.8-2 and liblqr. Remember to pass –with-lqr to ImageMagick configuration line. You can get liblqr here : http://liblqr.wikidot.com/. The Imagick side of the functionality should appear in the CVS today if everything goes as planned.

    Here is a really simple example just to illustrate the results of the operation. The parameters might be far from optimal (didn’t do much testing yet). The original dimensions of image are 500×375 and the resulting size is 500×200.

    Update : the functionality is pending until license issues are solved.

    1. < ?php
    2.  
    3. /* Create new object */
    4. $im = new Imagick( ’test.jpg’ ) ;
    5.  
    6. /* Scale down */
    7. $im->liquidRescaleImage( 500, 200, 3, 25 ) ;
    8.  
    9. /* Display */
    10. header( ’Content-Type : image/jpg’ ) ;
    11. echo $im ;
    12.  
    13.  ?>

    The original image by flickr/jennconspiracy

    result

    And the result :

    result

    Update. On kenrick’s request here is an image which is scaled down to 300×300

    result2

  • Decoding the h.264 stream from a COM port

    18 mars, par Peter

    I would like to know if there is a reliable way to decode an H.264 NAL stream coming through a serial port using software.

    &#xA;

    So far, I have managed to decode a single frame using a python script. In this script, I first write the incoming data to a file, and when the end-of-frame marker 00_00_00_01 appears, I display the frame using ffplay.

    &#xA;

    import serial&#xA;import subprocess&#xA;import os&#xA;import time&#xA;&#xA;ser = serial.Serial(&#x27;COM3&#x27;, 115200, timeout=1)&#xA;output_file = "output.264"&#xA;&#xA;# Variable to store the ffplay process&#xA;ffplay_process = None&#xA;&#xA;# Open the file for writing in binary mode&#xA;with open(output_file, "wb") as file:&#xA;&#xA;    print("Writing bytes to output.264. Waiting for the end-of-frame marker 0x00000001.")&#xA;&#xA;    buffer = bytearray()&#xA;    marker = b&#x27;\x00\x00\x00\x01&#x27;&#xA;&#xA;    try:&#xA;        while True:&#xA;            if ser.in_waiting:  # If there is data in the buffer&#xA;                data = ser.read(ser.in_waiting)  # Read all available bytes&#xA;                buffer.extend(data)&#xA;&#xA;                # Check if the end-of-frame marker is in the buffer&#xA;                while marker in buffer:&#xA;                    index = buffer.index(marker) &#x2B; len(marker)  # Position after the marker&#xA;                    frame = buffer[:index]  # Extract the frame&#xA;                    buffer = buffer[index:]  # Keep the remaining data&#xA;&#xA;                    print(f"Frame recorded: {len(frame)} bytes")&#xA;                    file.write(frame)  # Write the frame to the file&#xA;                    file.flush()  # Force writing to disk&#xA;&#xA;                    # Close the ffplay window if it is already open&#xA;                    if ffplay_process and ffplay_process.poll() is None:&#xA;                        ffplay_process.terminate()&#xA;                        ffplay_process.wait()  # Wait for the process to terminate&#xA;&#xA;                    # Play the recorded frame, reopening the window&#xA;                    ffplay_process = subprocess.Popen(["ffplay", "-f", "h264", "-i", output_file])&#xA;&#xA;    except KeyboardInterrupt:&#xA;        print("\nRecording stopped.")&#xA;    finally:&#xA;        # Close the serial port and the ffplay process&#xA;        ser.close()&#xA;

    &#xA;

    However, each time a new end-of-frame marker is detected, the ffplay window closes and reopens to show the next frame. It will flicker when transferring the video. Is there a way to display the frames in the same window for seamless playback when streaming video ?

    &#xA;

    Or is there a better approach or software that is more suited for this task ? I do not know where to start, so I will be glad for any hints.

    &#xA;

  • Can't view and record graph at the same time using FFMpegWriter [closed]

    7 juillet 2024, par Barkın Özer

    So this code is used for graphing and logging sensor data coming from bluetooth ports. I wanted to add an function that will record the graph in mp4 format. In order to achieve this I used ffmpegWriter. The issue is while this code records the graph I can't view the graph at the same time.

    &#xA;

    import serial&#xA;import matplotlib.pyplot as plt&#xA;from matplotlib.animation import FuncAnimation, FFMpegWriter&#xA;import openpyxl&#xA;from datetime import datetime&#xA;&#xA;# Constants&#xA;GRAVITY = 9.81  # Standard gravity in m/s&#xB2;&#xA;&#xA;# Initialize serial connections to HC-06 devices&#xA;ser_x_accel = serial.Serial(&#x27;COM4&#x27;, 9600, timeout=1)  # X-axis acceleration data&#xA;ser_y_angle = serial.Serial(&#x27;COM11&#x27;, 9600, timeout=1)  # Y-axis angle data&#xA;&#xA;# Initialize empty lists to store data&#xA;x_accel_data = []&#xA;y_angle_data = []&#xA;timestamps = []&#xA;&#xA;# Initialize Excel workbook&#xA;wb = openpyxl.Workbook()&#xA;ws = wb.active&#xA;ws.title = "Sensor Data"&#xA;ws.append(["Timestamp", "X Acceleration (m/s&#xB2;)", "Y Angle (degrees)"])&#xA;&#xA;# Function to update the plot and log data&#xA;def update(frame):&#xA;    # Read data from serial connections&#xA;    line_x_accel = ser_x_accel.readline().decode(&#x27;utf-8&#x27;).strip()&#xA;    line_y_angle = ser_y_angle.readline().decode(&#x27;utf-8&#x27;).strip()&#xA;    &#xA;    try:&#xA;        # Parse and process X-axis acceleration data&#xA;        x_accel_g = float(line_x_accel)  # Acceleration in g read from serial&#xA;        x_accel_ms2 = x_accel_g * GRAVITY  # Convert from g to m/s&#xB2;&#xA;        x_accel_data.append(x_accel_ms2)&#xA;        &#xA;        # Parse and process Y-axis angle data&#xA;        y_angle = float(line_y_angle)&#xA;        y_angle_data.append(y_angle)&#xA;        &#xA;        # Append timestamp&#xA;        timestamps.append(datetime.now())&#xA;&#xA;        # Limit data points to show only the latest 100&#xA;        if len(x_accel_data) > 100:&#xA;            x_accel_data.pop(0)&#xA;            y_angle_data.pop(0)&#xA;            timestamps.pop(0)&#xA;&#xA;        # Log data to Excel with timestamp&#xA;        timestamp_str = timestamps[-1].strftime("%H:%M:%S")&#xA;        ws.append([timestamp_str, x_accel_data[-1], y_angle_data[-1]])&#xA;&#xA;        # Clear and update plots&#xA;        ax1.clear()&#xA;        ax1.plot(timestamps, x_accel_data, label=&#x27;X Acceleration&#x27;, color=&#x27;b&#x27;)&#xA;        ax1.legend(loc=&#x27;upper left&#x27;)&#xA;        ax1.set_ylim([-20, 20])  # Adjust based on expected acceleration range in m/s&#xB2;&#xA;        ax1.set_title(&#x27;Real-time X Acceleration Data&#x27;)&#xA;        ax1.set_xlabel(&#x27;Time&#x27;)&#xA;        ax1.set_ylabel(&#x27;Acceleration (m/s&#xB2;)&#x27;)&#xA;        ax1.grid(True)&#xA;&#xA;        ax2.clear()&#xA;        ax2.plot(timestamps, y_angle_data, label=&#x27;Y Angle&#x27;, color=&#x27;g&#x27;)&#xA;        ax2.legend(loc=&#x27;upper left&#x27;)&#xA;        ax2.set_ylim([-180, 180])&#xA;        ax2.set_title(&#x27;Real-time Y Angle Data&#x27;)&#xA;        ax2.set_xlabel(&#x27;Time&#x27;)&#xA;        ax2.set_ylabel(&#x27;Angle (degrees)&#x27;)&#xA;        ax2.grid(True)&#xA;&#xA;        # Update text boxes with latest values&#xA;        text_box.set_text(f&#x27;X Acceleration: {x_accel_data[-1]:.2f} m/s&#xB2;&#x27;)&#xA;        text_box2.set_text(f&#x27;Y Angle: {y_angle_data[-1]:.2f}&#xB0;&#x27;)&#xA;        &#xA;        # Save the workbook periodically (every 100 updates)&#xA;        if frame % 100 == 0:&#xA;            wb.save("sensor_data.xlsx")&#xA;        &#xA;    except ValueError:&#xA;        pass  # Ignore lines that are not properly formatted&#xA;&#xA;# Setup the plots&#xA;fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8))&#xA;text_box = ax1.text(0.05, 0.95, &#x27;&#x27;, transform=ax1.transAxes, fontsize=12, verticalalignment=&#x27;top&#x27;, bbox=dict(boxstyle=&#x27;round&#x27;, facecolor=&#x27;wheat&#x27;, alpha=0.5))&#xA;text_box2 = ax2.text(0.05, 0.95, &#x27;&#x27;, transform=ax2.transAxes, fontsize=12, verticalalignment=&#x27;top&#x27;, bbox=dict(boxstyle=&#x27;round&#x27;, facecolor=&#x27;wheat&#x27;, alpha=0.5))&#xA;&#xA;# Animate the plots&#xA;ani = FuncAnimation(fig, update, interval=100)  # Update interval of 100ms&#xA;&#xA;# Save the animation as a video file&#xA;writer = FFMpegWriter(fps=10, metadata=dict(artist=&#x27;Me&#x27;), bitrate=1800)&#xA;ani.save("sensor_data.mp4", writer=writer)&#xA;&#xA;plt.tight_layout()&#xA;plt.show()&#xA;&#xA;# Save the workbook at the end of the session&#xA;wb.save("sensor_data.xlsx")&#xA;&#xA;

    &#xA;

    I tried using OpenCV to record the graph but then I didn't even got any recording. I think solving this issue with my original code would be a better approach.

    &#xA;