
Recherche avancée
Médias (1)
-
Revolution of Open-source and film making towards open film making
6 octobre 2011, par
Mis à jour : Juillet 2013
Langue : English
Type : Texte
Autres articles (43)
-
Use, discuss, criticize
13 avril 2011, parTalk to people directly involved in MediaSPIP’s development, or to people around you who could use MediaSPIP to share, enhance or develop their creative projects.
The bigger the community, the more MediaSPIP’s potential will be explored and the faster the software will evolve.
A discussion list is available for all exchanges between users. -
Installation en mode ferme
4 février 2011, parLe mode ferme permet d’héberger plusieurs sites de type MediaSPIP en n’installant qu’une seule fois son noyau fonctionnel.
C’est la méthode que nous utilisons sur cette même plateforme.
L’utilisation en mode ferme nécessite de connaïtre un peu le mécanisme de SPIP contrairement à la version standalone qui ne nécessite pas réellement de connaissances spécifique puisque l’espace privé habituel de SPIP n’est plus utilisé.
Dans un premier temps, vous devez avoir installé les mêmes fichiers que l’installation (...) -
MediaSPIP en mode privé (Intranet)
17 septembre 2013, parÀ partir de la version 0.3, un canal de MediaSPIP peut devenir privé, bloqué à toute personne non identifiée grâce au plugin "Intranet/extranet".
Le plugin Intranet/extranet, lorsqu’il est activé, permet de bloquer l’accès au canal à tout visiteur non identifié, l’empêchant d’accéder au contenu en le redirigeant systématiquement vers le formulaire d’identification.
Ce système peut être particulièrement utile pour certaines utilisations comme : Atelier de travail avec des enfants dont le contenu ne doit pas (...)
Sur d’autres sites (6099)
-
FFmpeg stream stops after a certain time
7 avril 2021, par AnarnoWe 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 datanew 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 viartmps
, it works perfectly.

*The whole system is in docker.


The error :


stderr: [tls @ 0x7f998e7bca40] Error in the pull function.
Our_app_logs: | av_interleaved_write_frame(): I/O error 
Our_app_logs: | [flv @ 0x7f998eeb1680] Failed to update header with correct duration.
Our_app_logs: | [flv @ 0x7f998eeb1680] Failed to update header with correct filesize.
Our_app_logs: | Error writing trailer of rtmps://global-live.mux.com/app/94e85197-78a3-f092-3437-03d93aba74e0: I/O error
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">
Our_app_logs: | stderr: frame= 1478 fps= 25 q=23.0 Lsize= 
 402kB time=00:01:02.89 bitrate= 52.4kbits/s speed=1.05x
Our_app_logs: | video:369kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.034639%
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">
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"> 
Our_app_logs: | stderr: The specified session has been invalidated for some reason.
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">
Our_app_logs: | stderr: Last message repeated 1 times 
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"> 
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">
Our_app_logs: | stderr: frame I:13 Avg QP: 5.39 size: 
2478
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">
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">
Our_app_logs: | stderr: frame P:1465 Avg QP:13.51 size: 
 235
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">
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">
Our_app_logs: | stderr: mb I I16..4: 99.2% 0.1% 0.7% 
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"> 
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">
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%
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">
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">
Our_app_logs: | stderr: 8x8 transform intra:0.3% inter:17.3%
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">
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">
Our_app_logs: | stderr: coded y,uvDC,uvAC intra: 1.4% 6.9% 
4.7% inter: 0.0% 0.0% 0.0%
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">
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">
Our_app_logs: | stderr: i16 v,h,dc,p: 90% 5% 5% 0%
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">
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">
Our_app_logs: | stderr: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 
18% 51% 6% 0% 0% 0% 0% 3%
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">
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">
Our_app_logs: | stderr: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 
25% 40% 0% 0% 0% 0% 0% 0%
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">
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">
Our_app_logs: | stderr: i8c dc,h,v,p: 86% 7% 6% 0%
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">
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">
Our_app_logs: | stderr: Weighted P-Frames: Y:0.1% UV:0.1% 
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"> 
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">
Our_app_logs: | stderr: kb/s:2041.23
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">
Our_app_logs: | stderr: Conversion failed!
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">
Our_app_logs: | close, code: 1, signal: null
Our_app_logs: | from react application: 14203
Our_app_logs: | Status ok...
Our_app_logs: | Data ok...
Our_app_logs: | FFmpeg ok...
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
Our_app_logs: | stderr: ffmpeg version 4.2.4 Copyright (c) 
2000-2020 the FFmpeg developers
Our_app_logs: | built with gcc 9.2.0 (Alpine 9.2.0)
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
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">
Our_app_logs: | stderr: libavutil 56. 31.100 / 56. 31.100
Our_app_logs: | libavcodec 58. 54.100 / 58. 54.100 
Our_app_logs: | libavformat 58. 29.100 / 58. 29.100
Our_app_logs: | libavdevice 58. 8.100 / 58. 8.100
Our_app_logs: | libavfilter 7. 57.100 / 7. 57.100
Our_app_logs: | libavresample 4. 0. 0 / 4. 0. 0 
Our_app_logs: | libswscale 5. 5.100 / 5. 5.100 
Our_app_logs: | libswresample 3. 5.100 / 3. 5.100 
Our_app_logs: | libpostproc 55. 5.100 / 55. 5.100 
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">
Our_app_logs: | stderr: [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | Last message repeated 4 times
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
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">
Our_app_logs: | stderr: [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | Last message repeated 5 times
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_headerOur_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] non-existing PPS 14 referenced
Our_app_logs: | [h264 @ 0x7f299f44f600] decode_slice_header error
Our_app_logs: | [h264 @ 0x7f299f44f600] no frame!

</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>


The FFmpeg config :


const FFMPEG_CONFIG = [
 '-i',
 '-',

 // video codec config: low latency, adaptive bitrate
 // '-vcodec',
 // 'copy',
 '-c:v',
 'libx264',
 '-preset',
 'veryfast',
 '-tune',
 'zerolatency',

 // audio codec config: sampling frequency (11025, 22050, 44100), bitrate 64 kbits
 '-c:a',
 'aac',
 '-ar',
 '44100',
 '-b:a',
 '64k',

 //force to overwrite
 '-y',

 // used for audio sync
 '-use_wallclock_as_timestamps',
 '1',
 '-async',
 '1',

 //'-filter_complex', 'aresample=44100', // resample audio to 44100Hz, needed if input is not 44100
 //'-strict', 'experimental',
 '-bufsize',
 '1000',
 '-f',
 'flv',
];



The process :


const process = child_process.spawn('ffmpeg', [
 ...FFMPEG_CONFIG,
 // 'local.bin',
 url,
 ]);
 
 process.stderr.on('data', data => {
 console.log(`stderr: ${data}`, data);
 });

 process.stdin.on('error', e => {
 console.log('FFmpeg STDIN Error', e);
 });

 process.on('error', err => console.log(err));

 process.on('close', (code, signal) => {
 console.log(`close, code: ${code}, signal: ${signal}`);
 });



The writing :


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



-
.mp4 file is not playing in Django template and FireFox or Chrome
9 février 2021, par Himanshu sharmaI 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.
I think I have a compatible issue problem in .mp4. Furthermore, I want to show and play .mp4 saved file in Django.


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


self.input_stream---> rtsp://admin:Admin123@192.168.1.208/user=admin_password=Admin123_channel=0channel_number_stream=0.sdp

self.input_stream---> rtsp://Admin:@192.168.1.209/user=Admin_password=_channel=0channel_number_stream=0.sdp



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


Django==3.1.2


I am implementing this code in difference Ubuntu PCs


Ubuntu = 18.04 and 20.04


opencv-contrib-python==4.4.0.46


opencv-python==4.4.0.46


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


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


fourcc = cv2.VideoWriter_fourcc(*'mp4v')


class ffmpegStratStreaming(threading.Thread):
 def __init__(self, input_stream=None, output_stream=None, camera=None, *args, **kwargs):
 self.input_stream = input_stream
 self.output_stream = output_stream
 self.camera = camera
 super().__init__(*args, **kwargs)

 def run(self):
 try:vs = cv2.VideoCapture(self.input_stream)
 fps_rate = int(vs.get(cv2.CAP_PROP_FPS))
 ##############################
 ############################## 
 # ~ print('fps rate-->', fps_rate,'camera id-->' ,str(self.camera.id))
 # ~ vs.set(cv2.CAP_PROP_POS_FRAMES,50) #Set the frame number to be obtained
 # ~ print('fps rate-->', fps_rate,'camera id-->' ,str(self.camera.id),' ####### ')
 
 # initialize the video writer (we'll instantiate later if need be)
 writer = None

 # initialize the frame dimensions (we'll set them as soon as we read
 # the first frame from the video)
 W = None
 H = None 
 # start the frames per second throughput estimator
 fps = FPS().start()

 # saving frame in avi video format
 video_file_count = 0
 start_time = time.time()

 while True:
 try:
 # grab the next frame and handle if we are reading from either
 # VideoCapture or VideoStream
 
 frame_init = vs.read()
 frame = frame_init[1] if self.input_stream else frame_init
 
 # if frame is can't read correctly ret is False
 while frame_init[0] == False:
 print("Can't receive frame. Retrying ...")
 vs.release()
 vs = cv2.VideoCapture(self.input_stream) 
 frame_init = vs.read()
 frame = frame_init[1] if self.input_stream else frame_init

 # if we are viewing a video and we did not grab a frame then we
 # have reached the end of the video
 if self.input_stream is not None and frame is None:
 break

 # resize the frame to have a maximum width of 500 pixels (the
 # less data we have, the faster we can process it), then convert
 # the frame from BGR to RGB for dlib
 frame = imutils.resize(frame, width=500) 
 
 
 #<---------------------- Start of writing a video to disk -------------------------> 
 minute = 1
 second = 60
 minite_to_save_video = int(minute) * int(second)

 
 # if we are supposed to be writing a video to disk, initialize
 if time.time() - start_time >= minite_to_save_video or video_file_count == 0 :
 ## where H = heigth, W = width, C = channel 
 H, W, C = frame.shape
 video_file_count += 1
 start_time = time.time()
 output_save_directory = self.output_stream+str(video_file_count)+'.mp4'
 # fourcc = cv2.VideoWriter_fourcc(*"MJPG")
 # fourcc = cv2.VideoWriter_fourcc(*'XVID')
 # fourcc = cv2.VideoWriter_fourcc(*'X264')
 # fourcc = cv2.VideoWriter_fourcc(*'MP4V')

 
 # fourcc = cv2.VideoWriter_fourcc(*'FMP4')

 # fourcc = cv2.VideoWriter_fourcc(*'avc1')


 # fourcc = cv2.VideoWriter_fourcc('M','J','P','G')

 fourcc = cv2.VideoWriter_fourcc(*'mp4v')
 # fourcc = cv2.VideoWriter_fourcc(*'mp3v')
 # fourcc = 0x00000021
 print(fourcc, type(fourcc),'ffffffff')
 # a = int(vs.get(cv2.CAP_PROP_FOURCC))
 # print(a,type(a),' aaaaaaaa' )

 # writer = skvideo.io.FFmpegWriter(output_save_directory, outputdict={
 # '-vcodec': 'libx264', '-b': '300000000'
 # })
 
 # writer = skvideo.io.FFmpegWriter(self.output_stream, outputdict={'-r': '120', '-c:v': 'libx264', '-crf': '0', '-preset': 'ultrafast', '-pix_fmt': 'yuv444p'})
 
 writer = cv2.VideoWriter(output_save_directory, fourcc ,20.0,( int(W), int(H) ), True)
 
 
 # ~ The cv2.VideoWriter requires five parameters: 

 # check to see if we should write the frame to disk
 if writer is not None: 
 try:
 writer.write(frame)
 except Exception as e:
 print('Error in writing video output---> ', e)
 
 #<---------------------- end of writing a video to disk ------------------------->

 # show the output frame
 # cv2.imshow("Frame", frame)
 # key = cv2.waitKey(1) & 0xFF

 # if the `q` key was pressed, break from the loop
 # if key == ord("q"):
 # break

 # increment the total number of frames processed thus far and
 # then update the FPS counter
 totalFrames += 1
 fps.update()
 except Exception as e:
 print('Error in main while loop--> ', e)

 # stop the timer and display FPS information
 fps.stop()

 # check to see if we need to release the video writer pointer
 # if writer is not None:
 # writer.release()

 # if we are not using a video file, stop the camera video stream
 # if not self.input_stream:
 # vs.stop()

 # otherwise, release the video file pointer
 # else:
 # vs.release()

 # close any open windows
 # cv2.destroyAllWindows()
 except Exception as e:
 print(e, '333333333333333333333333333')



My Django template code


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



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


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



-
When I append a silent audio (mp3) to an existing list of audio it garbles the final audio ?
6 février 2020, par MarieAfter several hours I have narrowed down the issue with the garbled audio to be the 2-seconds silence audio mp3 I am appending (I think I had produced it once with Wavelab)
However, I tried using ffmpeg according to a post to produce a similar 2 seconds audio but it too will corrupt/garble/chop voice in the final concatenation of audio files.
ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t 2 -q:a 9 -acodec libmp3lame SILENCE_2sec.MP3
I typically will have several audio files to concatenate together but for simplicity I have able to narrow it to a couple of files simplifying to the following script. A simple Windows batch file you should be able to use and reproduce the issue at your end.
rem
rem
SET EXE="S:\_BINS\FFmpeg 4.2.1 20200112\bin\ffmpeg.exe"
SET ROOTPATH=.\
SET IN_FILE="%ROOTPATH%MyList.txt"
ECHO file '%ROOTPATH%HELLO.mp3' > MyList.txt
ECHO file 'SILENCE_2sec.MP3' >> MyList.txt
SET OPTIONS= -f concat -safe 0 -i %IN_FILE% -c copy -y
SET OUT_FILE="%ROOTPATH%CONCATENATED_AUDIO_2.MP3"
SET INFO_FILE="INFO.TXT"
%EXE% %OPTIONS% %OUT_FILE% 1> %INFO_FILE% 2>&1
ECHO ======================== >> %INFO_FILE%
ECHO IN_FILE=%IN_FILE% >> %INFO_FILE%
ECHO EXE=%EXE% >> %INFO_FILE%
ECHO OPTIONS=%OPTIONS% >> %INFO_FILE%
ECHO ======================== >> %INFO_FILE%Here is the console info output from the ffmpeg, let me know if you need other output include ones from ffprobe
ffmpeg version git-2020-01-10-3d894db Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191125
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-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 65.103 / 58. 65.103
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 70.101 / 7. 70.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[mp3 @ 000000000036af80] Estimating duration from bitrate, this may be inaccurate
Input #0, concat, from '.\MyList.txt':
Duration: N/A, start: 0.000000, bitrate: 32 kb/s
Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s
Output #0, mp3, to '.\CONCATENATED_AUDIO_2.MP3':
Metadata:
TSSE : Lavf58.35.101
Stream #0:0: Audio: mp3, 24000 Hz, mono, fltp, 32 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp3 @ 0000000000372d00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 17280 >= 17255
size= 11kB time=00:00:02.73 bitrate= 33.2kbits/s speed=2.73e+03x
video:0kB audio:11kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.137446%
========================
IN_FILE=".\MyList.txt"
EXE="S:\_BINS\FFmpeg 4.2.1 20200112\bin\ffmpeg.exe"
OPTIONS= -f concat -safe 0 -i ".\MyList.txt" -c copy -y
========================I believe I am running FFmpeg 4.2.1, recently installed (20200112)
You may produce the HELLO.mp3 by saving the following link
https://translate.google.com.vn/translate_tts?en=UTF-8&q=Hello+&tl=en&client=tw-ob
FYI, I am still a novice of ffmpeg and using it more like a black box with the help I received in this very super forum.
Please be as explicit as you can with command line options on how I can fix this issue.
Thank you.Additional Hints Debugging :
If I append more files after the silence audio it seems that the silence audio impacts (garbles, chops) the previous audio.
You may try the following for the list of audio files input.ECHO file '%ROOTPATH%HELLO.mp3' > MyList.txt
ECHO file 'SILENCE_2sec.MP3' >> MyList.txt
ECHO file '%ROOTPATH%HELLO.mp3' >> MyList.txt
ECHO file '%ROOTPATH%HELLO.mp3' >> MyList.txtI typically add one or more silence file to derive a post silence effect after the actual audio. That’s my current logic. However if you have an alternative to appending a silence in the process of concatenating several audio files or appending x-seconds silence to an existing audio file. I can use that method as well from my coding.
Thank you.