Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
More tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
thepatrick committed Mar 9, 2019
1 parent 7408c21 commit 754b61e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions utils.js
Expand Up @@ -10,29 +10,26 @@ const readdirAsync = util.promisify(fs.readdir)
function timeFromFileName (filePath) {
const fileTime = path.basename(filePath, '.ts')
const fileDirectory = path.dirname(filePath)
const t = moment(fileDirectory + ' ' + fileTime, 'YYYY-MM-DD HH_mm_ss')
return t.unix()
return moment(fileDirectory + ' ' + fileTime, 'YYYY-MM-DD HH_mm_ss').unix()
}

function fileNameFromTime (time) {
const t = moment.unix(time)
return t.format('YYYY-MM-DD/HH_mm_ss') + '.ts'
return moment.unix(time).format('YYYY-MM-DD/HH_mm_ss') + '.ts'
}

async function filesByStartTime (videoFilesRoot) {
const dayDirectories = (await readdirAsync(videoFilesRoot, { withFileTypes: true }))
.filter(f => f.isDirectory())

const allFiles = await Promise.all(
dayDirectories.map(async d => {
return (await readdirAsync(path.join(videoFilesRoot, d.name), { withFileTypes: true }))
dayDirectories.map(async d => (
(await readdirAsync(path.join(videoFilesRoot, d.name), { withFileTypes: true }))
.filter(f => f.isFile() && path.extname(f.name) === '.ts')
.map(f => path.join(videoFilesRoot, d.name, f.name))
})
))
)

const files = _.flatten(allFiles).map(timeFromFileName)
return files
return _.flatten(allFiles).map(timeFromFileName)
}

function meltTracksForStartAndEndTime (videoFilesRoot, files, fps, start, end) {
Expand Down

0 comments on commit 754b61e

Please sign in to comment.