Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (7)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Menus personnalisés

    14 novembre 2010, par

    MediaSPIP utilise le plugin Menus pour gérer plusieurs menus configurables pour la navigation.
    Cela permet de laisser aux administrateurs de canaux la possibilité de configurer finement ces menus.
    Menus créés à l’initialisation du site
    Par défaut trois menus sont créés automatiquement à l’initialisation du site : Le menu principal ; Identifiant : barrenav ; Ce menu s’insère en général en haut de la page après le bloc d’entête, son identifiant le rend compatible avec les squelettes basés sur Zpip ; (...)

Sur d’autres sites (4336)

  • avformat_close_input memory leak ?

    20 janvier 2021, par Keen Jackdaw

    I developed an app to push live stream with ffmpeg. When I checked the app with leaks --atExit -- <the app="app"></the> (I'm on mac), I found some memory leak with AVFormatContext.

    &#xA;

    The minimized code are provided below :

    &#xA;

    #include <iostream>&#xA;&#xA;extern "C" {&#xA;#include <libavcodec></libavcodec>avcodec.h>&#xA;#include <libavformat></libavformat>avformat.h>&#xA;#include <libavdevice></libavdevice>avdevice.h>&#xA;}&#xA;&#xA;void foo() {&#xA;    avdevice_register_all();&#xA;&#xA;    AVFormatContext *avInputFormatContext = avformat_alloc_context();&#xA;    AVInputFormat *avInputFormat = av_find_input_format("avfoundation");&#xA;    std::cout &lt;&lt; "open input" &lt;&lt; std::endl;&#xA;    int ret = avformat_open_input(&amp;avInputFormatContext, "Capture screen 0", avInputFormat, nullptr);&#xA;    if (ret &lt; 0) { std::cout &lt;&lt; "open input failed: " &lt;&lt; ret &lt;&lt; std::endl; return;}&#xA;&#xA;    avformat_close_input(&amp;avInputFormatContext);&#xA;&#xA;}&#xA;&#xA;int main() {&#xA;    foo();&#xA;    return 0;&#xA;}&#xA;&#xA;</iostream>

    &#xA;

    The output is

    &#xA;

    Process:         ffmpegtest [87726]&#xA;Path:            /Users/USER/*/ffmpegtest&#xA;Load Address:    0x10a752000&#xA;Identifier:      ffmpegtest&#xA;Version:         ???&#xA;Code Type:       X86-64&#xA;Platform:        macOS&#xA;Parent Process:  leaks [87725]&#xA;&#xA;Date/Time:       2021-01-20 15:44:57.533 &#x2B;0800&#xA;Launch Time:     2021-01-20 15:44:55.760 &#x2B;0800&#xA;OS Version:      macOS 11.1 (20C69)&#xA;Report Version:  7&#xA;Analysis Tool:   /Applications/Xcode.app/Contents/Developer/usr/bin/leaks&#xA;Analysis Tool Version:  Xcode 12.3 (12C33)&#xA;&#xA;Physical footprint:         9.9M&#xA;Physical footprint (peak):  10.6M&#xA;----&#xA;&#xA;leaks Report Version: 4.0&#xA;Process 87726: 14143 nodes malloced for 2638 KB&#xA;Process 87726: 1 leak for 32 total leaked bytes.&#xA;&#xA;    1 (32 bytes) ROOT LEAK: 0x7f8c61e1b040 [32]  length: 16  "Capture screen 0"&#xA;

    &#xA;

    Did I miss something ?

    &#xA;

  • FFmpeg from Python has Corrupted Output

    14 juillet 2019, par Mazyod

    In 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 Hz

    Can 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 G

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

    &#xA;

    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.

    &#xA;

    &#xA;

    .venv\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py:178 : UserWarning : In file temp.mp4, 1080000 bytes wanted but 0&#xA;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.&#xA;warnings.warn(

    &#xA;

    &#xA;

    Complete code :

    &#xA;

    # to generate sound.wav&#xA;import numpy as np&#xA;import soundfile as sf&#xA;from tqdm import tqdm&#xA;from os import startfile&#xA;&#xA;# Parameters&#xA;filename = "sound.wav"&#xA;duration = 5  # seconds&#xA;num_voices = 1000&#xA;sample_rate = 44100  # Hz&#xA;chunk_size = sample_rate  # write in 1-second chunks&#xA;&#xA;&#xA;t = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)&#xA;&#xA;# Create many detuned sine waves (Deep Note style)&#xA;start_freqs = np.random.uniform(100, 400, num_voices)&#xA;end_freqs = np.linspace(400, 800, num_voices)  # target harmony&#xA;&#xA;# Each voice sweeps from start to end frequency&#xA;signal = np.zeros_like(t)&#xA;for i in range(num_voices):&#xA;    freqs = np.linspace(start_freqs[i], end_freqs[i], t.size)&#xA;    voice = np.sin(2 * np.pi * freqs * t)&#xA;    voice *= np.sin(np.pi * i / num_voices)  # slight variance&#xA;    signal &#x2B;= voice&#xA;&#xA;# Volume envelope&#xA;envelope = np.linspace(0.01, 1.0, t.size)&#xA;signal *= envelope&#xA;&#xA;# Normalize&#xA;signal /= np.max(np.abs(signal))&#xA;&#xA;# Save with progress bar using soundfile&#xA;with sf.SoundFile(&#xA;    filename, "w", samplerate=sample_rate, channels=1, subtype="PCM_16"&#xA;) as f:&#xA;    for i in tqdm(range(0, len(signal), chunk_size), desc=f"Saving {filename}"):&#xA;        f.write(signal[i : i &#x2B; chunk_size])&#xA;&#xA;&#xA;startfile(filename)&#xA;

    &#xA;

    # to generate temp.mp4&#xA;from numpy import pi, sin, cos&#xA;import matplotlib.pyplot as plt&#xA;from matplotlib.animation import FuncAnimation&#xA;from os import startfile&#xA;from tqdm import tqdm&#xA;from moviepy import VideoFileClip, AudioFileClip, CompositeAudioClip&#xA;&#xA;# Output settings&#xA;filename = "temp.mp4"&#xA;duration = 5  # seconds of animation&#xA;maxdim = 4  # canvas size in plot units (scaled)&#xA;fps = 60&#xA;&#xA;# Real-world parameters&#xA;r = 40  # km (radius)&#xA;endtime = 2  # hours (duration of real motion)&#xA;rph = 0.5  # rotations per hour&#xA;omega = 2 * pi * rph  # rad/hour&#xA;speed = omega * r  # km/hour&#xA;&#xA;# Animation setup&#xA;frames = duration * fps&#xA;scale = maxdim / r  # scale from km to plot units&#xA;dt = endtime / frames  # time per frame in hours&#xA;&#xA;# Prepare figure and axes&#xA;fig, ax = plt.subplots(figsize=(6, 6))&#xA;ax.set_xlim(-maxdim - 1, maxdim &#x2B; 1)&#xA;ax.set_ylim(-maxdim - 1, maxdim &#x2B; 1)&#xA;ax.set_aspect("equal")&#xA;ax.grid()&#xA;&#xA;&#xA;&#xA;# Plot circle path&#xA;circle = plt.Circle((0, 0), r * scale, color="lightgray", fill=False, linestyle="--")&#xA;ax.add_patch(circle)&#xA;&#xA;# Moving point&#xA;(point,) = ax.plot([], [], "ro")&#xA;&#xA;# Info text at center of the circle&#xA;info_text = ax.text(&#xA;    0, 0, "", fontsize=10,&#xA;    ha="center", va="center",&#xA;    bbox=dict(boxstyle="round,pad=0.4", facecolor="white", alpha=0.8)&#xA;)&#xA;&#xA;&#xA;def init():&#xA;    point.set_data([], [])&#xA;    info_text.set_text("")&#xA;    return point, info_text&#xA;&#xA;&#xA;def update(frame):&#xA;    t = frame * dt  # time in hours&#xA;    theta = omega * t  # angle in radians&#xA;&#xA;    x = r * cos(theta) * scale&#xA;    y = r * sin(theta) * scale&#xA;&#xA;    point.set_data([x], [y])&#xA;    info_text.set_text(&#xA;        f"Time: {t:.2f} hr\nRadius: {r:.1f} km\nSpeed: {speed:.2f} km/h"&#xA;    )&#xA;    return point, info_text&#xA;&#xA;&#xA;&#xA;# Create animation&#xA;anim = FuncAnimation(&#xA;    fig, update, frames=frames, init_func=init, blit=True, interval=1000 / fps&#xA;)&#xA;&#xA;&#xA;with tqdm(total=frames, desc="Saving", unit="frame") as pbar:&#xA;    anim.save(filename, fps=fps, progress_callback=lambda i, n: pbar.update(1))&#xA;&#xA;# Add sound using MoviePy&#xA;video = VideoFileClip(filename)&#xA;video.audio = CompositeAudioClip([AudioFileClip("sound.wav")])&#xA;video.write_videofile(filename)&#xA;&#xA;startfile(filename)&#xA;

    &#xA;

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

    &#xA;

    enter image description here

    &#xA;

    Edit

    &#xA;

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

    &#xA;

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

    &#xA;