Recherche avancée

Médias (91)

Autres articles (90)

  • Mise à jour de la version 0.1 vers 0.2

    24 juin 2013, par

    Explications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
    Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)

  • 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 ) (...)

Sur d’autres sites (11591)

  • Writing frames from camera using skvideo.io.FFmpegWriter

    28 juin 2018, par Liam Deacon

    I’m trying to finely control the video encoding of camera image frames captured on the fly using skvideo.io.FFmpegWriter and cv2.VideoCapture, e.g.

    from skvideo import io
    import cv2

    fps = 60
    stream = cv2.VideoCapture(0)                    # 0 is for /dev/video0
    print("fps: {}".format(stream.set(cv2.CAP_PROP_FPS, fps)))

    stream.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
    stream.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)
    print("bit_depth: {}".format(stream.set(cv2.CAP_PROP_FORMAT, cv2.CV_8U)))

    video = io.FFmpegWriter('/tmp/test_ffmpeg.avi',
               inputdict={'-r': fps, '-width': 1920, '-height': 1080},
               outputdict={'-r': fps, '-vcodec': 'libx264', '-pix_fmt': 'h264'}
    )

    try:
       for i in range(fps*10):  # 10s of video
           ret, frame = stream.read()
           video.writeFrame(frame)
    finally:
       stream.release()

    try:
       video.close()
    except:
       pass

    However, I get the following exception (in Jupyter notebook) :

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)

    in <module>()
        18     while range(fps*10):
        19         ret, frame = stream.read()
    ---> 20         video.writeFrame(frame)
        21 except BaseException as err:
        22     raise err

    /usr/local/lib/python3.6/site-packages/skvideo/io/ffmpeg.py in writeFrame(self, im)
       446         T, M, N, C = vid.shape
       447         if not self.warmStarted:
    --> 448             self._warmStart(M, N, C)
       449
       450         # Ensure that ndarray image is in uint8

    /usr/local/lib/python3.6/site-packages/skvideo/io/ffmpeg.py in _warmStart(self, M, N, C)
       412         cmd = [_FFMPEG_PATH + "/" + _FFMPEG_APPLICATION, "-y"] + iargs + ["-i", "-"] + oargs + [self._filename]
       413
    --> 414         self._cmd = " ".join(cmd)
       415
       416         # Launch process

    TypeError: sequence item 3: expected str instance, int found
    </module>

    Changing this to video.writeFrame(frame.tostring()) results in ValueError: Improper data input, leaving me stumped.

    How should I go about writing each frame (as returned by OpenCV) to my FFmpegWriter instance ?

    EDIT

    The code works fine if I remove inputdict and outputdict from the io.FFmpegWriter call, however this defeats the purpose for me as I need fine control over the video encoding (I am experimenting with lossless/near-lossless compression of the raw video captured from the camera and trying to establish the best compromise in terms of compression vs fidelity for my needs).

  • Normalizing audio of several wav snippets with ffmpeg

    17 mai 2023, par dick_kickem

    I searched the site and I figured that maybe ffmpeg-normalize could be part of my solution but I'm really not sure.

    &#xA;

    In my free time me and my friends create quizzes for people to solve. One of these is a music quiz, where you hear audio snippets and have to guess the artist and song title. A few years back I did most of them using Audacity, which means recording snippets from existing videos, inserting fade in and fade out to every snippet, putting announcements like "Number x" before the x-th song and also making sure that all songs are fairly of equal loudeness (-6.0 dB).

    &#xA;

    The result in Audacity looked like this.

    &#xA;

    enter image description here

    &#xA;

    Lazy as I am, I learned about ffmpeg and wrote a script, which does all these steps for me. The script is mostly written in bash. I use some audio files where I extract the audio in wav-format, add a fade in and fade out and then I try to set the volume to -6.0 dB as with Audacity. The part where this happens looks like this :

    &#xA;

    ...[some code before]...&#xA;&#xA;# write the audio details of temmp.wav into the "info" file&#xA;ffmpeg -i temp.wav -filter:a volumedetect -f null - 2> info&#xA;&#xA;#check out the max volume of temp.wav&#xA;max_vol=$(grep "max_volume" info | cut -d &#x27; &#x27; -f5)&#xA;&#xA;# determine the difference between the max volume and -6&#xA;vol_diff=$(expr "-6-($max_vol)" | bc -l)&#xA;&#xA;# change temp.wav loudness by the determined difference&#xA;ffmpeg -y -i temp.wav -filter:a "volume=$vol_diff$db" $count.wav&#xA;&#xA;...[some code after]...&#xA;

    &#xA;

    I do this with all snippets, leaving me with usually ten snippets in the format 1.wav, 2.wav and so on. Lastly, I concatenate them all with announcements in the form nr1.wav, 1.wav, nr2.wav, 2.wav and so on. Overall this works really great for me. Yet, the loudness is not quite as equal as in Audacity. Here is a screenshot of a generated music quiz using the described script (not the same music snippets as the example before) :

    &#xA;

    enter image description here

    &#xA;

    You can see some peaks pointing out. It's not bad and in fact, it works for me in most cases, but it's not like what I used to have with Audacity. Does anyone have any idea how to fix that to make it more equal ?

    &#xA;

    Thank you in advance and kind regards

    &#xA;

  • Video merge using ffmpeg issue

    29 mars 2020, par Getwrong

    pretty basic node script im using to merge 2 mp4 files together, currently have an error :

    Error ffmpeg exited with code 1 : Error reinitializing filters !
    Failed to inject frame into filter network : Invalid argument
    Error while processing the decoded data for stream #1:0
    Conversion failed !

    if i merge 2 of the same video together it works but when i use 2 different videos it throws that error !. i used the first code snippet to change the size and aspect ration but still no luck ! I have spent hours on end search for this fix. how on earth do you merge 2 different videos together.

    i’ve seen people comment that :
    1. sizing is different
    2. aspect is out of whack
    3. you can use Unsafe = 1 ????
    4. maybe different frame rate on the files ?

    any help would be awesome ! cheers !

    var fluent_ffmpeg = require("fluent-ffmpeg");
    var fs = require('fs');
    var ffmpeg = require('fluent-ffmpeg');


    //ATTEMPT TO RESIZE VIDEO FILES
    //-------------------------------------------------------
    var command = ffmpeg();
    var command2 = ffmpeg();

    var command = ffmpeg('./save/pokemon/name0.mp4')
     .videoCodec('libx264')
     .format('mp4');

    var command2 = ffmpeg('./save/pokemon/name1.mp4')
     .videoCodec('libx264')
     .format('mp4');

    command.clone()
     .size('640x?').aspect('4:3').autopad()
     .save('./save/name0.mp4')

    command2.clone()
     .size('640x?').aspect('4:3').autopad()
     .save('./save/name1.mp4');
    //-------------------------------------------------------
    //MERGE VIDEOS TOGETHER
    //-------------------------------------------------------
    async function test()
    {
       var mergedVideo = fluent_ffmpeg();

       var videoNames  = ['./save/name0.mp4','./save/name1.mp4']

       videoNames.forEach(function(videoName)
       {
           mergedVideo = mergedVideo.addInput(videoName);
       });

       mergedVideo.mergeToFile('./save/mergedVideo.avi', './tmp/').on('error', function(err)
       {
           console.log('Error ' + err.message);

       }).on('end', function()
       {
           console.log('Finished!');
       });
    }
    //-------------------------------------------------------
    C:\gif>ffmpeg -i ./save/pokemon/name0.mp4 -i ./save/pokemon/name1.mp4
    ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
     built with gcc 9.2.1 (GCC) 20200122
     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-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-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
     libavutil      56. 31.100 / 56. 31.100
     libavcodec     58. 54.100 / 58. 54.100
     libavformat    58. 29.100 / 58. 29.100
     libavdevice    58.  8.100 / 58.  8.100
     libavfilter     7. 57.100 /  7. 57.100
     libswscale      5.  5.100 /  5.  5.100
     libswresample   3.  5.100 /  3.  5.100
     libpostproc    55.  5.100 / 55.  5.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from './save/pokemon/name0.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf58.26.101
     Duration: 00:00:01.14, start: 0.000000, bitrate: 1104 kb/s
       Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x334 [SAR 1:1 DAR 240:167], 1098 kb/s, 33.33 fps, 33.33 tbr, 333333 tbn, 66.67 tbc (default)
       Metadata:
         handler_name    : VideoHandler
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from './save/pokemon/name1.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf58.26.101
       comment         : PhotoScape
     Duration: 00:00:01.80, start: 0.000000, bitrate: 1157 kb/s
       Stream #1:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x358 [SAR 1:1 DAR 240:179], 1153 kb/s, 6.67 fps, 6.67 tbr, 666667 tbn, 13.33 tbc (default)
       Metadata:
         handler_name    : VideoHandler
    At least one output file must be specified