
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (59)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Demande de création d’un canal
12 mars 2010, parEn fonction de la configuration de la plateforme, l’utilisateur peu avoir à sa disposition deux méthodes différentes de demande de création de canal. La première est au moment de son inscription, la seconde, après son inscription en remplissant un formulaire de demande.
Les deux manières demandent les mêmes choses fonctionnent à peu près de la même manière, le futur utilisateur doit remplir une série de champ de formulaire permettant tout d’abord aux administrateurs d’avoir des informations quant à (...) -
La file d’attente de SPIPmotion
28 novembre 2010, parUne 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 (...)
Sur d’autres sites (6536)
-
Revision 29188 : 2 options de plus pour personnaliser la page d’activation de la mutu : * ...
15 juin 2009, par real3t@… — Log2 options de plus pour personnaliser la page d’activation de la mutu :
* ’branding’ : texte libre en HTML
* ’branding_logo’ => logo (sous forme de HTML) -
FFmpeg from Python has Corrupted Output
14 juillet 2019, par MazyodIn a python script, I have :
os.system(ff_cmd)
# also tried Popen(ff_cmd, shell=True).wait()Then, I ran that same
ff_cmd
from terminal directly. Here are the results :# ff_cmd
ffmpeg -i "114006.mp3" -acodec pcm_s16le -ar 16000 -ac 1 "114-006-a4dec52a.wav"
# after running from python
% file 114-006-a4dec52a.wav
114-006-a4dec52a.wav: Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2, 40 kbps, 16 kHz, Monaural
# after running from terminal
% file 114-006-a4dec52a.wav
114-006-a4dec52a.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 HzCan anyone please explain why in the world would they result in different outputs ?
Output from Python :
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[mp3 @ 0x7ffa34001800] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/.../114006.mp3':
Duration: 00:00:09.53, start: 0.000000, bitrate: 64 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, stereo, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to '/.../114-006-a4dec52a.wav':
Metadata:
ISFT : Lavf58.20.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc58.35.100 pcm_s16le
size= 298kB time=00:00:09.53 bitrate= 256.1kbits/s speed= 166x
video:0kB audio:298kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.025564%Output from terminal :
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple LLVM version 10.0.1 (clang-1001.0.46.4)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.4 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[mp3 @ 0x7f98ed005800] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/.../114006.mp3':
Duration: 00:00:09.53, start: 0.000000, bitrate: 64 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, stereo, fltp, 64 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to '/.../114-006-a4dec52a.wav':
Metadata:
ISFT : Lavf58.20.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 16000 Hz, mono, s16, 256 kb/s
Metadata:
encoder : Lavc58.35.100 pcm_s16le
size= 298kB time=00:00:09.53 bitrate= 256.1kbits/s speed= 469x
video:0kB audio:298kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.025564% -
Failed to add audio to mp4 with moviepy
24 avril, par D GI generated an audio
sound.wav
and a videotemp.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 ?




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)