Skip to content

Commit

Permalink
OverlayParser
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewiski committed May 17, 2023
1 parent e7db580 commit 184cc7a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
44 changes: 22 additions & 22 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,29 @@ routes.get('/data/audioFiles/fullSongs/:filename', (req, res) => {

// If a range header was provided, only send the requested portion of the file
if (range) {
const parts = range.replace(/bytes=/, "").split("-");
const start = parseInt(parts[0], 10);
const end = parts[1]
? parseInt(parts[1], 10)
: fileSize-1;
const chunksize = (end-start)+1;
const file = fs.createReadStream(filePath, {start, end});
const head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
'Content-Type': 'audio/mp4',
};
res.writeHead(206, head);
file.pipe(res);
const parts = range.replace(/bytes=/, "").split("-");
const start = parseInt(parts[0], 10);
const end = parts[1]
? parseInt(parts[1], 10)
: fileSize-1;
const chunksize = (end-start)+1;
const file = fs.createReadStream(filePath, {start, end});
const head = {
'Content-Range': `bytes ${start}-${end}/${fileSize}`,
'Accept-Ranges': 'bytes',
'Content-Length': chunksize,
'Content-Type': 'audio/mp4',
};
res.writeHead(206, head);
file.pipe(res);
} else {
// If no range header was provided, send the entire file
const head = {
'Content-Length': fileSize,
'Content-Type': 'audio/mp4',
};
res.writeHead(200, head);
fs.createReadStream(filePath).pipe(res);
// If no range header was provided, send the entire file
const head = {
'Content-Length': fileSize,
'Content-Type': 'audio/mp4',
};
res.writeHead(200, head);
fs.createReadStream(filePath).pipe(res);
}
} catch (err) {
logUtilHelper.log(appLogName, "browser", "error", "Error getting audio file.", req.params.filename);
Expand Down
3 changes: 2 additions & 1 deletion modules/ffmpegRtmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var FfmpegRtmp = function (options, videoOverlayParser, logUtilHelper) {
}

self.options = extend({}, defaultOptions, options);
self.videoOverlayParser = videoOverlayParser;

if (process.platform === 'win32' && (process.env.FFMPEG_PATH === undefined || process.env.FFMPEG_PATH === '')) {
process.env.FFMPEG_PATH = path.join(__dirname, '..', 'ffmpeg', 'ffmpeg.exe');
Expand Down Expand Up @@ -376,7 +377,7 @@ var FfmpegRtmp = function (options, videoOverlayParser, logUtilHelper) {

var updateOverlay= function (options) {
try {
if(self.videoOverlayParser !== null){
if(self.videoOverlayParser && self.videoOverlayParser.getOverlayText){
var overlayText = self.videoOverlayParser.getOverlayText(options)
if(self.options.overlayFileName != null ){
var overlayFilePath = path.join(__dirname, '..', self.options.overlayFileName);
Expand Down
2 changes: 1 addition & 1 deletion modules/ffmpegVideoInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ var FfmpegVideoInput = function (options, videoOverlayParser, logUtilHelper) {

var updateOverlay= function (options) {
try {
if(self.videoOverlayParser !== null){
if(self.videoOverlayParser && self.videoOverlayParser.getOverlayText ){
var overlayText = self.videoOverlayParser.getOverlayText(options)
if(self.options.overlayFileName != null ){
var overlayFilePath = path.join(__dirname, '..', self.options.overlayFileName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radargunmonitor",
"version": "0.0.20",
"version": "0.0.21",
"private": false,
"license": "Apache-2.0",
"keywords": [
Expand Down

0 comments on commit 184cc7a

Please sign in to comment.