Recherche avancée

Médias (91)

Autres articles (18)

  • Personnaliser en ajoutant son logo, sa bannière ou son image de fond

    5 septembre 2013, par

    Certains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;

  • Ecrire une actualité

    21 juin 2013, par

    Présentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
    Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
    Vous pouvez personnaliser le formulaire de création d’une actualité.
    Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)

  • 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

Sur d’autres sites (4406)

  • Extracted .wav file from .mp4 video with ffmpeg only has half of the duration

    16 mars 2021, par TheSprinter

    I've been using ffmpeg to extract .wav files from .mp4 videos to then generate waveforms and spectrograms for it, but I stumbled upon a file for which ffmpeg does not generate the full audio file. The video duration is 25:25 (25 minutes and 25 seconds), but the .wav file is 12:28 (12 minutes and 28 seconds).

    


    This is what I've been doing :

    


    C:\Users\<user>> ffmpeg -i video.mp4 -ab 160k -ac 1 -ar 44100 -vn audio.wav&#xA;</user>

    &#xA;

    I tried with -ac 2 only to see if I get something different, but the result is the same. In fact, I can't generate the plots I need with a stereo audio file.

    &#xA;

    This is what I get in the terminal when I run the command :

    &#xA;

    C:\Users\<user>>ffmpeg -i video.mp4 -ab 160k -ac 1 -ar 44100 -vn audio.wav&#xA;ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with gcc 9.3.1 (GCC) 20200621&#xA;  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf&#xA;  libavutil      56. 51.100 / 56. 51.100&#xA;  libavcodec     58. 91.100 / 58. 91.100&#xA;  libavformat    58. 45.100 / 58. 45.100&#xA;  libavdevice    58. 10.100 / 58. 10.100&#xA;  libavfilter     7. 85.100 /  7. 85.100&#xA;  libswscale      5.  7.100 /  5.  7.100&#xA;  libswresample   3.  7.100 /  3.  7.100&#xA;  libpostproc    55.  7.100 / 55.  7.100&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;audio.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: mp42mp41&#xA;    creation_time   : 2021-03-09T05:00:00.000000Z&#xA;  Duration: 00:25:25.29, start: 0.000000, bitrate: 2308 kb/s&#xA;    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 4410 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-09T05:00:00.000000Z&#xA;      handler_name    : ?Mainconcept Video Media Handler&#xA;      encoder         : AVC Coding&#xA;    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 253 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-09T05:00:00.000000Z&#xA;      handler_name    : #Mainconcept MP4 Sound Media Handler&#xA;Stream mapping:&#xA;  Stream #0:1 -> #0:0 (aac (native) -> pcm_s16le (native))&#xA;Press [q] to stop, [?] for help&#xA;Output #0, wav, to &#x27;audio.wav&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: mp42mp41&#xA;    ISFT            : Lavf58.45.100&#xA;    Stream #0:0(eng): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2021-03-09T05:00:00.000000Z&#xA;      handler_name    : #Mainconcept MP4 Sound Media Handler&#xA;      encoder         : Lavc58.91.100 pcm_s16le&#xA;size=   64463kB time=00:12:28.41 bitrate= 705.6kbits/s speed= 156x&#xA;video:0kB audio:64463kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000118%&#xA;</user>

    &#xA;

    If this information on the video is not enough to troubleshoot, the video says the following (when it starts, for the first few seconds) :

    &#xA;

    &#xA;EP TRT (23.976): 01:24:53:18&#xA;EP TRT (29.976): 01:24:55:06&#xA;&#xA;AUDIO LAYOUT&#xA;&#xA;Channel 1: Left Front (L)&#xA;Channel 2: Right Front (R)&#xA;Channel 3: Center (C)&#xA;Channel 4: Low Frequency/Effects (LFE)&#xA;Channel 5: Left Surround (Ls)&#xA;Channel 6: Right Surround (Rs)&#xA;Channel 7: Mono Mix (L)&#xA;Channel 8: Mono Mix (R)&#xA;

    &#xA;

    This is for TV, that's why you see that longer duration. I don't know if all this is relevant, actually.

    &#xA;

    Some additional info

    &#xA;

    Something curious is that I'm doing this for manual tests, but I'm actually creating an app with python and, for that, I'm using python-ffmpeg module, and I with that I'm getting the correct .wav file (with the correct duration). The python lines for this are the following :

    &#xA;

    (&#xA;                        ffmpeg&#xA;                        .input(&#xA;                            &#xA;                        )&#xA;                        .output(&#xA;                            ,&#xA;                            audio_bitrate=316000,&#xA;                            ac=1,&#xA;                            ar=48000&#xA;                        )&#xA;                        .run()&#xA;)&#xA;

    &#xA;

  • Background transparency lost on new machine using matplotlib and ffmpeg

    23 octobre 2023, par Jan Turowski

    I am creating animated physics graphs with a transparent background for later use in a NLE. On my old machine at work they display and render with background transparency just fine. The exact same code however loses background transparency in the ffmpeg render on both my Linux and my Windows machine at home. The animations are displayed just fine on all machines.

    &#xA;

    As I first thought it was a Linux issue, I tried to run the code on my Windows machine expecting it to work again. Unfortunately it did not.

    &#xA;

    Reduced code :

    &#xA;

    import numpy as np&#xA;import matplotlib.pylab as plt&#xA;from matplotlib.animation import FuncAnimation&#xA;import matplotlib.animation as animation&#xA;from matplotlib.pyplot import figure&#xA;from matplotlib import style&#xA;import locale&#xA;from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)&#xA;# Set to German locale to get comma decimal separater&#xA;locale.setlocale(locale.LC_NUMERIC, "de_DE")&#xA;# Tell matplotlib to use the locale we set above&#xA;plt.rcParams[&#x27;axes.formatter.use_locale&#x27;] = True&#xA;&#xA;# plt.clf()&#xA;# plt.rcdefaults()&#xA;&#xA;# Style und Font definieren&#xA;&#xA;style.use(&#x27;dark_background&#x27;)&#xA;&#xA;# Pfeile erstellen&#xA;def arrowed_spines(fig, ax):&#xA;&#xA;    xmin, xmax = ax.get_xlim()&#xA;    ymin, ymax = ax.get_ylim()&#xA;&#xA;    # removing the default axis on all sides:&#xA;    for side in [&#x27;bottom&#x27;,&#x27;right&#x27;,&#x27;top&#x27;,&#x27;left&#x27;]:&#xA;        ax.spines[side].set_visible(False)&#xA;&#xA;    # removing the axis ticks&#xA;    # plt.xticks([]) # labels&#xA;    # plt.yticks([])&#xA;    # ax.xaxis.set_ticks_position(&#x27;none&#x27;) # tick markers&#xA;    # ax.yaxis.set_ticks_position(&#x27;none&#x27;)&#xA;&#xA;    # get width and height of axes object to compute&#xA;    # matching arrowhead length and width&#xA;    dps = fig.dpi_scale_trans.inverted()&#xA;    bbox = ax.get_window_extent().transformed(dps)&#xA;    width, height = bbox.width, bbox.height&#xA;&#xA;    # manual arrowhead width and length&#xA;    hw = 1./20.*(ymax-ymin)&#xA;    hl = 1./20.*(xmax-xmin)&#xA;    lw = 1. # axis line width&#xA;    ohg = 0.3 # arrow overhang&#xA;&#xA;    # compute matching arrowhead length and width&#xA;    yhw = hw/(ymax-ymin)*(xmax-xmin)* height/width&#xA;    yhl = hl/(xmax-xmin)*(ymax-ymin)* width/height&#xA;&#xA;    # draw x and y axis&#xA;    ax.arrow(xmin, 0, xmax-xmin, 0., fc=&#x27;w&#x27;, ec=&#x27;w&#x27;, lw = lw,&#xA;             head_width=hw, head_length=hl, overhang = ohg,&#xA;             length_includes_head= True, clip_on = False)&#xA;&#xA;    ax.arrow(0, ymin, 0., ymax-ymin, fc=&#x27;w&#x27;, ec=&#x27;w&#x27;, lw = lw,&#xA;             head_width=yhw, head_length=yhl, overhang = ohg,&#xA;             length_includes_head= True, clip_on = False)&#xA;&#xA;# Meine easing-Funktion&#xA;def ease(n):&#xA;    if n &lt; 0.0:&#xA;        return 0&#xA;    elif n > 1.0:&#xA;        return 1&#xA;    else:&#xA;        return 3*n**2-2*n**3&#xA;&#xA;# Meine Floor/Warte Funktion&#xA;def wait(n):&#xA;    if n &lt; 0.0:&#xA;        return 0&#xA;    else:&#xA;        return n&#xA;&#xA;# Canvas erstellen&#xA;fig = plt.figure()&#xA;ax = fig.add_subplot(111)&#xA;fig.set_size_inches([8,9])&#xA;&#xA;def f(x):&#xA;    return -0.05*x**2&#x2B;125&#xA;xlin = np.linspace(0,60,100)&#xA;&#xA;&#xA;# Beschriftung und Optik&#xA;&#xA;plt.xlabel(r"$x$ in $\rm{m}$", horizontalalignment=&#x27;right&#x27;, x=1.0)&#xA;plt.ylabel(r"$y$ in $\rm{m}$", horizontalalignment=&#x27;right&#x27;, y=1.0)&#xA;ax.set_xlim(0,100)&#xA;ax.set_ylim(0,139)&#xA;plt.grid(alpha=.4)&#xA;plt.xticks(np.arange(0, 100, 20))&#xA;plt.yticks(np.arange(0, 140, 20))&#xA;ax.yaxis.set_minor_locator(MultipleLocator(10))&#xA;ax.xaxis.set_minor_locator(MultipleLocator(10))&#xA;ax.tick_params(axis=&#x27;x&#x27;, direction = "inout", length= 10.0, which=&#x27;both&#x27;, width=3)&#xA;ax.tick_params(axis=&#x27;y&#x27;, direction = "inout", length= 10.0, which=&#x27;both&#x27;, width=3)&#xA;&#xA;&#xA;xsub = np.array([0])&#xA;&#xA;# statische Linien definieren&#xA;line2, = ax.plot(xsub,f(xsub),linewidth=5,zorder=0,c = &#x27;b&#x27;)&#xA;arrowed_spines(fig, ax)&#xA;plt.tight_layout()&#xA;&#xA;# Linien animieren&#xA;def animate(i):&#xA;&#xA;    xsub = xlin[0:wait(i-20)]&#xA;    global line2&#xA;    line2.remove()&#xA;    line2, = ax.plot(xsub, f(xsub), linewidth=5, zorder=0,c = "b")&#xA;    plt.tight_layout()&#xA;&#xA;animation = FuncAnimation(fig, animate, np.arange(0, 130, 1), interval=100)&#xA;&#xA;plt.show()&#xA;&#xA;# animation.save(r"YOUR\PATH\HERE\reduced_x-y.mov", codec="png",&#xA;         dpi=100, bitrate=-1,&#xA;         savefig_kwargs={&#x27;transparent&#x27;: True, &#x27;facecolor&#x27;: &#x27;none&#x27;})&#xA;&#xA;

    &#xA;

  • How to set background transparency for animation with ffmpeg

    23 octobre 2023, par Jan Turowski

    I am creating animated physics graphs with a transparent background for later use in a NLE. On my old machine at work they display and render with background transparency just fine. The exact same code however loses background transparency in the ffmpeg render on both my Linux and my Windows machine at home. The animations are displayed just fine on all machines.

    &#xA;

    As I first thought it was a Linux issue, I tried to run the code on my Windows machine expecting it to work again. Unfortunately it did not.

    &#xA;

    Reduced code :

    &#xA;

    import numpy as np&#xA;import matplotlib.pylab as plt&#xA;from matplotlib.animation import FuncAnimation&#xA;import matplotlib.animation as animation&#xA;from matplotlib.pyplot import figure&#xA;from matplotlib import style&#xA;import locale&#xA;from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)&#xA;# Set to German locale to get comma decimal separater&#xA;locale.setlocale(locale.LC_NUMERIC, "de_DE")&#xA;# Tell matplotlib to use the locale we set above&#xA;plt.rcParams[&#x27;axes.formatter.use_locale&#x27;] = True&#xA;&#xA;# plt.clf()&#xA;# plt.rcdefaults()&#xA;&#xA;# Style und Font definieren&#xA;&#xA;style.use(&#x27;dark_background&#x27;)&#xA;&#xA;# Pfeile erstellen&#xA;def arrowed_spines(fig, ax):&#xA;&#xA;    xmin, xmax = ax.get_xlim()&#xA;    ymin, ymax = ax.get_ylim()&#xA;&#xA;    # removing the default axis on all sides:&#xA;    for side in [&#x27;bottom&#x27;,&#x27;right&#x27;,&#x27;top&#x27;,&#x27;left&#x27;]:&#xA;        ax.spines[side].set_visible(False)&#xA;&#xA;    # removing the axis ticks&#xA;    # plt.xticks([]) # labels&#xA;    # plt.yticks([])&#xA;    # ax.xaxis.set_ticks_position(&#x27;none&#x27;) # tick markers&#xA;    # ax.yaxis.set_ticks_position(&#x27;none&#x27;)&#xA;&#xA;    # get width and height of axes object to compute&#xA;    # matching arrowhead length and width&#xA;    dps = fig.dpi_scale_trans.inverted()&#xA;    bbox = ax.get_window_extent().transformed(dps)&#xA;    width, height = bbox.width, bbox.height&#xA;&#xA;    # manual arrowhead width and length&#xA;    hw = 1./20.*(ymax-ymin)&#xA;    hl = 1./20.*(xmax-xmin)&#xA;    lw = 1. # axis line width&#xA;    ohg = 0.3 # arrow overhang&#xA;&#xA;    # compute matching arrowhead length and width&#xA;    yhw = hw/(ymax-ymin)*(xmax-xmin)* height/width&#xA;    yhl = hl/(xmax-xmin)*(ymax-ymin)* width/height&#xA;&#xA;    # draw x and y axis&#xA;    ax.arrow(xmin, 0, xmax-xmin, 0., fc=&#x27;w&#x27;, ec=&#x27;w&#x27;, lw = lw,&#xA;             head_width=hw, head_length=hl, overhang = ohg,&#xA;             length_includes_head= True, clip_on = False)&#xA;&#xA;    ax.arrow(0, ymin, 0., ymax-ymin, fc=&#x27;w&#x27;, ec=&#x27;w&#x27;, lw = lw,&#xA;             head_width=yhw, head_length=yhl, overhang = ohg,&#xA;             length_includes_head= True, clip_on = False)&#xA;&#xA;# Meine easing-Funktion&#xA;def ease(n):&#xA;    if n &lt; 0.0:&#xA;        return 0&#xA;    elif n > 1.0:&#xA;        return 1&#xA;    else:&#xA;        return 3*n**2-2*n**3&#xA;&#xA;# Meine Floor/Warte Funktion&#xA;def wait(n):&#xA;    if n &lt; 0.0:&#xA;        return 0&#xA;    else:&#xA;        return n&#xA;&#xA;# Canvas erstellen&#xA;fig = plt.figure()&#xA;ax = fig.add_subplot(111)&#xA;fig.set_size_inches([8,9])&#xA;&#xA;def f(x):&#xA;    return -0.05*x**2&#x2B;125&#xA;xlin = np.linspace(0,60,100)&#xA;&#xA;&#xA;# Beschriftung und Optik&#xA;&#xA;plt.xlabel(r"$x$ in $\rm{m}$", horizontalalignment=&#x27;right&#x27;, x=1.0)&#xA;plt.ylabel(r"$y$ in $\rm{m}$", horizontalalignment=&#x27;right&#x27;, y=1.0)&#xA;ax.set_xlim(0,100)&#xA;ax.set_ylim(0,139)&#xA;plt.grid(alpha=.4)&#xA;plt.xticks(np.arange(0, 100, 20))&#xA;plt.yticks(np.arange(0, 140, 20))&#xA;ax.yaxis.set_minor_locator(MultipleLocator(10))&#xA;ax.xaxis.set_minor_locator(MultipleLocator(10))&#xA;ax.tick_params(axis=&#x27;x&#x27;, direction = "inout", length= 10.0, which=&#x27;both&#x27;, width=3)&#xA;ax.tick_params(axis=&#x27;y&#x27;, direction = "inout", length= 10.0, which=&#x27;both&#x27;, width=3)&#xA;&#xA;&#xA;xsub = np.array([0])&#xA;&#xA;# statische Linien definieren&#xA;line2, = ax.plot(xsub,f(xsub),linewidth=5,zorder=0,c = &#x27;b&#x27;)&#xA;arrowed_spines(fig, ax)&#xA;plt.tight_layout()&#xA;&#xA;# Linien animieren&#xA;def animate(i):&#xA;&#xA;    xsub = xlin[0:wait(i-20)]&#xA;    global line2&#xA;    line2.remove()&#xA;    line2, = ax.plot(xsub, f(xsub), linewidth=5, zorder=0,c = "b")&#xA;    plt.tight_layout()&#xA;&#xA;animation = FuncAnimation(fig, animate, np.arange(0, 130, 1), interval=100)&#xA;&#xA;plt.show()&#xA;&#xA;# animation.save(r"YOUR\PATH\HERE\reduced_x-y.mov", codec="png",&#xA;         dpi=100, bitrate=-1,&#xA;         savefig_kwargs={&#x27;transparent&#x27;: True, &#x27;facecolor&#x27;: &#x27;none&#x27;})&#xA;&#xA;

    &#xA;