node.js - airplay-js no start streaming -


I am streaming a local file on Airplay Protocol with sub-title support, to do so that I am using Ffempey and The process is working really well, but the main problem is that when I try to start streaming after burning subtitles, Airplay does not work, but when I comment on those links which burning Works fine. What am I doing wrong? Here's the code.

  var fileSource = './source.mp4'; Var subtitle source = './source.srt'; Var http = is required ('http'), fs = require ('fs'), util = require (OS) = ('OS'), spawn = is required ( 'Child_process'). Spawn, airplay = is required ('broadcast-js'); Var Browser = airplay.createBrowser (); Var tmpDir = OS.tmpdir (); Var tmpFile = tmpDir + '/localTV.mp4'; Var Sources; Var tmpFileSize; Function init () {console.log ('local TV start'); Console.log ('burn subtitle' + file source); Var stat = fs.statSync (file processing); SourceSize = stat.size; Fs.exists (tmpFile, function (present) {if (exists) fs.unlink (tmpFile)}); Var ffmpeg = spawn ('. / Ffmpeg', ['-i', file source, '-sub_charenc', 'cp5252', '-i', subtitle source, '-map', '0: V', ' -m ',' 0: a ',' -c ',' copy ',' -map ',' 1 ',' -c: s' 0 ',' mov_text ',' -metadata: s: s: 0 ',' Language = esp ', tmpFile]); Ffmpeg.stderr.pipe (process.stdout); Ffmpeg.on ('close', function (code) {if (code == 0) {console.log (subtitle is ending); initServer ();}}) ffmpeg.on ('error', function (error ) {Console.log (error, 'ffmpeg error');}); // initServer (); return false; } Function initServer () {http.createServer (function (req, res) {var path = tmpFile; var stat = fs.statSync (path); var total = stat.size; if (req.headers ['range']) {Var range = req.headers.range; var parts = range.replace (/ bytes = /, "") .split ("-"); partial start = parts [0]; var partial = parts [1]; Var Start = parseInt (partialstart, 10); var end = partialend? ParseInt (partialend, 10): total -1; var chunksize = (end-start) +1; var file = fs.createReadStream (path, {start: start , End-end}); res.writeHead (206, {'content-range': 'bytes' + start +' - '+ + + + / + + total,' acceptance-range ':' bytes', 'content - File '(video / mp34)}; file.pipe (res);} else {res.writeHead (200, {' Content-Length ': Total,' Content ;); Fs.createReadStream (path) .pipe (res);}}) Listen. (1337, '192.168.0.100', function () {Greek-type ': total,' content type '' video / MP3 '}); Cons Ole.log (Start 'HTTP Server'); startStream ();}); Description is false;} startstream function () {console.log ('streaming on Apple TV'); Var stat = fs.statSync (tmpFile); TmpFileSize = stat.size; // if (tmpFileSize> = sourceSize) {browser.on ('deviceOn', function (device) {device.play ('http://192.168.0.100:1337', 0, function (position) {console. Info (position, 'playing video');});}); Browser.on ('error', function (err) {console.log (error, 'error airplay');}) browser.start (); //} else {// console.log ('case size of temporary file, something is wrong'); //  }  return false; }  in this();  


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -