Recherche avancée

Médias (0)

Mot : - Tags -/médias

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (42)

  • 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

  • Encoding and processing into web-friendly formats

    13 avril 2011, par

    MediaSPIP automatically converts uploaded files to internet-compatible formats.
    Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
    Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
    Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
    All uploaded files are stored online in their original format, so you can (...)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

Sur d’autres sites (8960)

  • FFmpeg stream stops after a certain time

    7 avril 2021, par Anarno

    We have a little Nodejs app, which starts a stream process, with a child_process.spawn. On the client-side, we have an HTML5-canvas element, which records the video data new MediaRecorder(canvas.captureStream(30), config), then this client sends its data to our Nodejs server over a WebSocket connection. We using FFmpeg for video encoding and decoding, then we send the data to our 3-rd party service (MUX), which accepts the stream and broadcasts them. Sadly the process continuously loses its fps, and after in general 1 minute, stops with an interesting error code. (when we save the video result locally instead of streaming via rtmps, it works perfectly.

    


    *The whole system is in docker.

    


    The error :

    


     stderr: [tls @ 0x7f998e7bca40] Error in the pull function.&#xA;Our_app_logs:    | av_interleaved_write_frame(): I/O error    &#xA;Our_app_logs:    | [flv @ 0x7f998eeb1680] Failed to update header with correct duration.&#xA;Our_app_logs:    | [flv @ 0x7f998eeb1680] Failed to update header with correct filesize.&#xA;Our_app_logs:    | Error writing trailer of rtmps://global-live.mux.com/app/94e85197-78a3-f092-3437-03d93aba74e0: I/O error&#xA;Our_app_logs:    |  <buffer 5b="5b" 74="74" 6c="6c" 73="73" 20="20" 40="40" 30="30" 78="78" 37="37" 66="66" 39="39" 38="38" 65="65" 62="62" 63="63" 61="61" 34="34" 5d="5d" 45="45" 72="72" 6f="6f" 69="69" 6e="6e" 68="68" 70="70" 75="75" 2e="2e">&#xA;Our_app_logs:    | stderr: frame= 1478 fps= 25 q=23.0 Lsize=  &#xA;   402kB time=00:01:02.89 bitrate=  52.4kbits/s speed=1.05x&#xA;Our_app_logs:    | video:369kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.034639%&#xA;Our_app_logs:    |  <buffer 66="66" 72="72" 61="61" 6d="6d" 65="65" 3d="3d" 20="20" 31="31" 34="34" 37="37" 38="38" 70="70" 73="73" 32="32" 35="35" 71="71" 33="33" 2e="2e" 30="30" 4c="4c" 69="69" 7a="7a" 6b="6b" 42="42" 74="74">&#xA;Our_app_logs:    | stderr: [tls @ 0x7f998e7bca40]  <buffer 5b="5b" 6c="6c" 73="73" 20="20" 40="40" 30="30" 78="78" 37="37" 66="66" 39="39" 38="38" 65="65" 62="62" 63="63" 61="61" 34="34" 5d="5d">    &#xA;Our_app_logs:    | stderr: The specified session has been invalidated for some reason.&#xA;Our_app_logs:    |  <buffer 54="54" 68="68" 65="65" 20="20" 73="73" 70="70" 63="63" 69="69" 66="66" 64="64" 6f="6f" 6e="6e" 61="61" 62="62" 76="76" 6c="6c" 74="74" 72="72" 6d="6d">&#xA;Our_app_logs:    | stderr:     Last message repeated 1 times  &#xA;Our_app_logs:    |  <buffer 20="20" 4c="4c" 61="61" 73="73" 74="74" 6d="6d" 65="65" 67="67" 72="72" 70="70" 64="64" 31="31" 69="69" 0a="0a">  &#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: frame I:13    Avg QP: 5.39  size:  &#xA;2478&#xA;Our_app_logs:    |  <buffer 66="66" 72="72" 61="61" 6d="6d" 65="65" 20="20" 49="49" 3a="3a" 31="31" 33="33" 41="41" 76="76" 67="67" 51="51" 50="50" 35="35" 2e="2e" 39="39" 73="73" 69="69" 7a="7a" 32="32" 34="34" 37="37" 38="38" 0a="0a">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: frame P:1465  Avg QP:13.51  size:  &#xA; 235&#xA;Our_app_logs:    |  <buffer 66="66" 72="72" 61="61" 6d="6d" 65="65" 20="20" 50="50" 3a="3a" 31="31" 34="34" 36="36" 35="35" 41="41" 76="76" 67="67" 51="51" 33="33" 2e="2e" 73="73" 69="69" 7a="7a" 32="32" 0a="0a">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: mb I  I16..4: 99.2%  0.1%  0.7%    &#xA;Our_app_logs:    |  <buffer 6d="6d" 62="62" 20="20" 49="49" 31="31" 36="36" 2e="2e" 34="34" 3a="3a" 39="39" 32="32" 25="25" 30="30" 37="37" 0a="0a">        &#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: mb P  I16..4:  0.3%  0.0%  0.0%  P16..4:  0.1%  0.0%  0.0%  0.0%  0.0%    skip:99.6%&#xA;Our_app_logs:    |  <buffer 6d="6d" 62="62" 20="20" 50="50" 49="49" 31="31" 36="36" 2e="2e" 34="34" 3a="3a" 30="30" 33="33" 25="25">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: 8x8 transform intra:0.3% inter:17.3%&#xA;Our_app_logs:    |  <buffer 38="38" 78="78" 20="20" 74="74" 72="72" 61="61" 6e="6e" 73="73" 66="66" 6f="6f" 6d="6d" 69="69" 3a="3a" 30="30" 2e="2e" 33="33" 25="25" 65="65" 31="31" 37="37" 0a="0a">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: coded y,uvDC,uvAC intra: 1.4% 6.9% &#xA;4.7% inter: 0.0% 0.0% 0.0%&#xA;Our_app_logs:    |  <buffer 63="63" 6f="6f" 64="64" 65="65" 20="20" 79="79" 2c="2c" 75="75" 76="76" 44="44" 43="43" 41="41" 69="69" 6e="6e" 74="74" 72="72" 61="61" 3a="3a" 31="31" 2e="2e" 34="34" 25="25" 36="36" 39="39" 37="37" 30="30">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: i16 v,h,dc,p: 90%  5%  5%  0%&#xA;Our_app_logs:    |  <buffer 69="69" 31="31" 36="36" 20="20" 76="76" 2c="2c" 68="68" 64="64" 63="63" 70="70" 3a="3a" 39="39" 30="30" 25="25" 35="35" 0a="0a">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% &#xA;18% 51%  6%  0%  0%  0%  0%  3%&#xA;Our_app_logs:    |  <buffer 69="69" 38="38" 20="20" 76="76" 2c="2c" 68="68" 64="64" 63="63" 6c="6c" 72="72" 75="75" 3a="3a" 32="32" 33="33" 25="25" 31="31" 35="35" 36="36" 30="30">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% &#xA;25% 40%  0%  0%  0%  0%  0%  0%&#xA;Our_app_logs:    |  <buffer 69="69" 34="34" 20="20" 76="76" 2c="2c" 68="68" 64="64" 63="63" 6c="6c" 72="72" 75="75" 3a="3a" 33="33" 25="25" 32="32" 35="35" 30="30">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: i8c dc,h,v,p: 86%  7%  6%  0%&#xA;Our_app_logs:    |  <buffer 69="69" 38="38" 63="63" 20="20" 64="64" 2c="2c" 68="68" 76="76" 70="70" 3a="3a" 36="36" 25="25" 37="37" 30="30" 0a="0a">&#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: Weighted P-Frames: Y:0.1% UV:0.1%  &#xA;Our_app_logs:    |  <buffer 57="57" 65="65" 69="69" 67="67" 68="68" 74="74" 64="64" 20="20" 50="50" 2d="2d" 46="46" 72="72" 61="61" 6d="6d" 73="73" 3a="3a" 59="59" 30="30" 2e="2e" 31="31" 25="25" 55="55" 56="56" 0a="0a">  &#xA;Our_app_logs:    | stderr: [libx264 @ 0x7f998e790080]  <buffer 5b="5b" 6c="6c" 69="69" 62="62" 78="78" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 37="37" 66="66" 39="39" 38="38" 65="65" 5d="5d">&#xA;Our_app_logs:    | stderr: kb/s:2041.23&#xA;Our_app_logs:    |  <buffer 6b="6b" 62="62" 2f="2f" 73="73" 3a="3a" 32="32" 30="30" 34="34" 31="31" 2e="2e" 33="33" 0a="0a">&#xA;Our_app_logs:    | stderr: Conversion failed!&#xA;Our_app_logs:    |  <buffer 43="43" 6f="6f" 6e="6e" 76="76" 65="65" 72="72" 73="73" 69="69" 20="20" 66="66" 61="61" 6c="6c" 64="64" 21="21" 0a="0a">&#xA;Our_app_logs:    | close, code: 1, signal: null&#xA;Our_app_logs:    | from react application: 14203&#xA;Our_app_logs:    | Status ok...&#xA;Our_app_logs:    | Data ok...&#xA;Our_app_logs:    | FFmpeg ok...&#xA;Our_app_logs:    | Writeable ok... <buffer c4="c4" 81="81" 0e="0e" 11="11" 00="00" 01="01" 61="61" c7="c7" 80="80" 5b="5b" b6="b6" 72="72" 03="03" bc="bc" b7="b7" de="de" 59="59" 7f="7f" 3c="3c" 27="27" b3="b3" 87="87" b2="b2" e6="e6" 84="84" d0="d0" f0="f0" 02="02" 2d="2d" c0="c0" 08="08" 70="70"> undefined&#xA;Our_app_logs:    | stderr: ffmpeg version 4.2.4 Copyright (c) &#xA;2000-2020 the FFmpeg developers&#xA;Our_app_logs:    |   built with gcc 9.2.0 (Alpine 9.2.0)&#xA;Our_app_logs:    |   configuration: --prefix=/usr --enable-avresample --enable-avfilter --enable-gnutls --enable-gpl --enable-libass --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libxvid --enable-libx264 --enable-libx265 --enable-libtheora --enable-libv4l2 --enable-postproc --enable-pic --enable-pthreads --enable-shared --enable-libxcb --disable-stripping --disable-static --disable-librtmp --enable-vaapi --enable-vdpau --enable-libopus --disable-debug&#xA;Our_app_logs:    |  <buffer 66="66" 6d="6d" 70="70" 65="65" 67="67" 20="20" 76="76" 72="72" 73="73" 69="69" 6f="6f" 6e="6e" 34="34" 2e="2e" 32="32" 43="43" 79="79" 68="68" 74="74" 28="28" 63="63" 29="29" 30="30" 2d="2d" 46="46">&#xA;Our_app_logs:    | stderr:   libavutil      56. 31.100 / 56. 31.100&#xA;Our_app_logs:    |   libavcodec     58. 54.100 / 58. 54.100   &#xA;Our_app_logs:    |   libavformat    58. 29.100 / 58. 29.100&#xA;Our_app_logs:    |   libavdevice    58.  8.100 / 58.  8.100&#xA;Our_app_logs:    |   libavfilter     7. 57.100 /  7. 57.100&#xA;Our_app_logs:    |   libavresample   4.  0.  0 /  4.  0.  0   &#xA;Our_app_logs:    |   libswscale      5.  5.100 /  5.  5.100   &#xA;Our_app_logs:    |   libswresample   3.  5.100 /  3.  5.100   &#xA;Our_app_logs:    |   libpostproc    55.  5.100 / 55.  5.100   &#xA;Our_app_logs:    |  <buffer 20="20" 6c="6c" 69="69" 62="62" 61="61" 76="76" 75="75" 74="74" 35="35" 36="36" 2e="2e" 33="33" 31="31" 30="30" 2f="2f" 0a="0a" 63="63" 6f="6f">&#xA;Our_app_logs:    | stderr: [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    |     Last message repeated 4 times&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    |  <buffer 5b="5b" 68="68" 32="32" 36="36" 34="34" 20="20" 40="40" 30="30" 78="78" 37="37" 66="66" 39="39" 5d="5d" 6e="6e" 6f="6f" 2d="2d" 65="65" 69="69" 73="73" 74="74" 67="67" 50="50" 53="53" 31="31" 72="72">&#xA;Our_app_logs:    | stderr: [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    |     Last message repeated 5 times&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_headerOur_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] decode_slice_header error&#xA;Our_app_logs:    | [h264 @ 0x7f299f44f600] no frame!&#xA;&#xA;</buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer></buffer>

    &#xA;

    The FFmpeg config :

    &#xA;

    const FFMPEG_CONFIG = [&#xA;  &#x27;-i&#x27;,&#xA;  &#x27;-&#x27;,&#xA;&#xA;  // video codec config: low latency, adaptive bitrate&#xA;  //   &#x27;-vcodec&#x27;,&#xA;  //   &#x27;copy&#x27;,&#xA;  &#x27;-c:v&#x27;,&#xA;  &#x27;libx264&#x27;,&#xA;  &#x27;-preset&#x27;,&#xA;  &#x27;veryfast&#x27;,&#xA;  &#x27;-tune&#x27;,&#xA;  &#x27;zerolatency&#x27;,&#xA;&#xA;  // audio codec config: sampling frequency (11025, 22050, 44100), bitrate 64 kbits&#xA;  &#x27;-c:a&#x27;,&#xA;  &#x27;aac&#x27;,&#xA;  &#x27;-ar&#x27;,&#xA;  &#x27;44100&#x27;,&#xA;  &#x27;-b:a&#x27;,&#xA;  &#x27;64k&#x27;,&#xA;&#xA;  //force to overwrite&#xA;  &#x27;-y&#x27;,&#xA;&#xA;  // used for audio sync&#xA;  &#x27;-use_wallclock_as_timestamps&#x27;,&#xA;  &#x27;1&#x27;,&#xA;  &#x27;-async&#x27;,&#xA;  &#x27;1&#x27;,&#xA;&#xA;  //&#x27;-filter_complex&#x27;, &#x27;aresample=44100&#x27;, // resample audio to 44100Hz, needed if input is not 44100&#xA;  //&#x27;-strict&#x27;, &#x27;experimental&#x27;,&#xA;  &#x27;-bufsize&#x27;,&#xA;  &#x27;1000&#x27;,&#xA;  &#x27;-f&#x27;,&#xA;  &#x27;flv&#x27;,&#xA;];&#xA;

    &#xA;

    The process :

    &#xA;

    const process = child_process.spawn(&#x27;ffmpeg&#x27;, [&#xA;      ...FFMPEG_CONFIG,&#xA;      //   &#x27;local.bin&#x27;,&#xA;      url,&#xA;    ]);&#xA; &#xA;    process.stderr.on(&#x27;data&#x27;, data => {&#xA;      console.log(`stderr: ${data}`, data);&#xA;    });&#xA;&#xA;    process.stdin.on(&#x27;error&#x27;, e => {&#xA;      console.log(&#x27;FFmpeg STDIN Error&#x27;, e);&#xA;    });&#xA;&#xA;    process.on(&#x27;error&#x27;, err => console.log(err));&#xA;&#xA;    process.on(&#x27;close&#x27;, (code, signal) => {&#xA;      console.log(`close, code: ${code}, signal: ${signal}`);&#xA;    });&#xA;

    &#xA;

    The writing :

    &#xA;

    if (!Buffer.isBuffer(data)) return;&#xA;if (!process.stdin.writable) return;&#xA;process.stdin.write(data);&#xA;

    &#xA;

  • .mp4 file is not playing in Django template and FireFox or Chrome

    9 février 2021, par Himanshu sharma

    I can save live RTSP video stream in .mp4 but when I run saved .mp4 video in Django template or Firefox or Chrome browser or VLC, video is not playing in ubuntu.&#xA;I think I have a compatible issue problem in .mp4. Furthermore, I want to show and play .mp4 saved file in Django.

    &#xA;

    I have a two IP camera which provides a live RTSP video stream.

    &#xA;

    self.input_stream---> rtsp://admin:Admin123@192.168.1.208/user=admin_password=Admin123_channel=0channel_number_stream=0.sdp&#xA;&#xA;self.input_stream---> rtsp://Admin:@192.168.1.209/user=Admin_password=_channel=0channel_number_stream=0.sdp&#xA;

    &#xA;

    Python 3.8.5 (default, Jul 28 2020, 12:59:40)&#xA;[GCC 9.3.0] on linux,

    &#xA;

    Django==3.1.2

    &#xA;

    I am implementing this code in difference Ubuntu PCs

    &#xA;

    Ubuntu = 18.04 and 20.04

    &#xA;

    opencv-contrib-python==4.4.0.46

    &#xA;

    opencv-python==4.4.0.46

    &#xA;

    ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers&#xA;built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)

    &#xA;

    I had tried different fourcc to save .mp4 but below fourcc work perfectly in Ubuntu.

    &#xA;

    fourcc = cv2.VideoWriter_fourcc(*'mp4v')

    &#xA;

    class ffmpegStratStreaming(threading.Thread):&#xA;    def __init__(self, input_stream=None, output_stream=None, camera=None, *args, **kwargs):&#xA;        self.input_stream = input_stream&#xA;        self.output_stream = output_stream&#xA;        self.camera = camera&#xA;        super().__init__(*args, **kwargs)&#xA;&#xA;    def run(self):&#xA;        try:vs = cv2.VideoCapture(self.input_stream)&#xA;            fps_rate = int(vs.get(cv2.CAP_PROP_FPS))&#xA;            ##############################&#xA;            ##############################  &#xA;            # ~ print(&#x27;fps rate-->&#x27;, fps_rate,&#x27;camera id-->&#x27; ,str(self.camera.id))&#xA;            # ~ vs.set(cv2.CAP_PROP_POS_FRAMES,50)  #Set the frame number to be obtained&#xA;            # ~ print(&#x27;fps rate-->&#x27;, fps_rate,&#x27;camera id-->&#x27; ,str(self.camera.id),&#x27; ####### &#x27;)&#xA;            &#xA;            # initialize the video writer (we&#x27;ll instantiate later if need be)&#xA;            writer = None&#xA;&#xA;            # initialize the frame dimensions (we&#x27;ll set them as soon as we read&#xA;            # the first frame from the video)&#xA;            W = None&#xA;            H = None    &#xA;            # start the frames per second throughput estimator&#xA;            fps = FPS().start()&#xA;&#xA;            #  saving frame in avi video format&#xA;            video_file_count = 0&#xA;            start_time = time.time()&#xA;&#xA;            while True:&#xA;                try:&#xA;                    # grab the next frame and handle if we are reading from either&#xA;                    # VideoCapture or VideoStream&#xA;                    &#xA;                    frame_init = vs.read()&#xA;                    frame = frame_init[1] if self.input_stream else frame_init&#xA;                    &#xA;                    # if frame is can&#x27;t read correctly ret is False&#xA;                    while frame_init[0] == False:&#xA;                        print("Can&#x27;t receive frame. Retrying ...")&#xA;                        vs.release()&#xA;                        vs = cv2.VideoCapture(self.input_stream)                                                                              &#xA;                        frame_init = vs.read()&#xA;                        frame = frame_init[1] if self.input_stream else frame_init&#xA;&#xA;                    # if we are viewing a video and we did not grab a frame then we&#xA;                    # have reached the end of the video&#xA;                    if self.input_stream is not None and frame is None:&#xA;                        break&#xA;&#xA;                    # resize the frame to have a maximum width of 500 pixels (the&#xA;                    # less data we have, the faster we can process it), then convert&#xA;                    # the frame from BGR to RGB for dlib&#xA;                    frame = imutils.resize(frame, width=500)        &#xA;                    &#xA;                    &#xA;                    #&lt;---------------------- Start of  writing a video to disk ------------------------->                   &#xA;                    minute = 1&#xA;                    second  = 60&#xA;                    minite_to_save_video = int(minute) * int(second)&#xA;&#xA;                &#xA;                    # if we are supposed to be writing a video to disk, initialize&#xA;                    if time.time() - start_time >= minite_to_save_video or  video_file_count == 0 :&#xA;                        ## where H = heigth, W = width, C = channel &#xA;                        H, W, C = frame.shape&#xA;                        video_file_count &#x2B;= 1&#xA;                        start_time = time.time()&#xA;                        output_save_directory = self.output_stream&#x2B;str(video_file_count)&#x2B;&#x27;.mp4&#x27;&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*"MJPG")&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;XVID&#x27;)&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;X264&#x27;)&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;MP4V&#x27;)&#xA;&#xA;                        &#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;FMP4&#x27;)&#xA;&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;avc1&#x27;)&#xA;&#xA;&#xA;                        # fourcc = cv2.VideoWriter_fourcc(&#x27;M&#x27;,&#x27;J&#x27;,&#x27;P&#x27;,&#x27;G&#x27;)&#xA;&#xA;                        fourcc = cv2.VideoWriter_fourcc(*&#x27;mp4v&#x27;)&#xA;                        # fourcc = cv2.VideoWriter_fourcc(*&#x27;mp3v&#x27;)&#xA;                        # fourcc = 0x00000021&#xA;                        print(fourcc, type(fourcc),&#x27;ffffffff&#x27;)&#xA;                        # a = int(vs.get(cv2.CAP_PROP_FOURCC))&#xA;                        # print(a,type(a),&#x27;  aaaaaaaa&#x27; )&#xA;&#xA;                        # writer = skvideo.io.FFmpegWriter(output_save_directory, outputdict={&#xA;                        #   &#x27;-vcodec&#x27;: &#x27;libx264&#x27;, &#x27;-b&#x27;: &#x27;300000000&#x27;&#xA;                        # })&#xA;                        &#xA;                        # writer = skvideo.io.FFmpegWriter(self.output_stream, outputdict={&#x27;-r&#x27;: &#x27;120&#x27;, &#x27;-c:v&#x27;: &#x27;libx264&#x27;, &#x27;-crf&#x27;: &#x27;0&#x27;, &#x27;-preset&#x27;: &#x27;ultrafast&#x27;, &#x27;-pix_fmt&#x27;: &#x27;yuv444p&#x27;})&#xA;                        &#xA;                        writer = cv2.VideoWriter(output_save_directory, fourcc ,20.0,( int(W), int(H) ), True)&#xA;                        &#xA;                        &#xA;                        # ~ The cv2.VideoWriter requires five parameters:    &#xA;&#xA;                    # check to see if we should write the frame to disk&#xA;                    if writer is not None:                          &#xA;                        try:&#xA;                            writer.write(frame)&#xA;                        except Exception as e:&#xA;                            print(&#x27;Error in writing video output---> &#x27;, e)&#xA;                            &#xA;                    #&lt;---------------------- end of  writing a video to disk ------------------------->&#xA;&#xA;                    # show the output frame&#xA;                    # cv2.imshow("Frame", frame)&#xA;                    # key = cv2.waitKey(1) &amp; 0xFF&#xA;&#xA;                    # if the `q` key was pressed, break from the loop&#xA;                    # if key == ord("q"):&#xA;                    #   break&#xA;&#xA;                    # increment the total number of frames processed thus far and&#xA;                    # then update the FPS counter&#xA;                    totalFrames &#x2B;= 1&#xA;                    fps.update()&#xA;                except Exception as e:&#xA;                    print(&#x27;Error in main while loop--> &#x27;, e)&#xA;&#xA;            # stop the timer and display FPS information&#xA;            fps.stop()&#xA;&#xA;            # check to see if we need to release the video writer pointer&#xA;            # if writer is not None:&#xA;            #   writer.release()&#xA;&#xA;            # if we are not using a video file, stop the camera video stream&#xA;            # if not self.input_stream:&#xA;            #   vs.stop()&#xA;&#xA;            # otherwise, release the video file pointer&#xA;            # else:&#xA;            #   vs.release()&#xA;&#xA;            # close any open windows&#xA;            # cv2.destroyAllWindows()&#xA;        except Exception as e:&#xA;            print(e, &#x27;333333333333333333333333333&#x27;)&#xA;

    &#xA;

    My Django template code

    &#xA;

    {% block main %}&#xA;<div class="row">&#xA;  {% if folders|length == 0 %}&#xA;    <div class="col-md-12 text-center">&#xA;      <h6 class="card-title">There are no files in this directory.</h6>&#xA;    </div>&#xA;  {% else %}&#xA;    {% for folder in folders %}&#xA;      <div class="col-md-3 text-center">&#xA;          <div class="card-block">&#xA;            <video class="video-js vjs-fluid vjs-default-skin" controls="controls" preload="auto" muted="muted" data-setup="&#x27;{" true="true"></video>&#xA;                <source src="{% get_media_prefix %}camera-feed/video-saved/{{pk}}/{{parent}}/{{folder}}" type="video/mp4">&#xA;            &#xA;            <h6 class="card-title">{{folder}}</h6>&#xA;          </source></div>&#xA;      </div>&#xA;    {% endfor %}&#xA;  {% endif %}&#xA;</div>&#xA;{% endblock %}&#xA;

    &#xA;

    Function in view.py to see saved .mp4 video in Django template. Video is saved at local folder.

    &#xA;

    def CameraVideos(request, pk, folder):&#xA;    dirpath = settings.MEDIA_ROOT &#x2B; &#x27;/camera-feed/video-saved/&#x27; &#x2B; str(pk) &#x2B; &#x27;/&#x27; &#x2B; folder&#xA;    folders = sorted(Path(dirpath).iterdir(), key=os.path.getmtime)&#xA;    data = []&#xA;    for file in folders:&#xA;        if not file.name.startswith(&#x27;.&#x27;):&#xA;            data.append(file.name)&#xA;    return render(request, "home/camera_video.html", {&#x27;folders&#x27;: data, &#x27;pk&#x27;: pk, &#x27;parent&#x27;: folder})&#xA;

    &#xA;

  • FFMPEG Take 1 second clips each video file from a directory of files, and until total playtime reached

    3 février 2021, par Matthew

    I'm working on a music art video project for a song.

    &#xA;

    I have a directory that contains approximately 400 individual videos

    &#xA;

      &#xA;
    • varying lengths (as short as 3 seconds and as long as 31 minutes)
    • &#xA;

    • varying file types (mp4 and webm)
    • &#xA;

    • varying resolutions/framerates/bitrates
    • &#xA;

    &#xA;

    The output video should consist of :

    &#xA;

      &#xA;
    • 1 second chunks of each video
    • &#xA;

    • in round-robin fashion
    • &#xA;

    • until all videos are played fully or the output total video length reaches a certain limit (example, 20 minutes).
    • &#xA;

    • Output video should be 1280×720 at 24fps, with no preference to bitrate.
    • &#xA;

    • Videos that are larger should be scaled down and letterboxed (vertically or horizontally).
    • &#xA;

    • Audio is not important at all. The video can be silent. I can overlay audio separately.
    • &#xA;

    &#xA;

    I do not want to loop short videos. In the example below, you can see that, for top-left-view-take-1.mp4, each 'clip' that's taken is incrementally further into the video. In other words, it shouldn't take the same 1 second clip from the beginning. The goal is to get further in to each individual video as the output video progresses.

    &#xA;

    For example, say my directory contains files such as the following (and, for the example here, we'll say that this is all files in the directory) :

    &#xA;

    overhead-view-take-1.mp4 (3 seconds, for the sake of the question)&#xA;top-right-view-take-1.mp4 (3 seconds, for the sake of the question)&#xA;top-right-view-take-2.mp4 (5 seconds, for the sake of the question)&#xA;outside-kaleidoscope-1.mp4&#xA;yellow-kaleidoscope-1.mp4&#xA;red-kaleidoscope-1.mp4&#xA;brake-lights-slow-1.mp4&#xA;soft-city-lights.webm&#xA;

    &#xA;

    Assume anything that isn't marked with a video duration is at least 5 seconds long.

    &#xA;

    Based on the above files & times, here would be the order and time code of each clip during the first 30 seconds of the output video :

    &#xA;

    Based on each video's total duration, the output video should include 1 second clips from all videos in the directory.

    &#xA;

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

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;&#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    Output time Clip time Clip file
    00:00-00:01 00:00-00:01 overhead-view-take-1.mp4
    00:01-00:02 00:00-00:01 top-right-view-take-1.mp4
    00:02-00:03 00:00-00:01 top-right-view-take-2.mp4
    00:03-00:04 00:00-00:01 outside-kaleidoscope-1.mp4
    00:04-00:05 00:00-00:01 yellow-kaleidoscope-1.mp4
    00:05-00:06 00:00-00:01 red-kaleidoscope-1.mp4
    00:06-00:07 00:00-00:01 brake-lights-slow-1.mp4
    00:07-00:08 00:00-00:01 soft-city-lights.webm
    00:08-00:09 00:01-00:02 overhead-view-take-1.mp4
    00:09-00:10 00:01-00:02 top-right-view-take-1.mp4
    00:10-00:11 00:01-00:02 top-right-view-take-2.mp4
    00:11-00:12 00:01-00:02 outside-kaleidoscope-1.mp4
    00:12-00:13 00:01-00:02 yellow-kaleidoscope-1.mp4
    00:13-00:14 00:01-00:02 red-kaleidoscope-1.mp4
    00:14-00:15 00:01-00:02 brake-lights-slow-1.mp4
    00:15-00:16 00:01-00:02 soft-city-lights.webm
    00:16-00:17 00:02-00:03 overhead-view-take-1.mp4
    00:17-00:18 00:02-00:03 top-right-view-take-1.mp4
    00:18-00:19 00:02-00:03 top-right-view-take-2.mp4
    00:19-00:20 00:02-00:03 outside-kaleidoscope-1.mp4
    00:20-00:21 00:02-00:03 yellow-kaleidoscope-1.mp4
    00:21-00:22 00:02-00:03 red-kaleidoscope-1.mp4
    00:22-00:23 00:02-00:03 brake-lights-slow-1.mp4
    00:23-00:24 00:02-00:03 soft-city-lights.webm

    &#xA;

    &#xA;

    Now, the output video should include 1 second clips only from videos that still have time remaining. The videos that don't have any time remaining, such as overhead-view-take-1.mp4 and top-right-view-take-1.mp4, are not present here.

    &#xA;

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

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;&#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    &#xA;

    Output time Clip time Clip file
    00:24-00:25 00:03-00:04 top-right-view-take-2.mp4
    00:25-00:26 00:03-00:04 outside-kaleidoscope-1.mp4
    00:26-00:27 00:03-00:04 yellow-kaleidoscope-1.mp4
    00:27-00:28 00:03-00:04 red-kaleidoscope-1.mp4
    00:28-00:29 00:03-00:04 brake-lights-slow-1.mp4
    00:29-00:30 00:03-00:04 soft-city-lights.webm

    &#xA;

    &#xA;

    What I've tried

    &#xA;

      &#xA;
    • I've read through the docs and cobbled together some code that produces output, but it only seems to work with images ; I can't get the same thing to work with videos (specifically the incremental chunks).
    • &#xA;

    • I've tried manipulating commands meant to `create a snapshot every x seconds/frames' but I've hit dead ends there.
    • &#xA;

    • I've also started trying to create a text file to run the input from. That's the point where I thought it would make sense to ask here.
    • &#xA;

    &#xA;

    My main issue is picking off incremental chunks of individual videos, and playing those in sequence.

    &#xA;

    Thoughts ?

    &#xA;

    Environment details&#xA;I have access to Win, Mac, and Linux machines. So, that environment isn't as important to me. Here's ffmpeg's output :

    &#xA;

    ffmpeg version 4.3.1-0york0~16.04 Copyright (c) 2000-2020 the FFmpeg developers&#xA;  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609&#xA;  configuration: --prefix=/usr --extra-version=&#x27;0york0~16.04&#x27; --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared&#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;  libavresample   4.  0.  0 /  4.  0.  0&#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;Hyper fast Audio and Video encoder&#xA;

    &#xA;