Recherche avancée

Médias (0)

Mot : - Tags -/xmlrpc

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (28)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • MediaSPIP version 0.1 Beta

    16 avril 2011, par

    MediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
    Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
    Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
    Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...)

  • MediaSPIP Player : problèmes potentiels

    22 février 2011, par

    Le lecteur ne fonctionne pas sur Internet Explorer
    Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
    Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)

Sur d’autres sites (4714)

  • Failed to add audio to mp4 with moviepy

    24 avril, par D G

    I generated an audio sound.wav and a video temp.mp4 that makes use of the audio. Both with the same duration.

    


    I got the following warning when generating the temp.mp4. The animation is out of sync, it means that it freezes before the audio finishes.

    


    


    .venv\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py:178 : UserWarning : In file temp.mp4, 1080000 bytes wanted but 0
bytes read at frame index 299 (out of a total 300 frames), at time 4.98/5.00 sec. Using the last valid frame instead.
warnings.warn(

    


    


    Complete code :

    


    # to generate sound.wav
import numpy as np
import soundfile as sf
from tqdm import tqdm
from os import startfile

# Parameters
filename = "sound.wav"
duration = 5  # seconds
num_voices = 1000
sample_rate = 44100  # Hz
chunk_size = sample_rate  # write in 1-second chunks


t = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)

# Create many detuned sine waves (Deep Note style)
start_freqs = np.random.uniform(100, 400, num_voices)
end_freqs = np.linspace(400, 800, num_voices)  # target harmony

# Each voice sweeps from start to end frequency
signal = np.zeros_like(t)
for i in range(num_voices):
    freqs = np.linspace(start_freqs[i], end_freqs[i], t.size)
    voice = np.sin(2 * np.pi * freqs * t)
    voice *= np.sin(np.pi * i / num_voices)  # slight variance
    signal += voice

# Volume envelope
envelope = np.linspace(0.01, 1.0, t.size)
signal *= envelope

# Normalize
signal /= np.max(np.abs(signal))

# Save with progress bar using soundfile
with sf.SoundFile(
    filename, "w", samplerate=sample_rate, channels=1, subtype="PCM_16"
) as f:
    for i in tqdm(range(0, len(signal), chunk_size), desc=f"Saving {filename}"):
        f.write(signal[i : i + chunk_size])


startfile(filename)


    


    # to generate temp.mp4
from numpy import pi, sin, cos
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from os import startfile
from tqdm import tqdm
from moviepy import VideoFileClip, AudioFileClip, CompositeAudioClip

# Output settings
filename = "temp.mp4"
duration = 5  # seconds of animation
maxdim = 4  # canvas size in plot units (scaled)
fps = 60

# Real-world parameters
r = 40  # km (radius)
endtime = 2  # hours (duration of real motion)
rph = 0.5  # rotations per hour
omega = 2 * pi * rph  # rad/hour
speed = omega * r  # km/hour

# Animation setup
frames = duration * fps
scale = maxdim / r  # scale from km to plot units
dt = endtime / frames  # time per frame in hours

# Prepare figure and axes
fig, ax = plt.subplots(figsize=(6, 6))
ax.set_xlim(-maxdim - 1, maxdim + 1)
ax.set_ylim(-maxdim - 1, maxdim + 1)
ax.set_aspect("equal")
ax.grid()



# Plot circle path
circle = plt.Circle((0, 0), r * scale, color="lightgray", fill=False, linestyle="--")
ax.add_patch(circle)

# Moving point
(point,) = ax.plot([], [], "ro")

# Info text at center of the circle
info_text = ax.text(
    0, 0, "", fontsize=10,
    ha="center", va="center",
    bbox=dict(boxstyle="round,pad=0.4", facecolor="white", alpha=0.8)
)


def init():
    point.set_data([], [])
    info_text.set_text("")
    return point, info_text


def update(frame):
    t = frame * dt  # time in hours
    theta = omega * t  # angle in radians

    x = r * cos(theta) * scale
    y = r * sin(theta) * scale

    point.set_data([x], [y])
    info_text.set_text(
        f"Time: {t:.2f} hr\nRadius: {r:.1f} km\nSpeed: {speed:.2f} km/h"
    )
    return point, info_text



# Create animation
anim = FuncAnimation(
    fig, update, frames=frames, init_func=init, blit=True, interval=1000 / fps
)


with tqdm(total=frames, desc="Saving", unit="frame") as pbar:
    anim.save(filename, fps=fps, progress_callback=lambda i, n: pbar.update(1))

# Add sound using MoviePy
video = VideoFileClip(filename)
video.audio = CompositeAudioClip([AudioFileClip("sound.wav")])
video.write_videofile(filename)

startfile(filename)


    


    Could you figure out what the culprit is and how to fix it ?

    


    enter image description here

    


    Edit

    


    Based on the given comment, I did the following but the problem still exists.

    


    # Add sound using MoviePy
video = VideoFileClip(filename)
audio = AudioFileClip("sound.wav")
audio.duration = video.duration
video.audio = CompositeAudioClip([audio])
video.write_videofile(filename)


    


  • FFmpeg, low quality merge using overlay filter [closed]

    24 mars, par He2A

    I am currently building a script, part of its functionality is to generate a cover art. I want to limit the scripts dependency to ffmpeg only so please don't suggest to use any other software to do the same.

    


    For this, I am using ffmpeg to generate separate components for the coverart, code is given below :

    


    # Draws transparent circle in correct background
ffmpeg -y -f lavfi -i "color=c=0x20292FFF:s=4000x4000,format=rgba" -filter_complex "geq=r='32':g='41':b='47':a='255*(1-between(hypot(X-2000,Y-2000),0,1150))'" -frames:v 1 -update 1 background.png

# Draws a circle gradient
ffmpeg -y -f lavfi -i "gradients=s=4000x4000:c0=0x33517e:c1=0x645098:c2=0xa53f97:c3=0xdf1177:c4=0xff033e:c5=0x2f4858:n=5:y0=750:x0=750:y1=3250:x1=3250:t=linear,format=rgba" -filter_complex "geq=g='g(X,Y)':a='255*between(hypot(X-2000,Y-2000),0,1200)'" -frames:v 1 -update 1 gradcir.png

# Draws the inner symbol
ffmpeg -y -f lavfi -i "color=c=0x20292FFF:s=4000x4000,format=rgba" -vf "geq=a='255*max(lte((X-2000+(530/3)+25)+sqrt(3)*abs(Y-2000),530)*gte(X-2000+(530/3)+25,0),between(hypot(X-2000,Y-2000),570,630))':r='255*max(lte((X-2000+(530/3)+25)+sqrt(3)*abs(Y-2000),530)*gte(X-2000+(530/3)+25,0),between(hypot(X-2000,Y-2000),570,630))':g='255*max(lte((X-2000+(530/3)+25)+sqrt(3)*abs(Y-2000),530)*gte(X-2000+(530/3)+25,0),between(hypot(X-2000,Y-2000),570,630))':b='255*max(lte((X-2000+(530/3)+25)+sqrt(3)*abs(Y-2000),530)*gte(X-2000+(530/3)+25,0),between(hypot(X-2000,Y-2000),570,630))'" -frames:v 1 shape.png


    


    Now to merge all three pngs, I am using the following command :

    


    ffmpeg -y -i background.png -i gradcir.png -i shape.png -filter_complex "[0][1]overlay[tmp];[tmp][2]overlay" cover.png


    


    All the code works but the problem is that the output is severely low quality with banding and improper merges in the borders of each image.

    


    I believe png is lossless so there shouldn't be any issue with artifacts but still I experimented with different levels of png compression but to no avail. I even tried enforcing rgba format for all three images prior to merging but to no avail.

    


    For now I alleviated the problem by generating all images in 4000x4000 resolution, applying a deband filter and then resizing it to 1000x1000.

    


    ffmpeg -y -i background.png -i gradcir.png -i shape.png -filter_complex "[0][1]overlay[tmp1];[tmp1][2]overlay[tmp2];[tmp2]format=rgb24,scale=2000:2000:flags=spline,deband,scale=1000:1000:flags=lanczos" -frames:v 1 -update 1 cover.png


    


    But the above method is expensive, which is problematic for low performance systems. Can anyone find out what seems to be the issue or suggest some better way to merge it ?

    


  • avcodec/sanm : FOBJ left/top are signed values

    11 mars, par Manuel Lauss
    avcodec/sanm : FOBJ left/top are signed values
    

    The left/top parameters of a FOBJ are signed values. Adjust
    codec1 code accordingly to not draw outside the buffer area.
    Rebel Assault 1 makes heavy use of this.

    Signed-off-by : Manuel Lauss <manuel.lauss@gmail.com>

    • [DH] libavcodec/sanm.c