Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support storyboards on very short shorts #3128

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/renderer/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ export function toLocalePublicationString ({ publishText, isLive = false, isUpco
return i18n.t('Video.Publicationtemplate', { number: strings[0], unit })
}

export function buildVTTFileLocally(storyboard) {
export function buildVTTFileLocally(storyboard, videoLengthSeconds) {
let vttString = 'WEBVTT\n\n'
// how many images are in one image
const numberOfSubImagesPerImage = storyboard.columns * storyboard.rows
// the number of storyboard images
const numberOfImages = Math.ceil(storyboard.thumbnail_count / numberOfSubImagesPerImage)
const intervalInSeconds = storyboard.interval / 1000
let intervalInSeconds
if (storyboard.interval > 0) {
intervalInSeconds = storyboard.interval / 1000
} else {
intervalInSeconds = videoLengthSeconds / (numberOfImages * numberOfSubImagesPerImage)
}
let startHours = 0
let startMinutes = 0
let startSeconds = 0
Expand All @@ -110,11 +115,11 @@ export function buildVTTFileLocally(storyboard) {
// add the timestamp information
const paddedStartHours = startHours.toString().padStart(2, '0')
const paddedStartMinutes = startMinutes.toString().padStart(2, '0')
const paddedStartSeconds = startSeconds.toString().padStart(2, '0')
const paddedStartSeconds = startSeconds.toFixed(3).padStart(6, '0')
const paddedEndHours = endHours.toString().padStart(2, '0')
const paddedEndMinutes = endMinutes.toString().padStart(2, '0')
const paddedEndSeconds = endSeconds.toString().padStart(2, '0')
vttString += `${paddedStartHours}:${paddedStartMinutes}:${paddedStartSeconds}.000 --> ${paddedEndHours}:${paddedEndMinutes}:${paddedEndSeconds}.000\n`
const paddedEndSeconds = endSeconds.toFixed(3).padStart(6, '0')
vttString += `${paddedStartHours}:${paddedStartMinutes}:${paddedStartSeconds} --> ${paddedEndHours}:${paddedEndMinutes}:${paddedEndSeconds}\n`
// add the current image url as well as the x, y, width, height information
vttString += `${currentUrl}#xywh=${xCoord},${yCoord},${storyboard.thumbnail_width},${storyboard.thumbnail_height}\n\n`
// update the variables
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export default defineComponent({
}

if (result.storyboards?.type === 'PlayerStoryboardSpec') {
await this.createLocalStoryboardUrls(result.storyboards.boards[2])
await this.createLocalStoryboardUrls(result.storyboards.boards.at(-1))
}
}

Expand Down Expand Up @@ -1290,7 +1290,7 @@ export default defineComponent({
},

createLocalStoryboardUrls: async function (storyboardInfo) {
const results = buildVTTFileLocally(storyboardInfo)
const results = buildVTTFileLocally(storyboardInfo, this.videoLengthSeconds)
const userData = await getUserDataPath()
let fileLocation
let uriSchema
Expand Down