airplay-js no start streaming

im writing a local file streaming over airplay protocol with subtitle support, to do that im using ffmpeg and the process works really fine, but the main problem is when try to start streaming after burning the subtitle, the airplay doesn't work, but when i comment the lines that do the burning works fine, what im doing wrong?... here is the code.

var fileSource = './source.mp4';
var subtitleSource = './source.srt';

var http = require('http'),
fs = require('fs'),
util = require('util'),
OS = require('os'),
spawn = require('child_process').spawn,
airplay = require('airplay-js');

var browser = airplay.createBrowser();

var tmpDir = OS.tmpdir();
var tmpFile = tmpDir + '/localTV.mp4';

var sourceSize;
var tmpFileSize;

function init(){
console.log('Starting LocalTV');
console.log('Burning Subtitle into ' + fileSource);

var stat = fs.statSync(fileSource);
sourceSize = stat.size;

fs.exists(tmpFile, function(exists){
    if(exists) fs.unlink(tmpFile)
});

var ffmpeg = spawn('./ffmpeg', [
    '-i', fileSource,
    '-sub_charenc', 'CP1252',
    '-i', subtitleSource,
    '-map', '0:v',
    '-map', '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('Burning subtitle finished');
        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("-");
        var partialstart = parts[0];
        var partialend = 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 + '-' + end + '/' + total, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': 'video/mp4' });
        file.pipe(res);

      }else{        

        res.writeHead(200, { 'Content-Length': total, 'Content-Type': 'video/mp4' });
        fs.createReadStream(path).pipe(res);
    }

}).listen(1337, '192.168.0.100', function(){
    console.log('HTTP Server Started');
    startStream();
});

return false;       
}

function startStream(){ 
console.log('Streaming to AppleTV');

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(status){
            console.info(status, 'Playing video');
        });
    });

    browser.on('error', function(err){
        console.log(err, 'Error airplay');
    })

    browser.start();
//  }else{
//      console.log('Temp file minor size that source, something is wrong');
//  }

return false;       
}

init();

thanks