Recherche avancée

Médias (91)

Autres articles (89)

  • Des sites réalisés avec MediaSPIP

    2 mai 2011, par

    Cette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
    Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page.

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

Sur d’autres sites (6165)

  • Duplicated frames when mering multiple videos with xfade filter (ffmpeg)

    25 février 2021, par tjk

    I'm stuck with merging multiple videos with audio. This used to work on most videos I merged before but with some videos, I get the "More than 1000 frames duplicated" warning, and the output video is broken (some videos won't play, just static picture and the sound is misaligned).

    


    All videos are in the same format afaik. The only difference I see is that some are "yuvj420p(pc)" and most are "yuv420p". But I tried merging without those with "yuvj420p(pc)" and it didn't help.

    


    Already tried adding "-vsync vfr", didn't help too.
Interestingly — if I remove the second or the last input video, no warning is given and it all works.

    


    The command I use :

    


    ffmpeg  -i intro.mp4 \
     -i 2043651222.mp4 \
     -i 2668231460.mp4 \
     -i 2342967217.mp4 \
     -i 2345792509.mp4 \
     -i 2764881879.mp4 \
     -i 3127825310.mp4 \
     -i 3058954129.mp4 \
     -i 2533841315.mp4 \
     -i 2334544474.mp4 \
     -i 2493440007.mp4 \
     -filter_complex \
"[0][1]xfade=transition=fade:duration=0.5:offset=3.5000000[V01]; \
[V01][2]xfade=transition=fade:duration=0.5:offset=7.67000[V02]; \
[V02][3]xfade=transition=fade:duration=0.5:offset=27.21000[V03]; \
[V03][4]xfade=transition=fade:duration=0.5:offset=37.01000[V04]; \
[V04][5]xfade=transition=fade:duration=0.5:offset=54.11000[V05]; \
[V05][6]xfade=transition=fade:duration=0.5:offset=56.63000[V06]; \
[V06][7]xfade=transition=fade:duration=0.5:offset=80.49000[V07]; \
[V07][8]xfade=transition=fade:duration=0.5:offset=107.23000[V08]; \
[V08][9]xfade=transition=fade:duration=0.5:offset=110.12000[V09]; \
[V09][10]xfade=transition=fade:duration=0.5:offset=118.31000,format=yuv420p[video]; \
[0:a]aresample=async=1:first_pts=0,apad,atrim=0:4[A0]; \
[1:a]aresample=async=1:first_pts=0,apad,atrim=0:4.67[A1]; \
[2:a]aresample=async=1:first_pts=0,apad,atrim=0:20.04[A2]; \
[3:a]aresample=async=1:first_pts=0,apad,atrim=0:10.3[A3]; \
[4:a]aresample=async=1:first_pts=0,apad,atrim=0:17.6[A4]; \
[5:a]aresample=async=1:first_pts=0,apad,atrim=0:3.02[A5]; \
[6:a]aresample=async=1:first_pts=0,apad,atrim=0:24.36[A6]; \
[7:a]aresample=async=1:first_pts=0,apad,atrim=0:27.24[A7]; \
[8:a]aresample=async=1:first_pts=0,apad,atrim=0:3.39[A8]; \
[9:a]aresample=async=1:first_pts=0,apad,atrim=0:8.69[A9]; \
[10:a]aresample=async=1:first_pts=0,apad,atrim=0:14.88[A10]; \
[A0][A1]acrossfade=d=0.5:c1=tri:c2=tri[A0001]; \
[A0001][A2]acrossfade=d=0.5:c1=tri:c2=tri[A0002]; \
[A0002][A3]acrossfade=d=0.5:c1=tri:c2=tri[A0003]; \
[A0003][A4]acrossfade=d=0.5:c1=tri:c2=tri[A0004]; \
[A0004][A5]acrossfade=d=0.5:c1=tri:c2=tri[A0005]; \
[A0005][A6]acrossfade=d=0.5:c1=tri:c2=tri[A0006]; \
[A0006][A7]acrossfade=d=0.5:c1=tri:c2=tri[A0007]; \
[A0007][A8]acrossfade=d=0.5:c1=tri:c2=tri[A0008]; \
[A0008][A9]acrossfade=d=0.5:c1=tri:c2=tri[A0009]; \
[A0009][A10]acrossfade=d=0.5:c1=tri:c2=tri[audio] \
" -map "[video]" -map "[audio]" -movflags +faststart 'compiled.mp4'


    


    Full log :

    


    ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 11.0.3 (clang-1103.0.32.62)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --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-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:04.00, start: 0.000000, bitrate: 98 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 2 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 85 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2043651222.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:04.67, start: 0.000000, bitrate: 471 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 720x1280 [SAR 1:1 DAR 9:16], 333 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from '2668231460.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:20.04, start: 0.000000, bitrate: 1882 kb/s
    Stream #2:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 1685 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 191 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #3, mov,mp4,m4a,3gp,3g2,mj2, from '2342967217.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:10.30, start: 0.000000, bitrate: 446 kb/s
    Stream #3:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 367 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #3:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #4, mov,mp4,m4a,3gp,3g2,mj2, from '2345792509.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:17.60, start: 0.000000, bitrate: 2546 kb/s
    Stream #4:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 2342 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #4:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 199 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #5, mov,mp4,m4a,3gp,3g2,mj2, from '2764881879.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:03.02, start: 0.000000, bitrate: 1293 kb/s
    Stream #5:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 1110 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #5:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 178 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #6, mov,mp4,m4a,3gp,3g2,mj2, from '3127825310.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:24.36, start: 0.000000, bitrate: 401 kb/s
    Stream #6:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280 [SAR 1:1 DAR 9:16], 323 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #6:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #7, mov,mp4,m4a,3gp,3g2,mj2, from '3058954129.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:27.24, start: 0.000000, bitrate: 1723 kb/s
    Stream #7:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 1519 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #7:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 194 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #8, mov,mp4,m4a,3gp,3g2,mj2, from '2533841315.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:03.39, start: 0.000000, bitrate: 1807 kb/s
    Stream #8:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 1657 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #8:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 150 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #9, mov,mp4,m4a,3gp,3g2,mj2, from '2334544474.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:08.69, start: 0.000000, bitrate: 2675 kb/s
    Stream #9:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 720x1280, 2500 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #9:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 180 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
Input #10, mov,mp4,m4a,3gp,3g2,mj2, from '2493440007.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:00:14.88, start: 0.000000, bitrate: 966 kb/s
    Stream #10:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x1280, 889 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
    Stream #10:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
File 'compiled.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 (aac) -> aresample
  Stream #0:1 (h264) -> xfade:main
  Stream #1:0 (h264) -> xfade:xfade
  Stream #1:1 (aac) -> aresample
  Stream #2:0 (h264) -> xfade:xfade
  Stream #2:1 (aac) -> aresample
  Stream #3:0 (h264) -> xfade:xfade
  Stream #3:1 (aac) -> aresample
  Stream #4:0 (h264) -> xfade:xfade
  Stream #4:1 (aac) -> aresample
  Stream #5:0 (h264) -> xfade:xfade
  Stream #5:1 (aac) -> aresample
  Stream #6:0 (h264) -> xfade:xfade
  Stream #6:1 (aac) -> aresample
  Stream #7:0 (h264) -> xfade:xfade
  Stream #7:1 (aac) -> aresample
  Stream #8:0 (h264) -> xfade:xfade
  Stream #8:1 (aac) -> aresample
  Stream #9:0 (h264) -> xfade:xfade
  Stream #9:1 (aac) -> aresample
  Stream #10:0 (h264) -> xfade:xfade
  Stream #10:1 (aac) -> aresample
  format -> Stream #0:0 (libx264)
  acrossfade -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[swscaler @ 0x7ff21ef72000] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7ff227827800] using SAR=1/1
[libx264 @ 0x7ff227827800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7ff227827800] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x7ff227827800] 264 - core 160 r3011M cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'compiled.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 720x1280 [SAR 1:1 DAR 9:16], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.91.100 aac
More than 1000 frames duplicated    1024kB time=00:00:47.41 bitrate= 176.9kbits/s dup=597 drop=996 speed=5.81x    
[mp4 @ 0x7ff227815200] Starting second pass: moving the moov atom to the beginning of the filep=1954 speed=4.07x    
frame= 3989 fps=121 q=-1.0 Lsize=   13252kB time=00:02:12.98 bitrate= 816.3kbits/s dup=1946 drop=1954 speed=4.05x    
video:11094kB audio:2036kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.927680%
[libx264 @ 0x7ff227827800] frame I:23    Avg QP:14.09  size: 69236
[libx264 @ 0x7ff227827800] frame P:1195  Avg QP:18.60  size:  6527
[libx264 @ 0x7ff227827800] frame B:2771  Avg QP:21.69  size:   710
[libx264 @ 0x7ff227827800] consecutive B-frames:  3.3% 11.5%  2.6% 82.6%
[libx264 @ 0x7ff227827800] mb I  I16..4: 36.4% 41.9% 21.7%
[libx264 @ 0x7ff227827800] mb P  I16..4:  3.1%  6.0%  1.1%  P16..4: 15.4%  5.5%  2.9%  0.0%  0.0%    skip:66.0%
[libx264 @ 0x7ff227827800] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8: 10.2%  0.6%  0.0%  direct: 0.4%  skip:88.5%  L0:42.8% L1:53.3% BI: 3.8%
[libx264 @ 0x7ff227827800] 8x8 transform intra:55.8% inter:63.6%
[libx264 @ 0x7ff227827800] coded y,uvDC,uvAC intra: 25.6% 42.8% 14.5% inter: 2.7% 2.5% 0.0%
[libx264 @ 0x7ff227827800] i16 v,h,dc,p: 45% 22% 14% 19%
[libx264 @ 0x7ff227827800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 19% 28%  3%  2%  3%  2%  3%  2%
[libx264 @ 0x7ff227827800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 17% 15%  6%  7%  8%  5%  6%  4%
[libx264 @ 0x7ff227827800] i8c dc,h,v,p: 55% 15% 23%  7%
[libx264 @ 0x7ff227827800] Weighted P-Frames: Y:2.0% UV:1.7%
[libx264 @ 0x7ff227827800] ref P L0: 68.4% 13.3% 14.4%  3.9%  0.1%
[libx264 @ 0x7ff227827800] ref B L0: 86.0% 12.0%  2.1%
[libx264 @ 0x7ff227827800] ref B L1: 96.9%  3.1%
[libx264 @ 0x7ff227827800] kb/s:683.43
[aac @ 0x7ff22781fc00] Qavg: 2168.180


    


  • I received connection refused error while trying to stream live video through RTMP with FFMPEG

    25 septembre 2020, par Femzy

    I am working on a nodeJs app that can send camera stream to third party plartform i.e Facebook and Youtube using the RTMP protoco ;.. It works well on my localhost but once i deploy to the server, it only give me errors. The error I get is below on this content..
Here is my codes

    


    server.js

    


    

    

    const child_process = require('child_process'); // To be used later for running FFmpeg
const express = require('express');
const http = require('http');
const WebSocketServer = require('ws').Server;

const app = express();
const server = http.createServer(app).listen(4000, () => {
  console.log('Listening...');
});

// Serve static files out of the www directory, where we will put our HTML page
app.use(express.static(__dirname + '/www'));


const wss = new WebSocketServer({
  server: server
});
wss.on('connection', (ws, req) => {
  
  
  
  const rtmpUrl = 'rtmp://a.rtmp.youtube.com/live2/MyStreamId';
  console.log('Target RTMP URL:', rtmpUrl);
  
  // Launch FFmpeg to handle all appropriate transcoding, muxing, and RTMP.
  // If 'ffmpeg' isn't in your path, specify the full path to the ffmpeg binary.
  const ffmpeg = child_process.spawn('ffmpeg', [
    // Facebook requires an audio track, so we create a silent one here.
    // Remove this line, as well as `-shortest`, if you send audio from the browser.
    //'-f', 'lavfi', '-i', 'anullsrc',
    
    // FFmpeg will read input video from STDIN
    '-i', '-',
    
    // Because we're using a generated audio source which never ends,
    // specify that we'll stop at end of other input.  Remove this line if you
    // send audio from the browser.
    //'-shortest',
    
    // If we're encoding H.264 in-browser, we can set the video codec to 'copy'
    // so that we don't waste any CPU and quality with unnecessary transcoding.
    // If the browser doesn't support H.264, set the video codec to 'libx264'
    // or similar to transcode it to H.264 here on the server.
    '-vcodec', 'copy',
    
    // AAC audio is required for Facebook Live.  No browser currently supports
    // encoding AAC, so we must transcode the audio to AAC here on the server.
    '-acodec', 'aac',
    
    // FLV is the container format used in conjunction with RTMP
    '-f', 'flv',
    
    // The output RTMP URL.
    // For debugging, you could set this to a filename like 'test.flv', and play
    // the resulting file with VLC.  Please also read the security considerations
    // later on in this tutorial.
    rtmpUrl 
  ]);
  
  // If FFmpeg stops for any reason, close the WebSocket connection.
  ffmpeg.on('close', (code, signal) => {
    console.log('FFmpeg child process closed, code ' + code + ', signal ' + signal);
    ws.terminate();
  });
  
  // Handle STDIN pipe errors by logging to the console.
  // These errors most commonly occur when FFmpeg closes and there is still
  // data to write.  If left unhandled, the server will crash.
  ffmpeg.stdin.on('error', (e) => {
    console.log('FFmpeg STDIN Error', e);
  });
  
  // FFmpeg outputs all of its messages to STDERR.  Let's log them to the console.
  ffmpeg.stderr.on('data', (data) => {
    console.log('FFmpeg STDERR:', data.toString());
  });

  // When data comes in from the WebSocket, write it to FFmpeg's STDIN.
  ws.on('message', (msg) => {
    console.log('DATA', msg);
    ffmpeg.stdin.write(msg);
  });
  
  // If the client disconnects, stop FFmpeg.
  ws.on('close', (e) => {
    ffmpeg.kill('SIGINT');
  });
  
});

    


    


    



    On the server.js file i create a websocket to receive stream data from the client side and then use FFMPEG to send the stream data over to youtube via the RTMP url

    


    Here is my client.js code

    


    

    

    const ws = new WebSocket(
             'wss://my-websocket-server.com'

        );
         ws.addEventListener('open', (e) => {
             console.log('WebSocket Open', e);
             drawVideosToCanvas();
             mediaStream = getMixedVideoStream(); // 30 FPS
             mediaRecorder = new MediaRecorder(mediaStream, {
               mimeType: 'video/webm;codecs=h264',
               //videoBitsPerSecond : 3000000000
               bitsPerSecond: 6000000
             });

             mediaRecorder.addEventListener('dataavailable', (e) => {
               ws.send(e.data);
             });
             mediaRecorder.onstop = function() {
              ws.close.bind(ws);
              isRecording = false;
              actionBtn.textContent = 'Start Streaming';
              actionBtn.onclick = startRecording;
             }
             mediaRecorder.onstart = function() {
              isRecording = true;
              actionBtn.textContent = 'Stop Streaming';
              actionBtn.onclick = stopRecording;
              screenShareBtn.onclick = startSharing;
              screenShareBtn.disabled = false;
             }
             //mediaRecorder.addEventListener('stop', ws.close.bind(ws));

             mediaRecorder.start(1000); // Start recording, and dump data every second

           });

    


    


    



    On my client.js file, i captured users camera and then open the websocket server to send the data to the server.. Every thing works fine on local host expect for when i deploy it to live server..
i am wondering if there is a bad configuration on the server.. The server is Centos 7.8 and the app was runing on Apache software
Here is how i configured the virtual host for the websocket domain

    


    

    

    ServerName my-websocket.com

  RewriteEngine on
  RewriteCond %{HTTP:Upgrade} websocket [NC]
  RewriteCond %{HTTP:Connection} upgrade [NC]
  RewriteRule .* "ws://127.0.0.1:3000/$1" [P,L]

  ProxyPass "/" "http://127.0.0.1:3000/$1"
  ProxyPassReverse "/" "http://127.0.0.1:3000/$1"
  ProxyRequests off

    


    


    



    I don't know much about server configuration but i just thought may be the configuration has to do with why FFMPEg can not open connection to RTMP protocol on the server.

    


    here is the error am getting

    


    

    

    FFmpeg STDERR: Input #0, lavfi, from &#x27;anullsrc&#x27;:&#xA;  Duration:&#xA;FFmpeg STDERR: N/A, start: 0.000000, bitrate: 705 kb/s&#xA;    Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s&#xA;&#xA;DATA <buffer 1a="1a">&#xA;DATA <buffer 45="45" df="df" a3="a3" 42="42" 86="86" 81="81" 01="01" f7="f7" f2="f2" 04="04" f3="f3" 08="08" 82="82" 88="88" 6d="6d" 61="61" 74="74" 72="72" 6f="6f" 73="73" 6b="6b" 87="87" 0442="0442" 85="85" 02="02" 18="18" 53="53" 80="80" 67="67" ff="ff" 53991="53991" more="more" bytes="bytes">&#xA;DATA <buffer 40="40" c1="c1" 81="81" 00="00" f0="f0" 80="80" 7b="7b" 83="83" 3e="3e" 3b="3b" 07="07" d6="d6" 4e="4e" 1c="1c" 11="11" b4="b4" 7f="7f" cb="cb" 5e="5e" 68="68" 9b="9b" d5="d5" 2a="2a" e3="e3" 06="06" c6="c6" f3="f3" 94="94" ff="ff" 29="29" 16="16" b2="b2" 60="60" 04ac="04ac" 37="37" fb="fb" 1a="1a" 15="15" ea="ea" 39="39" a0="a0" cd="cd" 02="02" b8="b8" 56206="56206" more="more" bytes="bytes">&#xA;FFmpeg STDERR: Input #1, matroska,webm, from &#x27;pipe:&#x27;:&#xA;  Metadata:&#xA;    encoder         :&#xA;FFmpeg STDERR: Chrome&#xA;  Duration: N/A, start: 0.000000, bitrate: N/A&#xA;    Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)&#xA;    Stream #1:1(eng): Video: h264 (Constrained Baseline), yuv420p(progressive), 1366x768, SAR 1:1 DAR 683:384, 30.30 fps, 30 tbr, 1k tbn, 60 tbc (default)&#xA;&#xA;FFmpeg STDERR: [tcp @ 0xe5fac0] Connection to tcp://a.rtmp.youtube.com:1935 failed (Connection refused), trying next address&#xA;[rtmp @ 0xe0fb80] Cannot open connection tcp://a.rtmp.youtube.com:1935&#xA;&#xA;FFmpeg STDERR: rtmp://a.rtmp.youtube.com/live2/mystreamid: Network is unreachable&#xA;&#xA;FFmpeg child process closed, code 1, signal null</buffer></buffer></buffer>

    &#xD;&#xA;

    &#xD;&#xA;

    &#xD;&#xA;&#xA;

    I will really appreciate if I could get some insight on what may be causing this issue or what i can do to solve it..Thanks in advance..

    &#xA;

  • Is there a way to batch split a file by chapter with ffmpeg and then reassemble with mkvmerge in windows ?

    8 novembre 2020, par Sipherdrakon

    So I made a batch script originally with the ability to relatively precision trim a video into chapters without having to run by keyframes, but the code looks horrible and I can't get it to loop through all mp4 files nor get mkvmerge to append the files after splitting them. Code is below but be gentle it is my first try.

    &#xA;

    @echo off&#xA;setlocal enableDelayedExpansion&#xA;&#xA;REM CODE BELOW CREATES JSON FILES FOR ALL MP4 FILES WITHIN THE SAME DIRECTORY&#xA;ffprobe -v quiet -print_format json -show_chapters -loglevel error "01x01.mp4" > "01x01.json"&#xA;&#xA;REM CODE BELOW SETS VARIABLES FROM EACH SPECIFIC JSON&#xA;FOR /F "delims=" %%i in (&#x27;jq .chapters[2].start ^&lt; 01x01.json&#x27;) DO SET /A start1=%%i&#xA;FOR /F "delims=" %%j in (&#x27;jq .chapters[2].end ^&lt; 01x01.json&#x27;) DO SET /A end1=%%j&#xA;&#xA;FOR /F "delims=" %%k in (&#x27;jq .chapters[4].start ^&lt; 01x01.json&#x27;) DO SET /A start2=%%k&#xA;FOR /F "delims=" %%l in (&#x27;jq .chapters[4].end ^&lt; 01x01.json&#x27;) DO SET /A end2=%%l&#xA;&#xA;FOR /F "delims=" %%m in (&#x27;jq .chapters[6].start ^&lt; 01x01.json&#x27;) DO SET /A start3=%%m&#xA;FOR /F "delims=" %%n in (&#x27;jq .chapters[6].end ^&lt; 01x01.json&#x27;) DO SET /A end3=%%n&#xA;&#xA;FOR /F "delims=" %%o in (&#x27;jq .chapters[8].start ^&lt; 01x01.json&#x27;) DO SET /A start4=%%o&#xA;FOR /F "delims=" %%p in (&#x27;jq .chapters[8].end ^&lt; 01x01.json&#x27;) DO SET /A end4=%%p&#xA;&#xA;REM SETS THE DURATION OF EACH FILE TO USE PRECISION TIMING FOR START AND STOP TIMES&#xA;CALL vbs (%end1%-%start1%)/1000&#xA;SET duration1=%val%&#xA;CALL vbs (%end2%-%start2%)/1000&#xA;SET duration2=%val%&#xA;CALL vbs (%end3%-%start3%)/1000&#xA;SET duration3=%val%&#xA;CALL vbs (%end4%-%start4%)/1000&#xA;SET duration4=%val%&#xA;&#xA;REM SETS THE START TIME IN SECONDS VS MILLISECONDS&#xA;CALL vbs (%start1%)/1000&#xA;SET start1=%val%&#xA;CALL vbs (%start2%)/1000&#xA;SET start2=%val%&#xA;CALL vbs (%start3%)/1000&#xA;SET start3=%val%&#xA;CALL vbs (%start4%)/1000&#xA;SET start4=%val%&#xA;&#xA;REM TRIM AND SPLIT ORIGINAL FILE INTO SEPERATE SECTIONS BASED ON CHAPTER MARKERS&#xA;ffmpeg -ss %START1% -i 01x01.mp4 -ss 0 -c copy -to %DURATION1% -avoid_negative_ts make_zero 01x01-1.mp4&#xA;ffmpeg -ss %START2% -i 01x01.mp4 -ss 0 -c copy -to %DURATION2% -avoid_negative_ts make_zero 01x01-2.mp4&#xA;ffmpeg -ss %START3% -i 01x01.mp4 -ss 0 -c copy -to %DURATION3% -avoid_negative_ts make_zero 01x01-3.mp4&#xA;ffmpeg -ss %START4% -i 01x01.mp4 -ss 0 -c copy -to %DURATION4% -avoid_negative_ts make_zero 01x01-4.mp4&#xA;&#xA;REM DELETES UNNEEDED JSON AFTER USE&#xA;del /s *.json&#xA;&#xA;REM APPEND ALL MP4 FILES INTO COHESIVE MKV&#xA;for /d /r %%D in (*) do (&#xA;    pushd %%D&#xA;    set files=&#xA;    for %%F in (*.mp4) do set files=!files! &#x2B; ^( "%%F" ^)&#xA;    if not "!files!"=="" %mkvmerge% -o "01x01-FINAL.mkv" !files:~2!&#xA;    popd&#xA;)&#xA;&#xA;REM DELETE UNNEEDED MP4 ORIGINALS AND SPLIT FILES&#xA;del /s *.mp4&#xA;

    &#xA;

    I know it is super long and every time I try to use a variable or a loop to run through all files it can't read the json file. I've been at this all day and I can use the script as is but I have to make a file for each iteration.

    &#xA;

    I was also hoping to be able to have it only pull chapters labeled as "video" but I haven't quite figured that one out yet.

    &#xA;

    I'll add the vbs batch file for the arithmetic section as well as the sample json if it will help.

    &#xA;

    @echo off&#xA;>"%temp%\VBS.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") : Wscript.echo (%*)&#xA;for /f "delims=" %%a in (&#x27;cscript /nologo "%temp%\VBS.vbs"&#x27;) do set "val=%%a"&#xA;del "%temp%\VBS.vbs"&#xA;

    &#xA;

    {&#xA;    "chapters": [&#xA;        {&#xA;            "id": 0,&#xA;            "time_base": "1/1000",&#xA;            "start": 0,&#xA;            "start_time": "0.000000",&#xA;            "end": 5590,&#xA;            "end_time": "5.590000",&#xA;            "tags": {&#xA;                "title": "Video"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 1,&#xA;            "time_base": "1/1000",&#xA;            "start": 5590,&#xA;            "start_time": "5.590000",&#xA;            "end": 13994,&#xA;            "end_time": "13.994000",&#xA;            "tags": {&#xA;                "title": "Advertisement"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 2,&#xA;            "time_base": "1/1000",&#xA;            "start": 13994,&#xA;            "start_time": "13.994000",&#xA;            "end": 163964,&#xA;            "end_time": "163.964000",&#xA;            "tags": {&#xA;                "title": "Video"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 3,&#xA;            "time_base": "1/1000",&#xA;            "start": 163964,&#xA;            "start_time": "163.964000",&#xA;            "end": 195940,&#xA;            "end_time": "195.940000",&#xA;            "tags": {&#xA;                "title": "Advertisement"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 4,&#xA;            "time_base": "1/1000",&#xA;            "start": 195940,&#xA;            "start_time": "195.940000",&#xA;            "end": 547849,&#xA;            "end_time": "547.849000",&#xA;            "tags": {&#xA;                "title": "Video"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 5,&#xA;            "time_base": "1/1000",&#xA;            "start": 547849,&#xA;            "start_time": "547.849000",&#xA;            "end": 595850,&#xA;            "end_time": "595.850000",&#xA;            "tags": {&#xA;                "title": "Advertisement"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 6,&#xA;            "time_base": "1/1000",&#xA;            "start": 595850,&#xA;            "start_time": "595.850000",&#xA;            "end": 1413588,&#xA;            "end_time": "1413.588000",&#xA;            "tags": {&#xA;                "title": "Video"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 7,&#xA;            "time_base": "1/1000",&#xA;            "start": 1413588,&#xA;            "start_time": "1413.588000",&#xA;            "end": 1477569,&#xA;            "end_time": "1477.569000",&#xA;            "tags": {&#xA;                "title": "Advertisement"&#xA;            }&#xA;        },&#xA;        {&#xA;            "id": 8,&#xA;            "time_base": "1/1000",&#xA;            "start": 1477569,&#xA;            "start_time": "1477.569000",&#xA;            "end": 1529696,&#xA;            "end_time": "1529.696000",&#xA;            "tags": {&#xA;                "title": "Video"&#xA;            }&#xA;        }&#xA;    ]&#xA;}&#xA;

    &#xA;

    I also tried using the start_time so I didn't have to do extra calculations but jq didn't like that either.

    &#xA;

    mkvmerge doesn't even try to run when I have it in here and I still need to cut 7 seconds off the end and 12 seconds off the front of it once it is all one file again.

    &#xA;

    Any help would be appreciated, I know it's a lot but I seem to have hit a roadblock or just sleep deprived at this point.

    &#xA;

    UPDATE

    &#xA;

    This works amazing I just need to figure out how to use files with spaces and I'm all set. I guess I could run a batch before hand replacing all spaces with underscores. That would probably work but I would like to not change filenames if I can help it.

    &#xA;

    @echo off&#xA;&#xA;for %%i in (*.mp4) do (&#xA;FOR /F "delims=" %%A IN (&#x27;ffprobe -v quiet -print_format json -show_chapters -loglevel error "%%i" ^| xidel - -se "$json/(chapters)()[id!=0 and tags/title=&#x27;Video&#x27;]/concat(&#x27;ffmpeg -ss &#x27;,start div 1000,&#x27; -i %%i -to &#x27;,((end - start) div 1000),&#x27; -c copy -avoid_negative_ts make_zero %%~ni-&#x27;,position(),&#x27;.mp4&#x27;)"&#x27;) DO %%A&#xA;FOR /F "delims=" %%A IN (&#x27;xidel -s --xquery "concat(&#x27;mkvmerge -o &amp;quot;%%~ni-FINAL.mkv&amp;quot; &amp;quot;&#x27;,join(file:list(.,false(),&#x27;%%~ni-*.mp4&#x27;),&#x27;&amp;quot; &#x2B; &amp;quot;&#x27;),&#x27;&amp;quot;&#x27;)"&#x27;) DO %%A&#xA;)&#xA;

    &#xA;