Recherche avancée

Médias (91)

Autres articles (104)

  • Les autorisations surchargées par les plugins

    27 avril 2010, par

    Mediaspip core
    autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs

  • Personnaliser les catégories

    21 juin 2013, par

    Formulaire de création d’une catégorie
    Pour ceux qui connaissent bien SPIP, une catégorie peut être assimilée à une rubrique.
    Dans le cas d’un document de type catégorie, les champs proposés par défaut sont : Texte
    On peut modifier ce formulaire dans la partie :
    Administration > Configuration des masques de formulaire.
    Dans le cas d’un document de type média, les champs non affichés par défaut sont : Descriptif rapide
    Par ailleurs, c’est dans cette partie configuration qu’on peut indiquer le (...)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

Sur d’autres sites (13366)

  • Reading file stream from Google Cloud Storage to ffmpeg (using fluent-ffmpeg)

    27 juillet 2018, par ekuusi

    I’m trying to run ffmpeg on a NodeJS backend with fluent-ffmpeg, reading input files from Google Cloud Storage. Everything works fine if I download the file first :

    const file = storage
       .bucket('example_bucket')
       .file('examplefile.mp4');

    file.download({destination: 'test.mp4'}, (err) => {

       let command = ffmpeg()
       .input('test.mp4')
       .duration(10)
       .format('mp4');

       command.save('test_out.mp4');

    });

    res.json([{
       message: 'Command sent!'
    }]);

    But if I try to use a readable stream as the input, it fails :

    const file = storage
       .bucket('example_bucket')
       .file('examplefile.mp4');


    var filestream = file.createReadStream()

    let command = ffmpeg()
       .input(filestream)
       .duration(10)
       .format('mp4');


    command.save('test_out.mp4');
    });

    res.json([{
       message: 'Command sent!'
    }]);

    Here is the full output of ffmpeg when trying to do the conversion. It seems to read the details of the file fine but for some reason it fails, saying "Cannot process video : ffmpeg exited with code 1 : pipe:0 : Invalid data found when processing input"

    Spawned Ffmpeg with command: ffmpeg -i pipe:0 -y -t 10 -f mp4 test_out.mp4
    Stderr output: ffmpeg version 4.0.1 Copyright (c) 2000-2018 the FFmpeg developers
    Stderr output:   built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
    Stderr output:   configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-librsvg --enable-libtheora --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-indev=jack --enable-opencl --disable-outdev=xv --enable-audiotoolbox --enable-videotoolbox --enable-sdl2 --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --arch=x86_64 --enable-x86asm --enable-libx265 --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
    Stderr output:   libavutil      56. 14.100 / 56. 14.100
    Stderr output:   libavcodec     58. 18.100 / 58. 18.100
    Stderr output:   libavformat    58. 12.100 / 58. 12.100
    Stderr output:   libavdevice    58.  3.100 / 58.  3.100
    Stderr output:   libavfilter     7. 16.100 /  7. 16.100
    Stderr output:   libavresample   4.  0.  0 /  4.  0.  0
    Stderr output:   libswscale      5.  1.100 /  5.  1.100
    Stderr output:   libswresample   3.  1.100 /  3.  1.100
    Stderr output:   libpostproc    55.  1.100 / 55.  1.100
    Stderr output: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb6db80a200] stream 2, offset 0x30: partial file
    Stderr output: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb6db80a200] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1920x1080, 4647 kb/s): unspecified pixel format
    Stderr output: Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Stderr output: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'pipe:0':
    Stderr output:   Metadata:
    Stderr output:     major_brand     : isom
    Stderr output:     minor_version   : 512
    Stderr output:     compatible_brands: isomiso2avc1mp41
    Stderr output:     encoder         : Lavf58.12.100
    Stderr output:     location-eng    : +60.2121+024.8754/
    Stderr output:     location        : +60.2121+024.8754/
    Stderr output:   Duration: 00:02:23.13, bitrate: N/A
    Stderr output:     Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), none, 1920x1080, 4647 kb/s, SAR 1:1 DAR 16:9, 59.94 fps, 59.94 tbr, 60k tbn, 120k tbc (default)
    Stderr output:     Metadata:
    Stderr output:       handler_name    : VideoHandler
    Stderr output:     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Stderr output:     Metadata:
    Stderr output:       handler_name    : SoundHandler
    Stderr output:     Stream #0:2(eng): Data: none (tmcd / 0x64636D74)
    Stderr output:     Metadata:
    Stderr output:       handler_name    : TimeCodeHandler
    Stderr output: Stream mapping:
    Input is aac (mp4a / 0x6134706D) audio with h264 (avc1 / 0x31637661) video
    Stderr output:   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Stderr output:   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
    Stderr output: [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb6db80a200] stream 0, offset 0x34: partial file
    Stderr output: pipe:0: Invalid data found when processing input
    Stderr output: Cannot determine format of input stream 0:0 after EOF
    Stderr output: Error marking filters as finished
    Stderr output: Conversion failed!
    Stderr output:
    Cannot process video: ffmpeg exited with code 1: pipe:0: Invalid data found when processing input
    Cannot determine format of input stream 0:0 after EOF
    Error marking filters as finished
    Conversion failed!
  • Does PTS have to start at 0 ?

    5 juillet 2018, par stevendesu

    I’ve seen a number of questions regarding video PTS values not starting at zero, or asking how to make them start at zero. I’m aware that using ffmpeg I can do something like ffmpeg -i <video> -vf="setpts=PTS-STARTPTS" <output></output></video> to fix this kind of thing

    However it’s my understanding that PTS values don’t have to start at zero. For instance, if you join a live stream then odds are it has been going on for an hour and the PTS is already somewhere around 3600000+ but your video player faithfully displays everything just fine. Therefore I would expect there to be no problem if I intentionally created a video with a PTS value starting at, say, the current wall clock time.

    I want to send a live stream using ffmpeg, but embed the current time into the stream. This can be used both for latency calculation while the stream is live, and later to determine when the stream was originally aired. From my understanding of PTS, something as simple as this should probably work :

    ffmpeg -i video.flv -vf="setpts=RTCTIME" rtmp://<output>
    </output>

    When I try this, however, ffmpeg outputs the following :

    frame=   93 fps= 20 q=-1.0 Lsize=    9434kB time=535020:39:58.70 bitrate=   0.0kbits/s speed=1.35e+11x

    Note the extremely large value for "time", the bitrate (0.0kbits), and the speed (135000000000x !!!)

    At first I thought the issue might be my timebase, so I tried the following :

    ffmpeg -i video.flv -vf="settb=1/1K,setpts=RTCTIME/1K" rtmp://<output>
    </output>

    This puts everything in terms of milliseconds (1 PTS = 1 ms) but I had the same issue (massive time, zero bitrate, and massive speed)

    Am I misunderstanding something about PTS ? Is it not allowed to start at non-zero values ? Or am I just doing something wrong ?

    Update

    After reviewing @Gyan’s answer, I formatted my command like so :

    ffmpeg -re -i video.flv -vf="settb=1/1K, setpts=(RTCTIME-RTCSTART)/1K" -output_ts_offset $(date +%s.%N) rtmp://<output>
    </output>

    This way the PTS values would match up to "milliseconds since the stream started" and would be offset by the start time of the stream (theoretically making PTS = timestamp on the server)

    This looked like it was encoding better :

    frame=  590 fps=7.2 q=22.0 size=   25330kB time=00:01:21.71 bitrate=2539.5kbits/s dup=0 drop=1350 speed=   1x

    Bitrate was now correct, time was accurate, and speed was not outrageous. The frames per second was still a bit off, though (the source video is 24 fps but it’s reporting 7.2 frames per second)

    When I tried watching the stream from the other end, the video was out of sync with the audio and played at about double normal speed for a while, then the video froze and the audio continued without it

    Furthermore, when I dumped the stream to a file (ffmpeg -i rtmp://<output> dump.mp4</output>) and look at the PTS timestamps with ffprobe (ffprobe -show_entries packet=codec_type,pts dump.mp4 | grep "video" -B 1 -A 2) the timestamps didn’t seem to show server time at all :

    ...
    --
    [PACKET]
    codec_type=video
    pts=131072
    [/PACKET]
    [PACKET]
    codec_type=video
    pts=130048
    [/PACKET]
    --
    [PACKET]
    codec_type=video
    pts=129536
    [/PACKET]
    [PACKET]
    codec_type=video
    pts=130560
    [/PACKET]
    --
    [PACKET]
    codec_type=video
    pts=131584
    [/PACKET]

    Is the problem just an incompatibility with RTMP ?

    Update 2

    I’ve removed the video filter and I’m now encoding like so :

    ffmpeg -re -i video.flv -output_ts_offset $(date +%s.%N) rtmp://<output>
    </output>

    This is encoding correctly :

    frame=  910 fps= 23 q=25.0 size=   12027kB time=00:00:38.97 bitrate=2528.2kbits/s speed=0.981x

    In order to verify that the PTS values are correct, I’m dumping the output to a file like so :

    ffmpeg -i rtmp://<output> -copyts -write_tmcd 0 dump.mp4
    </output>

    I tried saving it as dump.flv (since it’s RTMP) however this threw the error :

    [flv @ 0x5600f24b4620] Audio codec mp3 not compatible with flv

    This is a bit weird since the video isn’t mp3-encoded (it’s speex) - but whatever.

    While dumping this file the following error pops up repeatedly :

    frame=    1 fps=0.0 q=0.0 size=       0kB time=00:00:09.21 bitrate=   0.0kbits/s dup=0 dr
    43090023 frame duplication too large, skipping
    43090027 frame duplication too large, skipping
       Last message repeated 3 times
    43090031 frame duplication too large, skipping
       Last message repeated 3 times
    43090035 frame duplication too large, skipping

    Playing the resulting video in VLC plays an audio stream but displays no video. I then attempt to probe this video with ffprobe to look at the video PTS values :

    ffprobe -show_entries packet=codec_type,pts dump.mp4 | grep "video" -B 1 -A 2

    This returns only a single video frame whose PTS is not large like I would expect :

    [PACKET]
    codec_type=video
    pts=1020
    [/PACKET]

    This has been a surprisingly difficult task

  • HLS : How to detect out of order segments in media playlist ?

    27 juin 2018, par anirudh612

    What would be an efficient way to detect if an http live streaming VOD playlist has segments out of order (and count how many segments are out of order) ? They are ordered correctly based on the #EXT-X-PROGRAM-DATETIME tag but the segment decoding timestamps in some cases are out of order. Currently, the workflow I’m following is :

    1. Convert the HLS stream into an mp4 using ffmpeg :

      ffmpeg -i http://localhost:8080/test/unsorted.m3u8 -c copy -bsf:a aac_adtstoasc test/unsorted.mp4 &> test/unsorted_ffmpeg.log

    2. Inspect the logs and count number of occurrences of "Non-monotonous DTS in output stream" log messages :

      [mp4 @ 0x7fe74f01b000] Non-monotonous DTS in output stream 0:1 ; previous : 12063760, current : 11866128 ; changing to 12063761. This may result in incorrect timestamps in the output file.

      However, this requires downloading and reading all of the ts segments and is an expensive operation. Is there a more efficient way to determine out of order DTS or PTS in chunks using ffmpeg or ffprobe ?