Skip to content

Commit

Permalink
fix(video): fix filename fix in ensureAllClipsAreDecoded
Browse files Browse the repository at this point in the history
  • Loading branch information
saoron committed Apr 1, 2018
1 parent 9913b3b commit 250ae10
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 58 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drideOS",
"version": "0.10.2",
"version": "0.10.3",
"settings": {
"debug": false,
"videoRecord": true,
Expand Down
80 changes: 42 additions & 38 deletions modules/video/helpers/ensureAllClipsAreDecoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,49 @@ var isAppConnected = record.isAppOnline();

var settings = settingsHelper.getSettings();
if (isAppConnected && !isAppConnectedObj.connected) {
fs.readdir(dirTmpClip, (err, files) => {
if (err) {
console.error('Could not list the directory.', err);
process.exit(0);
}
let fielDetails = null;
//files.forEach((file, index) => {
for (var index = 0; index < files.length; index++) {
file = files[index];
fileDetails = fs.statSync(dirTmpClip + '/' + file);
fs.readdir(dirTmpClip, (err, files) => {
if (err) {
console.error('Could not list the directory.', err);
process.exit(0);
}
let fielDetails = null;
//files.forEach((file, index) => {
for (var index = 0; index < files.length; index++) {
file = files[index];
fileDetails = fs.statSync(dirTmpClip + '/' + file);

var fileName = file.split('.').shift();
//skip empty files
if (!fileDetails.size) {
continue;
}
var fileName = file.split('.').shift();

//if the file is from the last minute ignore it
if (Math.abs(new Date().getTime() - fileDetails.birthtimeMs) > 1000 * 120) {
//repack h264 to mp4 container
execSync(
'avconv -framerate ' +
(settings.resolution == '1080' ? 30 : 30) +
' -i /dride/tmp_clip/' +
fileName +
'.h264 -c copy /dride/clip/' +
fileDetails.birthtimeMs +
'.mp4 -y'
);
//if the file is from the last minute ignore it
if (Math.abs(new Date().getTime() - Math.floor(fileDetails.birthtimeMs)) > 1000 * 120) {
//repack h264 to mp4 container
execSync(
'avconv -framerate ' +
(settings.resolution == '1080' ? 30 : 30) +
' -i /dride/tmp_clip/' +
fileName +
'.h264 -c copy /dride/clip/' +
Math.floor(fileDetails.birthtimeMs) +
'.mp4 -y'
);

//remove tmp file
if (fs.existsSync(dir + 'tmp_clip/' + fileName + '.h264')) {
try {
fs.unlinkSync(dir + 'tmp_clip/' + fileName + '.h264');
} catch (err) {
//throw err
console.error(error);
}
}
// Manual encoding will add .m to the file name, this will allow us to avoid conflict with button press events
record.saveThumbNail(fileDetails.birthtimeMs);
break;
}
}
});
//remove tmp file
if (fs.existsSync(dir + 'tmp_clip/' + fileName + '.h264')) {
try {
fs.unlinkSync(dir + 'tmp_clip/' + fileName + '.h264');
} catch (err) {
//throw err
console.error(error);
}
}
// Manual encoding will add .m to the file name, this will allow us to avoid conflict with button press events
record.saveThumbNail(Math.floor(fileDetails.birthtimeMs));
break;
}
}
});
}
4 changes: 2 additions & 2 deletions modules/video/helpers/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var encodeAndAddThumb = (fileName, resolution, birthtimeMs) => {
' -i /dride/tmp_clip/' +
fileName +
'.h264 -c copy /dride/clip/' +
fileDetails.birthtimeMs +
Math.floor(fileDetails.birthtimeMs) +
'.mp4 -y'
);
//remove tmp file
Expand All @@ -155,7 +155,7 @@ var encodeAndAddThumb = (fileName, resolution, birthtimeMs) => {
console.error(error);
}
}
saveThumbNail(fileDetails.birthtimeMs);
saveThumbNail(Math.floor(fileDetails.birthtimeMs));
};

module.exports = {
Expand Down
21 changes: 5 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dride-core",
"version": "0.10.2",
"version": "0.10.3",
"description": "Open source dashcam for RaspberryPi ",
"scripts": {
"build": "node scripts/build.js",
Expand All @@ -13,9 +13,7 @@
"type": "git",
"url": "https://github.com/dride/dride-core.git"
},
"keywords": [
"dride"
],
"keywords": ["dride"],
"author": "Dride, Inc.",
"license": "MIT",
"bugs": {
Expand Down Expand Up @@ -43,17 +41,10 @@
"generateNotes": {
"preset": "angular",
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING"
]
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
},
"writerOpts": {
"commitsSort": [
"subject",
"scope"
]
"commitsSort": ["subject", "scope"]
}
},
"prepare": [
Expand All @@ -63,8 +54,6 @@
},
"@semantic-release/git"
],
"publish": [
"@semantic-release/github"
]
"publish": ["@semantic-release/github"]
}
}
2 changes: 1 addition & 1 deletion state/config.backup.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drideOS",
"version": "0.10.2",
"version": "0.10.3",
"settings": {
"debug": false,
"videoRecord": true,
Expand Down

0 comments on commit 250ae10

Please sign in to comment.