
Recherche avancée
Médias (1)
-
Rennes Emotion Map 2010-11
19 octobre 2011, par
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (33)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...)
Sur d’autres sites (5634)
-
I received connection refused error while trying to stream live video through RTMP with FFMPEG
25 septembre 2020, par FemzyI 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 'anullsrc':
 Duration:
FFmpeg STDERR: N/A, start: 0.000000, bitrate: 705 kb/s
 Stream #0:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s

DATA <buffer 1a="1a">
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">
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">
FFmpeg STDERR: Input #1, matroska,webm, from 'pipe:':
 Metadata:
 encoder :
FFmpeg STDERR: Chrome
 Duration: N/A, start: 0.000000, bitrate: N/A
 Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
 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)

FFmpeg STDERR: [tcp @ 0xe5fac0] Connection to tcp://a.rtmp.youtube.com:1935 failed (Connection refused), trying next address
[rtmp @ 0xe0fb80] Cannot open connection tcp://a.rtmp.youtube.com:1935

FFmpeg STDERR: rtmp://a.rtmp.youtube.com/live2/mystreamid: Network is unreachable

FFmpeg child process closed, code 1, signal null</buffer></buffer></buffer>







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


-
Is there a way to batch split a file by chapter with ffmpeg and then reassemble with mkvmerge in windows ?
13 avril, par SipherdrakonSo 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.


@echo off
setlocal enableDelayedExpansion

REM CODE BELOW CREATES JSON FILES FOR ALL MP4 FILES WITHIN THE SAME DIRECTORY
ffprobe -v quiet -print_format json -show_chapters -loglevel error "01x01.mp4" > "01x01.json"

REM CODE BELOW SETS VARIABLES FROM EACH SPECIFIC JSON
FOR /F "delims=" %%i in ('jq .chapters[2].start ^< 01x01.json') DO SET /A start1=%%i
FOR /F "delims=" %%j in ('jq .chapters[2].end ^< 01x01.json') DO SET /A end1=%%j

FOR /F "delims=" %%k in ('jq .chapters[4].start ^< 01x01.json') DO SET /A start2=%%k
FOR /F "delims=" %%l in ('jq .chapters[4].end ^< 01x01.json') DO SET /A end2=%%l

FOR /F "delims=" %%m in ('jq .chapters[6].start ^< 01x01.json') DO SET /A start3=%%m
FOR /F "delims=" %%n in ('jq .chapters[6].end ^< 01x01.json') DO SET /A end3=%%n

FOR /F "delims=" %%o in ('jq .chapters[8].start ^< 01x01.json') DO SET /A start4=%%o
FOR /F "delims=" %%p in ('jq .chapters[8].end ^< 01x01.json') DO SET /A end4=%%p

REM SETS THE DURATION OF EACH FILE TO USE PRECISION TIMING FOR START AND STOP TIMES
CALL vbs (%end1%-%start1%)/1000
SET duration1=%val%
CALL vbs (%end2%-%start2%)/1000
SET duration2=%val%
CALL vbs (%end3%-%start3%)/1000
SET duration3=%val%
CALL vbs (%end4%-%start4%)/1000
SET duration4=%val%

REM SETS THE START TIME IN SECONDS VS MILLISECONDS
CALL vbs (%start1%)/1000
SET start1=%val%
CALL vbs (%start2%)/1000
SET start2=%val%
CALL vbs (%start3%)/1000
SET start3=%val%
CALL vbs (%start4%)/1000
SET start4=%val%

REM TRIM AND SPLIT ORIGINAL FILE INTO SEPERATE SECTIONS BASED ON CHAPTER MARKERS
ffmpeg -ss %START1% -i 01x01.mp4 -ss 0 -c copy -to %DURATION1% -avoid_negative_ts make_zero 01x01-1.mp4
ffmpeg -ss %START2% -i 01x01.mp4 -ss 0 -c copy -to %DURATION2% -avoid_negative_ts make_zero 01x01-2.mp4
ffmpeg -ss %START3% -i 01x01.mp4 -ss 0 -c copy -to %DURATION3% -avoid_negative_ts make_zero 01x01-3.mp4
ffmpeg -ss %START4% -i 01x01.mp4 -ss 0 -c copy -to %DURATION4% -avoid_negative_ts make_zero 01x01-4.mp4

REM DELETES UNNEEDED JSON AFTER USE
del /s *.json

REM APPEND ALL MP4 FILES INTO COHESIVE MKV
for /d /r %%D in (*) do (
 pushd %%D
 set files=
 for %%F in (*.mp4) do set files=!files! + ^( "%%F" ^)
 if not "!files!"=="" %mkvmerge% -o "01x01-FINAL.mkv" !files:~2!
 popd
)

REM DELETE UNNEEDED MP4 ORIGINALS AND SPLIT FILES
del /s *.mp4



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.


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.


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


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



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



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


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.


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.


UPDATE


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.


@echo off

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



-
Evolution #4567 : balise introduction
4 octobre 2020, par RastaPopoulos ♥Il y a déjà le filtre |introduction pour ça (utilisé par la balise) (le première argument est le descriptif, qu’on met donc ici à vide) : [(#VAL|introduction#TEXTE, 1000)]