@crievo/omni 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +41 -0
- package/README.md +2 -2
- package/bin/omni.mjs +14 -0
- package/docs/onboarding/clone-voice.png +0 -0
- package/docs/onboarding/getting-started.png +0 -0
- package/docs/onboarding/new-video.png +0 -0
- package/docs/onboarding/providers.png +0 -0
- package/docs/onboarding/publish.png +0 -0
- package/docs/onboarding/references.png +0 -0
- package/docs/onboarding.md +212 -0
- package/omnivideo.config.example.json +437 -0
- package/package.json +40 -4
- package/reference/captions.md +156 -0
- package/reference/carousel-contract.md +91 -0
- package/reference/cloud.md +96 -0
- package/reference/learnings.md +792 -0
- package/reference/omnichat.md +305 -0
- package/reference/premiere-mcp.md +91 -0
- package/reference/publish.md +305 -0
- package/reference/scenes-contract.md +109 -0
- package/reference/studio.md +666 -0
- package/reference/voicestudio.md +81 -0
- package/reference/writing-for-voice.md +67 -0
- package/requirements.txt +3 -0
- package/studio/api/app.ts +87 -0
- package/studio/api/lib/errors.ts +33 -0
- package/studio/api/lib/files.ts +41 -0
- package/studio/api/lib/hono.ts +9 -0
- package/studio/api/lib/result.ts +14 -0
- package/studio/api/lib/validate.ts +31 -0
- package/studio/api/lib/video.ts +10 -0
- package/studio/api/middleware/json-charset.ts +11 -0
- package/studio/api/middleware/local-only.ts +32 -0
- package/studio/api/middleware/no-timeout.ts +10 -0
- package/studio/api/routes/admin.ts +18 -0
- package/studio/api/routes/agent-cascade.ts +100 -0
- package/studio/api/routes/agent-history.ts +23 -0
- package/studio/api/routes/agent.ts +162 -0
- package/studio/api/routes/analytics.ts +31 -0
- package/studio/api/routes/approval.ts +60 -0
- package/studio/api/routes/archive.ts +12 -0
- package/studio/api/routes/captions.ts +28 -0
- package/studio/api/routes/carousel.ts +38 -0
- package/studio/api/routes/clone.ts +27 -0
- package/studio/api/routes/create.ts +19 -0
- package/studio/api/routes/events.ts +11 -0
- package/studio/api/routes/export.ts +14 -0
- package/studio/api/routes/media.ts +30 -0
- package/studio/api/routes/omnichat.ts +113 -0
- package/studio/api/routes/onboarding.ts +14 -0
- package/studio/api/routes/publish.ts +40 -0
- package/studio/api/routes/queue.ts +14 -0
- package/studio/api/routes/references.ts +40 -0
- package/studio/api/routes/runner.ts +17 -0
- package/studio/api/routes/schedule.ts +47 -0
- package/studio/api/routes/services.ts +11 -0
- package/studio/api/routes/sessions.ts +27 -0
- package/studio/api/routes/settings.ts +102 -0
- package/studio/api/routes/sound.ts +45 -0
- package/studio/api/routes/thumbnail.ts +18 -0
- package/studio/api/routes/usage.ts +13 -0
- package/studio/api/routes/videos.ts +41 -0
- package/studio/api/routes/voices.ts +71 -0
- package/studio/api/services/admin.ts +113 -0
- package/studio/api/services/agent-cascade.ts +975 -0
- package/studio/api/services/agent-claude.ts +47 -0
- package/studio/api/services/agent-history.ts +103 -0
- package/studio/api/services/agent-persona.ts +77 -0
- package/studio/api/services/agent-tools.ts +2237 -0
- package/studio/api/services/agent-ui-tools.ts +259 -0
- package/studio/api/services/agent-wait.ts +32 -0
- package/studio/api/services/agent.ts +553 -0
- package/studio/api/services/analytics.ts +92 -0
- package/studio/api/services/approval.ts +134 -0
- package/studio/api/services/archive.ts +38 -0
- package/studio/api/services/captions.ts +268 -0
- package/studio/api/services/carousel.ts +206 -0
- package/studio/api/services/classify.ts +196 -0
- package/studio/api/services/clone-phrases.ts +75 -0
- package/studio/api/services/clone.ts +722 -0
- package/studio/api/services/create.ts +421 -0
- package/studio/api/services/events.ts +215 -0
- package/studio/api/services/media.ts +32 -0
- package/studio/api/services/omnichat.ts +624 -0
- package/studio/api/services/onboarding.ts +77 -0
- package/studio/api/services/publish.ts +287 -0
- package/studio/api/services/queue.ts +150 -0
- package/studio/api/services/references.ts +269 -0
- package/studio/api/services/root.ts +60 -0
- package/studio/api/services/services.ts +114 -0
- package/studio/api/services/sessions.ts +1007 -0
- package/studio/api/services/settings.ts +983 -0
- package/studio/api/services/sound.ts +311 -0
- package/studio/api/services/thumbnail.ts +133 -0
- package/studio/api/services/usage.ts +27 -0
- package/studio/api/services/videos.ts +418 -0
- package/studio/api/services/voice-pause.ts +98 -0
- package/studio/api/services/voices.ts +324 -0
- package/studio/runner/runner.ts +244 -0
- package/studio/shared/omni-actions.ts +68 -0
- package/studio/shared/omni-admin.ts +52 -0
- package/studio/shared/omni-farewell.ts +48 -0
- package/studio/shared/omni-hotword.ts +20 -0
- package/studio/shared/omni-screens.ts +228 -0
- package/studio/shared/schemas/admin.ts +15 -0
- package/studio/shared/schemas/agent-cascade.ts +58 -0
- package/studio/shared/schemas/agent-history.ts +73 -0
- package/studio/shared/schemas/agent.ts +50 -0
- package/studio/shared/schemas/analytics.ts +6 -0
- package/studio/shared/schemas/approval.ts +22 -0
- package/studio/shared/schemas/captions.ts +19 -0
- package/studio/shared/schemas/carousel.ts +26 -0
- package/studio/shared/schemas/clone.ts +40 -0
- package/studio/shared/schemas/common.ts +16 -0
- package/studio/shared/schemas/omnichat.ts +54 -0
- package/studio/shared/schemas/onboarding.ts +5 -0
- package/studio/shared/schemas/publish.ts +45 -0
- package/studio/shared/schemas/references.ts +20 -0
- package/studio/shared/schemas/settings.ts +82 -0
- package/studio/shared/schemas/sound.ts +22 -0
- package/studio/shared/schemas/videos.ts +38 -0
- package/studio/shared/schemas/voices.ts +23 -0
- package/studio/shared/types/api.ts +1290 -0
- package/studio/studio.ts +148 -0
- package/studio/tsconfig.json +15 -0
- package/studio/web/assets/logos/cartesia.svg +4 -0
- package/studio/web/assets/logos/elevenlabs.svg +12 -0
- package/studio/web/assets/logos/fish.svg +24 -0
- package/studio/web/assets/logos/omni-black.png +0 -0
- package/studio/web/assets/logos/omni-white.png +0 -0
- package/studio/web/assets/logos/voicestudio.svg +21 -0
- package/studio/web/components/AgentMark.tsx +7 -0
- package/studio/web/components/AgentWalking.tsx +11 -0
- package/studio/web/components/ApiKeyField.tsx +104 -0
- package/studio/web/components/AppShell.tsx +64 -0
- package/studio/web/components/ApprovalNotice.tsx +65 -0
- package/studio/web/components/AvatarGroupIcon.tsx +22 -0
- package/studio/web/components/AvatarNameField.tsx +86 -0
- package/studio/web/components/AvatarPicker.tsx +84 -0
- package/studio/web/components/BrandLogo.tsx +16 -0
- package/studio/web/components/CartesiaPlanSetting.tsx +90 -0
- package/studio/web/components/ClaudeWalking.tsx +32 -0
- package/studio/web/components/CloneVoiceDialog/GuidedScript.tsx +39 -0
- package/studio/web/components/CloneVoiceDialog/LanguageBar.tsx +37 -0
- package/studio/web/components/CloneVoiceDialog/LevelMeter.tsx +31 -0
- package/studio/web/components/CloneVoiceDialog/ProviderChoice.tsx +81 -0
- package/studio/web/components/CloneVoiceDialog/QualityPanel.tsx +62 -0
- package/studio/web/components/CloneVoiceDialog/RecordStep.tsx +50 -0
- package/studio/web/components/CloneVoiceDialog/RecorderBar.tsx +79 -0
- package/studio/web/components/CloneVoiceDialog/RedoSummary.tsx +54 -0
- package/studio/web/components/CloneVoiceDialog/SaveStep.tsx +91 -0
- package/studio/web/components/CloneVoiceDialog/SourceBar.tsx +30 -0
- package/studio/web/components/CloneVoiceDialog/index.tsx +141 -0
- package/studio/web/components/CloneVoiceDialog/types.ts +28 -0
- package/studio/web/components/CloneVoiceDialog/useCloneVoice.ts +528 -0
- package/studio/web/components/ConnectionSignals.tsx +51 -0
- package/studio/web/components/EditVoiceDialog/EditVoiceFooter.tsx +72 -0
- package/studio/web/components/EditVoiceDialog/ProviderCards.tsx +81 -0
- package/studio/web/components/EditVoiceDialog/index.tsx +256 -0
- package/studio/web/components/ErrorBanner.tsx +115 -0
- package/studio/web/components/FinishedTask.tsx +41 -0
- package/studio/web/components/FishModelSetting.tsx +69 -0
- package/studio/web/components/FishPriceSetting.tsx +44 -0
- package/studio/web/components/HumanBanner.tsx +64 -0
- package/studio/web/components/Lightbox.tsx +41 -0
- package/studio/web/components/LogStream.tsx +42 -0
- package/studio/web/components/Markdown.tsx +21 -0
- package/studio/web/components/MissingDmsPanel/BatchSend.tsx +137 -0
- package/studio/web/components/MissingDmsPanel/CommentCard.tsx +168 -0
- package/studio/web/components/MissingDmsPanel/CommentFeed.tsx +45 -0
- package/studio/web/components/MissingDmsPanel/DmBubble.tsx +38 -0
- package/studio/web/components/MissingDmsPanel/ReplyComposer.tsx +63 -0
- package/studio/web/components/MissingDmsPanel/index.tsx +98 -0
- package/studio/web/components/NotFound.tsx +48 -0
- package/studio/web/components/Omni/OmniAvatarPicker.tsx +92 -0
- package/studio/web/components/Omni/OmniCards.tsx +202 -0
- package/studio/web/components/Omni/OmniGlow.tsx +183 -0
- package/studio/web/components/Omni/OmniHistory.tsx +119 -0
- package/studio/web/components/Omni/OmniHotword.tsx +40 -0
- package/studio/web/components/Omni/OmniMicSelect.tsx +92 -0
- package/studio/web/components/Omni/OmniVoiceSample.tsx +81 -0
- package/studio/web/components/Omni/OmniWidget.tsx +743 -0
- package/studio/web/components/Omni/PendingActions.tsx +200 -0
- package/studio/web/components/Omni/Transcript.tsx +127 -0
- package/studio/web/components/OmnichatAccountStatus.tsx +87 -0
- package/studio/web/components/OmnichatRulePanel/RuleConfig.tsx +150 -0
- package/studio/web/components/OmnichatRulePanel/RuleDryRun.tsx +15 -0
- package/studio/web/components/OmnichatRulePanel/RuleEnableConfirm.tsx +42 -0
- package/studio/web/components/OmnichatRulePanel/RuleSkeleton.tsx +18 -0
- package/studio/web/components/OmnichatRulePanel/RuleStatus.tsx +55 -0
- package/studio/web/components/OmnichatRulePanel/index.tsx +115 -0
- package/studio/web/components/OmnichatRulePanel/rule-steps.ts +67 -0
- package/studio/web/components/OmnichatRulePanel/steps/MessageStep.tsx +91 -0
- package/studio/web/components/OmnichatRulePanel/steps/RepliesStep.tsx +201 -0
- package/studio/web/components/OmnichatRulePanel/steps/TriggerStep.tsx +76 -0
- package/studio/web/components/OmnichatRulePanel/steps/types.ts +11 -0
- package/studio/web/components/Palette.tsx +17 -0
- package/studio/web/components/PlatformCard.tsx +109 -0
- package/studio/web/components/PlatformIcon.tsx +19 -0
- package/studio/web/components/ProviderCard.tsx +80 -0
- package/studio/web/components/ProviderDetail.tsx +367 -0
- package/studio/web/components/ProviderLogo.tsx +20 -0
- package/studio/web/components/QueuePanel.tsx +77 -0
- package/studio/web/components/ReferenceActions.tsx +89 -0
- package/studio/web/components/ReferencePicker.tsx +136 -0
- package/studio/web/components/ResultMessage.tsx +7 -0
- package/studio/web/components/RuleForm.tsx +138 -0
- package/studio/web/components/RuleLog.tsx +151 -0
- package/studio/web/components/RunningTask.tsx +23 -0
- package/studio/web/components/SampleList.tsx +55 -0
- package/studio/web/components/SessionPanel.tsx +352 -0
- package/studio/web/components/SettingRow.tsx +14 -0
- package/studio/web/components/SettingsCategorySkeleton.tsx +25 -0
- package/studio/web/components/SidePanel.tsx +77 -0
- package/studio/web/components/Sidebar.tsx +289 -0
- package/studio/web/components/StageStepper.tsx +87 -0
- package/studio/web/components/StudioOffline.tsx +80 -0
- package/studio/web/components/TaskName.tsx +17 -0
- package/studio/web/components/TopBanners.tsx +30 -0
- package/studio/web/components/VideoOmnichatPanel.tsx +287 -0
- package/studio/web/components/VoiceAvatar.tsx +33 -0
- package/studio/web/components/VoiceCarousel.tsx +196 -0
- package/studio/web/components/VoiceCategory.tsx +9 -0
- package/studio/web/components/VoiceModal.tsx +39 -0
- package/studio/web/components/VoiceProfileCard.tsx +75 -0
- package/studio/web/components/VoiceProfilePicker.tsx +107 -0
- package/studio/web/components/VoiceProfilesSettings.tsx +150 -0
- package/studio/web/components/VoiceProviderCard.tsx +118 -0
- package/studio/web/components/VoiceProvidersCard.tsx +26 -0
- package/studio/web/components/WaitList.tsx +21 -0
- package/studio/web/components/icons.tsx +247 -0
- package/studio/web/components/ui/accordion.tsx +47 -0
- package/studio/web/components/ui/badge.tsx +18 -0
- package/studio/web/components/ui/calendar.tsx +43 -0
- package/studio/web/components/ui/chart.tsx +229 -0
- package/studio/web/components/ui/checkbox.tsx +26 -0
- package/studio/web/components/ui/cx.ts +2 -0
- package/studio/web/components/ui/date-time-picker.tsx +84 -0
- package/studio/web/components/ui/panel.tsx +23 -0
- package/studio/web/components/ui/picker.tsx +58 -0
- package/studio/web/components/ui/popover.tsx +24 -0
- package/studio/web/components/ui/select.tsx +89 -0
- package/studio/web/components/ui/skeleton.tsx +10 -0
- package/studio/web/components/ui/slider.tsx +68 -0
- package/studio/web/components/ui/switch.tsx +13 -0
- package/studio/web/components/ui/tooltip.test.tsx +30 -0
- package/studio/web/components/ui/tooltip.tsx +59 -0
- package/studio/web/hooks/useAccounts.ts +27 -0
- package/studio/web/hooks/useAdmin.ts +12 -0
- package/studio/web/hooks/useAnalytics.ts +21 -0
- package/studio/web/hooks/useAvatarAudioReactive.ts +87 -0
- package/studio/web/hooks/useBrowserConnect.ts +48 -0
- package/studio/web/hooks/useClonePlan.ts +14 -0
- package/studio/web/hooks/useConnected.ts +7 -0
- package/studio/web/hooks/useLiveQuery.ts +29 -0
- package/studio/web/hooks/useMenuCollapsed.ts +32 -0
- package/studio/web/hooks/useMicDevices.ts +53 -0
- package/studio/web/hooks/useMissingDms.ts +211 -0
- package/studio/web/hooks/useMissingSetupSteps.ts +26 -0
- package/studio/web/hooks/useNow.ts +11 -0
- package/studio/web/hooks/useOmniAgent.ts +278 -0
- package/studio/web/hooks/useOmniClaude.ts +124 -0
- package/studio/web/hooks/useOmniDock.ts +142 -0
- package/studio/web/hooks/useOmniGreeting.ts +60 -0
- package/studio/web/hooks/useOmniHotword.ts +128 -0
- package/studio/web/hooks/useOmnichat.ts +26 -0
- package/studio/web/hooks/useOnboarding.ts +27 -0
- package/studio/web/hooks/usePost.ts +23 -0
- package/studio/web/hooks/useQueue.ts +10 -0
- package/studio/web/hooks/useReferences.ts +20 -0
- package/studio/web/hooks/useRuleEditor.ts +101 -0
- package/studio/web/hooks/useRunner.ts +24 -0
- package/studio/web/hooks/useSaveAction.ts +23 -0
- package/studio/web/hooks/useSchedule.ts +11 -0
- package/studio/web/hooks/useServices.ts +10 -0
- package/studio/web/hooks/useSessions.ts +15 -0
- package/studio/web/hooks/useSettings.ts +11 -0
- package/studio/web/hooks/useSettingsSection.ts +30 -0
- package/studio/web/hooks/useSidePanel.ts +23 -0
- package/studio/web/hooks/useSound.ts +30 -0
- package/studio/web/hooks/useUsage.ts +11 -0
- package/studio/web/hooks/useVideoVoice.ts +36 -0
- package/studio/web/hooks/useVideos.ts +21 -0
- package/studio/web/hooks/useVoiceProfilePreview.ts +52 -0
- package/studio/web/hooks/useVoiceProfiles.ts +7 -0
- package/studio/web/hooks/useVoiceRunning.ts +10 -0
- package/studio/web/hooks/useVoiceStudioClosed.ts +8 -0
- package/studio/web/index.html +19 -0
- package/studio/web/lib/agent.ts +7 -0
- package/studio/web/lib/alerts.ts +210 -0
- package/studio/web/lib/analytics-metrics.ts +351 -0
- package/studio/web/lib/api.ts +70 -0
- package/studio/web/lib/audio.ts +39 -0
- package/studio/web/lib/avatars.ts +41 -0
- package/studio/web/lib/calendar.ts +218 -0
- package/studio/web/lib/caption-position.ts +249 -0
- package/studio/web/lib/carousel.ts +24 -0
- package/studio/web/lib/chime.ts +42 -0
- package/studio/web/lib/clone-voice.ts +55 -0
- package/studio/web/lib/export.ts +11 -0
- package/studio/web/lib/files.ts +8 -0
- package/studio/web/lib/format.ts +93 -0
- package/studio/web/lib/media.ts +29 -0
- package/studio/web/lib/mic-device.ts +72 -0
- package/studio/web/lib/missing-dms.ts +70 -0
- package/studio/web/lib/omni-cards.ts +42 -0
- package/studio/web/lib/omni-cascade.ts +1067 -0
- package/studio/web/lib/omni-greeting-audio.ts +24 -0
- package/studio/web/lib/omni-hotword.ts +231 -0
- package/studio/web/lib/omni-panel.ts +67 -0
- package/studio/web/lib/omni-realtime.ts +811 -0
- package/studio/web/lib/omni-ui.ts +402 -0
- package/studio/web/lib/omni-wait.ts +174 -0
- package/studio/web/lib/omnichat-api.ts +44 -0
- package/studio/web/lib/orb.ts +270 -0
- package/studio/web/lib/pcm-recorder.ts +115 -0
- package/studio/web/lib/platforms.ts +17 -0
- package/studio/web/lib/providers.ts +27 -0
- package/studio/web/lib/publish-draft.ts +52 -0
- package/studio/web/lib/publish-settings.ts +81 -0
- package/studio/web/lib/query-client.ts +122 -0
- package/studio/web/lib/references.ts +13 -0
- package/studio/web/lib/services.ts +40 -0
- package/studio/web/lib/sessions.ts +103 -0
- package/studio/web/lib/settings-categories.ts +58 -0
- package/studio/web/lib/sound-audio.ts +33 -0
- package/studio/web/lib/sound-timeline.ts +291 -0
- package/studio/web/lib/sse.ts +86 -0
- package/studio/web/lib/stage-history.ts +141 -0
- package/studio/web/lib/stages.ts +344 -0
- package/studio/web/lib/studio-offline.ts +60 -0
- package/studio/web/lib/upload.ts +24 -0
- package/studio/web/lib/video-tabs.ts +118 -0
- package/studio/web/lib/voice-profile-draft.ts +34 -0
- package/studio/web/lib/voice-profiles.ts +3 -0
- package/studio/web/main.tsx +14 -0
- package/studio/web/pages/AdminPage/index.tsx +123 -0
- package/studio/web/pages/AgentPage/components/Measurements.tsx +102 -0
- package/studio/web/pages/AgentPage/index.tsx +28 -0
- package/studio/web/pages/AnalyticsPage/components/About.tsx +52 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelCards.tsx +106 -0
- package/studio/web/pages/AnalyticsPage/components/ChannelView.tsx +137 -0
- package/studio/web/pages/AnalyticsPage/components/CollectionStatus.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/Comparison.tsx +68 -0
- package/studio/web/pages/AnalyticsPage/components/Diagnosis.tsx +50 -0
- package/studio/web/pages/AnalyticsPage/components/Highlights.tsx +49 -0
- package/studio/web/pages/AnalyticsPage/components/Hint.tsx +11 -0
- package/studio/web/pages/AnalyticsPage/components/HookVsBody.tsx +100 -0
- package/studio/web/pages/AnalyticsPage/components/HourlyWave.tsx +133 -0
- package/studio/web/pages/AnalyticsPage/components/Insights.tsx +70 -0
- package/studio/web/pages/AnalyticsPage/components/MetricCard.tsx +46 -0
- package/studio/web/pages/AnalyticsPage/components/PlanSection.tsx +40 -0
- package/studio/web/pages/AnalyticsPage/components/ProgressionChart.tsx +155 -0
- package/studio/web/pages/AnalyticsPage/components/ReelBarsChart.tsx +154 -0
- package/studio/web/pages/AnalyticsPage/components/ReelThumb.tsx +19 -0
- package/studio/web/pages/AnalyticsPage/components/ReelView.tsx +290 -0
- package/studio/web/pages/AnalyticsPage/components/ReelsTable.tsx +269 -0
- package/studio/web/pages/AnalyticsPage/components/RequestWithFocus.tsx +38 -0
- package/studio/web/pages/AnalyticsPage/components/SegmentedControl.tsx +35 -0
- package/studio/web/pages/AnalyticsPage/components/VsMedian.tsx +31 -0
- package/studio/web/pages/AnalyticsPage/index.tsx +17 -0
- package/studio/web/pages/GettingStartedPage/index.tsx +174 -0
- package/studio/web/pages/NewVideoPage/components/DeliverablesPicker.tsx +62 -0
- package/studio/web/pages/NewVideoPage/components/FormatPicker.tsx +33 -0
- package/studio/web/pages/NewVideoPage/index.tsx +133 -0
- package/studio/web/pages/NotFoundPage/index.tsx +9 -0
- package/studio/web/pages/OmnichatPage/components/NewFromLink.tsx +59 -0
- package/studio/web/pages/OmnichatPage/components/RuleListItem.tsx +64 -0
- package/studio/web/pages/OmnichatPage/components/RulePreview.tsx +14 -0
- package/studio/web/pages/OmnichatPage/components/RuleView.tsx +88 -0
- package/studio/web/pages/OmnichatPage/index.tsx +153 -0
- package/studio/web/pages/QueuePage/index.tsx +22 -0
- package/studio/web/pages/ReferencePage/components/ReferenceTexts.tsx +131 -0
- package/studio/web/pages/ReferencePage/index.tsx +216 -0
- package/studio/web/pages/ReferencesPage/components/NewReferenceForm.tsx +150 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceCard.tsx +42 -0
- package/studio/web/pages/ReferencesPage/components/ReferenceGridSkeleton.tsx +31 -0
- package/studio/web/pages/ReferencesPage/index.tsx +67 -0
- package/studio/web/pages/SchedulePage/components/CalendarSkeleton.tsx +18 -0
- package/studio/web/pages/SchedulePage/components/DayView.tsx +177 -0
- package/studio/web/pages/SchedulePage/components/HourPicker.tsx +103 -0
- package/studio/web/pages/SchedulePage/components/MonthDayCell.tsx +111 -0
- package/studio/web/pages/SchedulePage/components/MonthView.tsx +47 -0
- package/studio/web/pages/SchedulePage/components/PlatformIcons.tsx +12 -0
- package/studio/web/pages/SchedulePage/components/PostThumb.tsx +15 -0
- package/studio/web/pages/SchedulePage/components/WeekColumn.tsx +75 -0
- package/studio/web/pages/SchedulePage/components/WeekView.tsx +35 -0
- package/studio/web/pages/SchedulePage/index.tsx +285 -0
- package/studio/web/pages/SettingsPage/components/AgentAccounts.tsx +263 -0
- package/studio/web/pages/SettingsPage/components/AgentCategory.tsx +20 -0
- package/studio/web/pages/SettingsPage/components/ModelPicker.tsx +49 -0
- package/studio/web/pages/SettingsPage/components/ModelsSettings.tsx +138 -0
- package/studio/web/pages/SettingsPage/components/PlatformsCategory.tsx +23 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AccountStatus.tsx +29 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/AutoPublishPanel.tsx +90 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/BrowserConnect.tsx +62 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/CheckField.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/InstagramPanel.tsx +113 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/OmnichatSettingsPanel.tsx +146 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SaveBar.tsx +33 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SchedulePanel.tsx +132 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCard.tsx +47 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/SettingsCardGroup.tsx +19 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TextPanel.tsx +55 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/TiktokPanel.tsx +123 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/YoutubePanel.tsx +100 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/badges.tsx +15 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/index.tsx +40 -0
- package/studio/web/pages/SettingsPage/components/PublishingCategory/types.ts +10 -0
- package/studio/web/pages/SettingsPage/components/UsageCategory.tsx +389 -0
- package/studio/web/pages/SettingsPage/components/VoiceProvidersCategory.tsx +97 -0
- package/studio/web/pages/SettingsPage/index.tsx +85 -0
- package/studio/web/pages/VideoPage/components/AudioPlayer.tsx +113 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/AxisField.tsx +50 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionList.tsx +56 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionListItem.tsx +92 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionMargins.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionStyleFields.tsx +70 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/CaptionTextForm.tsx +87 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/ColorField.tsx +37 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/MarginField.tsx +59 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/NumberField.tsx +57 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/PositionControls.tsx +140 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/captionEditor.ts +215 -0
- package/studio/web/pages/VideoPage/components/CaptionPositionEditor/useCaptionPosition.ts +154 -0
- package/studio/web/pages/VideoPage/components/CarouselChangeRequest.tsx +72 -0
- package/studio/web/pages/VideoPage/components/CarouselCompositionStage.tsx +80 -0
- package/studio/web/pages/VideoPage/components/CarouselCreate.tsx +63 -0
- package/studio/web/pages/VideoPage/components/CarouselMissing.tsx +19 -0
- package/studio/web/pages/VideoPage/components/CarouselPublishStage.tsx +173 -0
- package/studio/web/pages/VideoPage/components/CarouselScriptStage.tsx +82 -0
- package/studio/web/pages/VideoPage/components/CarouselSlideCard.tsx +49 -0
- package/studio/web/pages/VideoPage/components/CarouselViewer.tsx +55 -0
- package/studio/web/pages/VideoPage/components/ChangedVoices.tsx +53 -0
- package/studio/web/pages/VideoPage/components/CompositionStage.tsx +78 -0
- package/studio/web/pages/VideoPage/components/CoverPicker.tsx +32 -0
- package/studio/web/pages/VideoPage/components/EditorStage.tsx +53 -0
- package/studio/web/pages/VideoPage/components/LineTakes.tsx +160 -0
- package/studio/web/pages/VideoPage/components/LineTextEditor.tsx +124 -0
- package/studio/web/pages/VideoPage/components/LineVoicePicker.tsx +37 -0
- package/studio/web/pages/VideoPage/components/MediaImage.tsx +25 -0
- package/studio/web/pages/VideoPage/components/MotionScriptStage.tsx +39 -0
- package/studio/web/pages/VideoPage/components/NarrationStage.tsx +70 -0
- package/studio/web/pages/VideoPage/components/PublishForm.tsx +387 -0
- package/studio/web/pages/VideoPage/components/PublishStage.tsx +76 -0
- package/studio/web/pages/VideoPage/components/PublishText.tsx +149 -0
- package/studio/web/pages/VideoPage/components/ScenesApprovalPanel.tsx +278 -0
- package/studio/web/pages/VideoPage/components/ScheduledInfo.tsx +72 -0
- package/studio/web/pages/VideoPage/components/ScriptApprovalPanel.tsx +189 -0
- package/studio/web/pages/VideoPage/components/ScriptStage.tsx +17 -0
- package/studio/web/pages/VideoPage/components/SequencePlayer.tsx +146 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AddSound.tsx +117 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/AreaSelection.tsx +74 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedPanel.tsx +94 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/BedRow.tsx +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionOverlay.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionSaveBar.tsx +32 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CaptionsPanel.tsx +22 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipBlock.tsx +111 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/ClipPanel.tsx +76 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/CutsPanel.tsx +44 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EditorTabBar.tsx +73 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectChoice.tsx +46 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectItem.tsx +89 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectPanel.tsx +232 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/EffectsRow.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Lane.tsx +39 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MarkerRow.tsx +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/MuteButton.tsx +36 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/NumberInput.tsx +37 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlanWarnings.tsx +19 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PlayerResizeHandle.tsx +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/PreviewControls.tsx +51 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SceneRow.tsx +54 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SettingsPanel.tsx +65 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundLibrary.tsx +99 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SoundPreview.tsx +82 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/SpeedPanel.tsx +128 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineDock.tsx +56 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineFooter.tsx +26 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineSkeleton.tsx +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineToolbar.tsx +160 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TimelineTracks.tsx +121 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/TrackSidebar.tsx +30 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/VoiceRow.tsx +53 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/Waveform.tsx +97 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/clipActions.ts +50 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/effectActions.ts +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/index.tsx +161 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/timelineGeometry.ts +45 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/types.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useAutosave.ts +107 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useEditorShortcuts.ts +168 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFitHeight.ts +40 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useFollowPlayhead.ts +21 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useListenMix.ts +43 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayback.ts +231 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/usePlayerWidth.ts +27 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundData.ts +124 -0
- package/studio/web/pages/VideoPage/components/SoundTimeline/useSoundTimeline.ts +511 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/CompareVersions.tsx +111 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionCard.tsx +81 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionMedia.tsx +24 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/VersionText.tsx +15 -0
- package/studio/web/pages/VideoPage/components/StageDrawer/index.tsx +109 -0
- package/studio/web/pages/VideoPage/components/StageProcess.tsx +126 -0
- package/studio/web/pages/VideoPage/components/StageResult.tsx +69 -0
- package/studio/web/pages/VideoPage/components/SwapReference.tsx +92 -0
- package/studio/web/pages/VideoPage/components/ThumbnailPanel.tsx +252 -0
- package/studio/web/pages/VideoPage/components/TimingPanel.tsx +89 -0
- package/studio/web/pages/VideoPage/components/VideoPlayer.tsx +18 -0
- package/studio/web/pages/VideoPage/components/VideoSkeleton.tsx +50 -0
- package/studio/web/pages/VideoPage/components/VideoVoiceInfo.tsx +33 -0
- package/studio/web/pages/VideoPage/components/VideoVoicePicker.tsx +165 -0
- package/studio/web/pages/VideoPage/components/VoicePauseBanner.tsx +56 -0
- package/studio/web/pages/VideoPage/components/WithLogo.tsx +10 -0
- package/studio/web/pages/VideoPage/index.tsx +295 -0
- package/studio/web/pages/VideosPage/components/PublishedOn.tsx +85 -0
- package/studio/web/pages/VideosPage/components/ServicesPanel.tsx +81 -0
- package/studio/web/pages/VideosPage/components/SessionsPanel.tsx +62 -0
- package/studio/web/pages/VideosPage/components/VideoListSkeleton.tsx +25 -0
- package/studio/web/pages/VideosPage/components/VideoRow.tsx +122 -0
- package/studio/web/pages/VideosPage/index.tsx +134 -0
- package/studio/web/pages/VoicePage/index.tsx +28 -0
- package/studio/web/router.tsx +201 -0
- package/studio/web/styles/base/elements.css +55 -0
- package/studio/web/styles/base/utilities.css +25 -0
- package/studio/web/styles/components/badge.css +33 -0
- package/studio/web/styles/components/claude-running.css +27 -0
- package/studio/web/styles/components/claude-session.css +212 -0
- package/studio/web/styles/components/claude-walking.css +92 -0
- package/studio/web/styles/components/clone-voice-save.css +136 -0
- package/studio/web/styles/components/clone-voice.css +379 -0
- package/studio/web/styles/components/controls.css +70 -0
- package/studio/web/styles/components/data-and-image.css +54 -0
- package/studio/web/styles/components/forms.css +132 -0
- package/studio/web/styles/components/human-banner.css +99 -0
- package/studio/web/styles/components/lightbox.css +50 -0
- package/studio/web/styles/components/markdown.css +68 -0
- package/studio/web/styles/components/modal.css +70 -0
- package/studio/web/styles/components/omni-cards.css +105 -0
- package/studio/web/styles/components/omni.css +859 -0
- package/studio/web/styles/components/omnichat.css +538 -0
- package/studio/web/styles/components/panel.css +115 -0
- package/studio/web/styles/components/platform-card.css +140 -0
- package/studio/web/styles/components/provider-card.css +132 -0
- package/studio/web/styles/components/queue.css +185 -0
- package/studio/web/styles/components/reference-actions.css +133 -0
- package/studio/web/styles/components/reference-picker.css +146 -0
- package/studio/web/styles/components/results-drawer.css +224 -0
- package/studio/web/styles/components/segmented.css +115 -0
- package/studio/web/styles/components/side-panel-tab.css +23 -0
- package/studio/web/styles/components/status-signals.css +66 -0
- package/studio/web/styles/components/stepper.css +208 -0
- package/studio/web/styles/components/table.css +19 -0
- package/studio/web/styles/components/tabs.css +24 -0
- package/studio/web/styles/components/ui/accordion.css +71 -0
- package/studio/web/styles/components/ui/chart.css +162 -0
- package/studio/web/styles/components/ui/checkbox.css +37 -0
- package/studio/web/styles/components/ui/date-picker.css +153 -0
- package/studio/web/styles/components/ui/select.css +110 -0
- package/studio/web/styles/components/ui/skeleton.css +25 -0
- package/studio/web/styles/components/ui/slider.css +81 -0
- package/studio/web/styles/components/ui/switch.css +41 -0
- package/studio/web/styles/components/ui/tooltip.css +24 -0
- package/studio/web/styles/components/voice-carousel.css +255 -0
- package/studio/web/styles/components/voice-editor.css +179 -0
- package/studio/web/styles/components/voice-grid.css +56 -0
- package/studio/web/styles/components/voice-profiles.css +192 -0
- package/studio/web/styles/design-system.md +136 -0
- package/studio/web/styles/index.css +116 -0
- package/studio/web/styles/layout/page.css +41 -0
- package/studio/web/styles/layout/sidebar-groups.css +39 -0
- package/studio/web/styles/layout/sidebar.css +111 -0
- package/studio/web/styles/pages/agent.css +26 -0
- package/studio/web/styles/pages/analytics/dashboard.css +614 -0
- package/studio/web/styles/pages/analytics/insights.css +48 -0
- package/studio/web/styles/pages/getting-started.css +166 -0
- package/studio/web/styles/pages/new-video/form.css +32 -0
- package/studio/web/styles/pages/not-found.css +59 -0
- package/studio/web/styles/pages/references.css +204 -0
- package/studio/web/styles/pages/schedule/calendar.css +541 -0
- package/studio/web/styles/pages/schedule/chip-states.css +60 -0
- package/studio/web/styles/pages/settings/models.css +72 -0
- package/studio/web/styles/pages/settings/shell.css +361 -0
- package/studio/web/styles/pages/settings/usage.css +63 -0
- package/studio/web/styles/pages/studio-offline.css +105 -0
- package/studio/web/styles/pages/video/caption-controls.css +194 -0
- package/studio/web/styles/pages/video/captions-grid.css +70 -0
- package/studio/web/styles/pages/video/captions.css +79 -0
- package/studio/web/styles/pages/video/editor-chat.css +103 -0
- package/studio/web/styles/pages/video/export.css +50 -0
- package/studio/web/styles/pages/video/frames.css +29 -0
- package/studio/web/styles/pages/video/fullscreen-stage.css +400 -0
- package/studio/web/styles/pages/video/instagram-carousel.css +309 -0
- package/studio/web/styles/pages/video/layout.css +285 -0
- package/studio/web/styles/pages/video/narration.css +138 -0
- package/studio/web/styles/pages/video/preview-overview.css +11 -0
- package/studio/web/styles/pages/video/processing-notice.css +34 -0
- package/studio/web/styles/pages/video/publish-when.css +76 -0
- package/studio/web/styles/pages/video/publish.css +97 -0
- package/studio/web/styles/pages/video/result.css +96 -0
- package/studio/web/styles/pages/video/scenes.css +167 -0
- package/studio/web/styles/pages/video/sound-timeline.css +672 -0
- package/studio/web/styles/pages/video/sound-toolbar.css +149 -0
- package/studio/web/styles/pages/video/take-player.css +100 -0
- package/studio/web/styles/pages/video/thumbnail.css +157 -0
- package/studio/web/styles/pages/video/timeline.css +117 -0
- package/studio/web/styles/pages/video/voice-picker.css +14 -0
- package/studio/web/styles/pages/video-list/active-row.css +27 -0
- package/studio/web/styles/pages/video-list/card-link.css +49 -0
- package/studio/web/styles/pages/video-list/list.css +86 -0
- package/studio/web/styles/theme/identity/details.css +204 -0
- package/studio/web/styles/theme/identity/shell.css +249 -0
- package/studio/web/styles/theme/identity/surfaces.css +183 -0
- package/studio/web/styles/theme/identity/titles-and-buttons.css +120 -0
- package/studio/web/styles/theme/no-borders/blocks.css +208 -0
- package/studio/web/styles/theme/no-borders/controls.css +256 -0
- package/studio/web/styles/tokens.css +245 -0
- package/studio/web/types/api.ts +2 -0
- package/studio/web/types/assets.d.ts +9 -0
- package/templates/brief.md +27 -0
- package/templates/captions.html +204 -0
- package/templates/carousel-composition.md +47 -0
- package/templates/carousel-script.md +60 -0
- package/templates/components/voiceavatar/README.md +87 -0
- package/templates/components/voiceavatar/demo.html +50 -0
- package/templates/components/voiceavatar/voiceavatar.js +415 -0
- package/templates/motion.md +80 -0
- package/templates/playbook.md +43 -0
- package/templates/reference.md +123 -0
- package/templates/scene.html +112 -0
- package/templates/scenes.example.json +96 -0
- package/templates/script.md +63 -0
- package/templates/slide.html +71 -0
- package/templates/wireframe.html +91 -0
- package/tools/analysis.mjs +300 -0
- package/tools/approval.mjs +442 -0
- package/tools/assemble.mjs +942 -0
- package/tools/build-motion.mjs +437 -0
- package/tools/captions.mjs +246 -0
- package/tools/carousel.mjs +558 -0
- package/tools/compose.mjs +307 -0
- package/tools/cuts.mjs +74 -0
- package/tools/editor.mjs +419 -0
- package/tools/epidemic-capture.js +54 -0
- package/tools/fanout.mjs +69 -0
- package/tools/history.mjs +70 -0
- package/tools/history.py +61 -0
- package/tools/job-queue.mjs +180 -0
- package/tools/job_queue.py +430 -0
- package/tools/lib/agents.mjs +412 -0
- package/tools/lib/channel.mjs +399 -0
- package/tools/lib/claude-settings.mjs +67 -0
- package/tools/lib/cli.mjs +9 -0
- package/tools/lib/fanout.mjs +234 -0
- package/tools/lib/http.mjs +94 -0
- package/tools/lib/index.js +14 -0
- package/tools/lib/mcp-server.mjs +69 -0
- package/tools/lib/metrics/metrics.mjs +204 -0
- package/tools/lib/narration.mjs +15 -0
- package/tools/lib/oauth-client.mjs +295 -0
- package/tools/lib/omnichat/config.mjs +139 -0
- package/tools/lib/omnichat/errors.mjs +42 -0
- package/tools/lib/omnichat/extract.mjs +82 -0
- package/tools/lib/omnichat/gate.mjs +151 -0
- package/tools/lib/omnichat/manual.mjs +166 -0
- package/tools/lib/omnichat/match.mjs +78 -0
- package/tools/lib/omnichat/pass.mjs +393 -0
- package/tools/lib/omnichat/record.mjs +208 -0
- package/tools/lib/omnichat/text.mjs +315 -0
- package/tools/lib/omnichat/webhook.mjs +166 -0
- package/tools/lib/pairing.mjs +99 -0
- package/tools/lib/paths.mjs +41 -0
- package/tools/lib/platforms/instagram.mjs +469 -0
- package/tools/lib/platforms/tiktok.mjs +343 -0
- package/tools/lib/platforms/youtube.mjs +228 -0
- package/tools/lib/publish/publish.mjs +244 -0
- package/tools/lib/schedule/schedule.mjs +191 -0
- package/tools/lib/service.mjs +134 -0
- package/tools/lib/skill-client.mjs +126 -0
- package/tools/lib/skills-release.mjs +196 -0
- package/tools/lib/testing.mjs +52 -0
- package/tools/lib/up.mjs +187 -0
- package/tools/metrics.mjs +415 -0
- package/tools/models.mjs +134 -0
- package/tools/narrate.mjs +257 -0
- package/tools/omni.mjs +298 -0
- package/tools/omni_paths.py +12 -0
- package/tools/omnichat.mjs +1577 -0
- package/tools/omnivideo.py +1122 -0
- package/tools/package.mjs +130 -0
- package/tools/platforms.mjs +236 -0
- package/tools/premiere.mjs +533 -0
- package/tools/publish.mjs +1496 -0
- package/tools/reference.mjs +1408 -0
- package/tools/render.mjs +426 -0
- package/tools/runner.mjs +156 -0
- package/tools/setup.mjs +466 -0
- package/tools/skills-release.mjs +93 -0
- package/tools/sound.mjs +1323 -0
- package/tools/soundtrack.mjs +217 -0
- package/tools/thumbnail.mjs +271 -0
- package/tools/timing.mjs +108 -0
- package/tools/usage.py +628 -0
- package/tools/voice-envelope.mjs +185 -0
- package/tools/voice.py +448 -0
- package/tools/voice_sample.py +75 -0
- package/tools/wireframe.mjs +230 -0
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
Assembly and export with ffmpeg: the whole video, ready to upload.
|
|
4
|
+
|
|
5
|
+
node tools/assemble.mjs videos/<slug> assembles and exports export/<slug>.mp4
|
|
6
|
+
node tools/assemble.mjs videos/<slug> --sheet only the captions sheet over the scenes (no video)
|
|
7
|
+
--captions | --no-captions burns the captions or not (default: burns, unless
|
|
8
|
+
`captions_in_motion: true` in scenes.json)
|
|
9
|
+
|
|
10
|
+
Speed (`speed` at the root of scenes.json, 1 to 1.5, set in the studio editor): after the base
|
|
11
|
+
export at 100% (export/<slug>.mp4, the one the editor shows), a second pass writes
|
|
12
|
+
export/<slug>-speed-110.mp4 and assembly.json points to it (that's what publish uploads).
|
|
13
|
+
The picture and the voice (with the effects) speed up together, voice without changing pitch;
|
|
14
|
+
the bed does not (see below). No speed: the base export is the deliverable.
|
|
15
|
+
|
|
16
|
+
Area cuts (`cuts` in scenes.json, the cut tool in the studio editor;
|
|
17
|
+
tools/cuts.mjs): the ranges leave the export at the end, with image,
|
|
18
|
+
captions and sound already assembled, and the rest is joined (10 ms sound
|
|
19
|
+
fade at each join). Voice, render and sound/ don't change: cutting a
|
|
20
|
+
silence is just assembling again. assembly.json keeps the export's cuts.
|
|
21
|
+
The bed (background music) is isolated: neither the cuts nor the speed touch it. It plays
|
|
22
|
+
straight through on the final timeline, at its own pace, ducked by the voice where the voice
|
|
23
|
+
now is (tools/sound.mjs, finalClock).
|
|
24
|
+
|
|
25
|
+
Shifted animation (`scene.video_offset`, dragged in the editor;
|
|
26
|
+
tools/soundtrack.mjs): each scene's image enters at `scene.start +
|
|
27
|
+
video_offset`, on a single track (the one that started last covers; in a
|
|
28
|
+
gap, it holds the last frame). The voice doesn't move; beat effects move
|
|
29
|
+
with the animation.
|
|
30
|
+
|
|
31
|
+
What goes in, at the times scenes.json already has:
|
|
32
|
+
- V: the scene MP4s joined, each at its `scene.start`;
|
|
33
|
+
- captions: captions.srt drawn in HTML (templates/captions.html, plus the
|
|
34
|
+
video's motion/src/_captions.css, if any), one transparent PNG per
|
|
35
|
+
caption, overlaid from its start to its end. The position (platform
|
|
36
|
+
safe area, 3×3 grid anchor, x/y; video → scene → caption) is
|
|
37
|
+
`captions` in scenes.json, the same the studio edits (tools/captions.mjs);
|
|
38
|
+
- A: each line at `scene.start + line.start`, the beat and transition
|
|
39
|
+
effects and the bed from sound.mjs (already at the level relative to the
|
|
40
|
+
voice and with ducking applied), mixed and normalized in two passes to
|
|
41
|
+
`assembly.lufs` (YouTube: −14 LUFS).
|
|
42
|
+
|
|
43
|
+
Writes export/<slug>.mp4, export/<slug>-sheet.png (one frame per scene,
|
|
44
|
+
from the MP4 itself) and export/assembly.json. Refuses to start if
|
|
45
|
+
anything is missing: scene MP4 with wrong duration, line without audio or
|
|
46
|
+
position, missing captions.srt, effect that doesn't exist. Premiere is
|
|
47
|
+
optional (premiere.mjs assemble, to edit by hand).
|
|
48
|
+
|
|
49
|
+
Waits for its turn in the machine queue (tools/job-queue.mjs).
|
|
50
|
+
============================================================================ */
|
|
51
|
+
|
|
52
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync, readdirSync, statSync, utimesSync } from "node:fs";
|
|
53
|
+
import { spawnSync } from "node:child_process";
|
|
54
|
+
import { join, resolve, dirname } from "node:path";
|
|
55
|
+
import { fileURLToPath } from "node:url";
|
|
56
|
+
import { tmpdir } from "node:os";
|
|
57
|
+
import { loadVideo } from "./timing.mjs";
|
|
58
|
+
import { prepareSound, planSound, finalClock, sanitizeSpeed, mixGraph, lineInputs } from "./sound.mjs";
|
|
59
|
+
import { turn } from "./job-queue.mjs";
|
|
60
|
+
import { isNarrated } from "./lib/narration.mjs";
|
|
61
|
+
import { keepPrevious } from "./history.mjs";
|
|
62
|
+
import { captionsOf, captionsHtml } from "./captions.mjs";
|
|
63
|
+
import { normalizeCuts, keptSegments, removedDuration, toEdited } from "./cuts.mjs";
|
|
64
|
+
import {
|
|
65
|
+
videoTrack,
|
|
66
|
+
videoEdited,
|
|
67
|
+
voiceEdited,
|
|
68
|
+
animationStart,
|
|
69
|
+
videoClips,
|
|
70
|
+
lineClips,
|
|
71
|
+
voiceSpans,
|
|
72
|
+
} from "./soundtrack.mjs";
|
|
73
|
+
import { CODE_ROOT, DATA_ROOT as ROOT } from "./lib/paths.mjs";
|
|
74
|
+
|
|
75
|
+
const CFG = JSON.parse(readFileSync(join(ROOT, "omnivideo.config.json"), "utf8"));
|
|
76
|
+
const A = { lufs: -14, peak_db: -1, lra: 11, crf: 17, audio_kbps: 320, ...(CFG.assembly ?? {}) };
|
|
77
|
+
const RATE = 48000;
|
|
78
|
+
|
|
79
|
+
const args = process.argv.slice(2);
|
|
80
|
+
const has = n => args.includes(`--${n}`);
|
|
81
|
+
const dir = resolve(args[0] ?? "");
|
|
82
|
+
/* "Sem narração e voz": no voice, no captions, and the sound is not leveled (only effects and the bed) */
|
|
83
|
+
const SILENT = !isNarrated(dir);
|
|
84
|
+
function fail(msg) {
|
|
85
|
+
console.error(`erro: ${msg}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
if (!args[0] || !existsSync(join(dir, "scenes.json"))) {
|
|
89
|
+
const source = readFileSync(fileURLToPath(import.meta.url), "utf8").split("\n");
|
|
90
|
+
console.log(
|
|
91
|
+
source
|
|
92
|
+
.slice(
|
|
93
|
+
1,
|
|
94
|
+
source.findIndex((l, i) => i > 1 && l.includes("=====*/")),
|
|
95
|
+
)
|
|
96
|
+
.join("\n"),
|
|
97
|
+
);
|
|
98
|
+
process.exit(2);
|
|
99
|
+
}
|
|
100
|
+
function run(bin, a, label = bin) {
|
|
101
|
+
const r = spawnSync(bin, a, { encoding: "utf8", maxBuffer: 1 << 26 });
|
|
102
|
+
if (r.status !== 0) fail(`${label}: ${(r.stderr || r.stdout).slice(-800)}`);
|
|
103
|
+
return r;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function duration(file) {
|
|
107
|
+
const r = spawnSync("ffprobe", ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", file], {
|
|
108
|
+
encoding: "utf8",
|
|
109
|
+
});
|
|
110
|
+
return r.status === 0 ? +r.stdout.trim() : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* before the editor owned the speed, the export panel kept it in assembly.json: a video that
|
|
114
|
+
never chose one in the editor (no `speed` in scenes.json) keeps that one */
|
|
115
|
+
function legacySpeed() {
|
|
116
|
+
try {
|
|
117
|
+
return JSON.parse(readFileSync(join(dir, "export", "assembly.json"), "utf8")).speed;
|
|
118
|
+
} catch {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* --- what must exist first ------------------------------------------------ */
|
|
124
|
+
function check(video, withCaptions) {
|
|
125
|
+
const { fps } = video.format;
|
|
126
|
+
const problems = [];
|
|
127
|
+
for (const scene of video.scenes) {
|
|
128
|
+
const mp4 = join(dir, scene.mp4 ?? `motion/${scene.id}.mp4`);
|
|
129
|
+
if (scene.duration == null) problems.push(`${scene.id}: sem duração — rode omnivideo.py timing`);
|
|
130
|
+
else if (!existsSync(mp4))
|
|
131
|
+
problems.push(`${scene.id}: ${scene.mp4} não existe — renderize (build-motion.mjs --render)`);
|
|
132
|
+
else {
|
|
133
|
+
const d = duration(mp4);
|
|
134
|
+
if (d == null || Math.abs(d - scene.duration) > 1.5 / fps)
|
|
135
|
+
problems.push(
|
|
136
|
+
`${scene.id}: ${scene.mp4} tem ${d?.toFixed(3)}s, a cena pede ${scene.duration}s — renderize de novo`,
|
|
137
|
+
);
|
|
138
|
+
const reg = join(dir, "motion", `${scene.id}.render.json`);
|
|
139
|
+
const r = existsSync(reg) ? JSON.parse(readFileSync(reg, "utf8")) : null;
|
|
140
|
+
if (r?.video_time && Math.abs(r.start - scene.start) > 1e-3) {
|
|
141
|
+
problems.push(
|
|
142
|
+
`${scene.id}: renderizada começando em ${r.start}s, agora começa em ${scene.start}s; o fundo anda no tempo do vídeo e pularia no corte — renderize de novo`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const line of scene.lines ?? []) {
|
|
147
|
+
if (!line.wav || !existsSync(join(dir, line.wav)))
|
|
148
|
+
problems.push(`${line.id}: sem áudio — rode omnivideo.py voice`);
|
|
149
|
+
if (line.start == null) problems.push(`${line.id}: sem posição — rode omnivideo.py timing`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!SILENT && !existsSync(join(dir, "captions.srt")))
|
|
153
|
+
problems.push("captions.srt não existe — rode omnivideo.py captions");
|
|
154
|
+
if (withCaptions && !existsSync(join(CODE_ROOT, "templates", "captions.html")))
|
|
155
|
+
problems.push("templates/captions.html não existe");
|
|
156
|
+
if (problems.length) fail("a montagem não pode começar:\n " + problems.join("\n "));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* --- captions --------------------------------------------------------------------- */
|
|
160
|
+
/* captions.html (tools/captions.mjs: data, position and the video's _captions.css); one
|
|
161
|
+
transparent PNG per caption */
|
|
162
|
+
function captionFrames(video, captions) {
|
|
163
|
+
const { w, h } = video.format;
|
|
164
|
+
const capDir = join(dir, "captions");
|
|
165
|
+
rmSync(join(capDir, "frames"), { recursive: true, force: true });
|
|
166
|
+
mkdirSync(capDir, { recursive: true });
|
|
167
|
+
const { html, pos, css } = captionsHtml(dir, video, captions);
|
|
168
|
+
const file = join(capDir, "captions.html");
|
|
169
|
+
writeFileSync(file, html);
|
|
170
|
+
const mids = captions.map(c => +((c.s + c.e) / 2).toFixed(4));
|
|
171
|
+
run(
|
|
172
|
+
"node",
|
|
173
|
+
[
|
|
174
|
+
join(CODE_ROOT, "tools", "render.mjs"),
|
|
175
|
+
file,
|
|
176
|
+
"--frames",
|
|
177
|
+
join(capDir, "frames"),
|
|
178
|
+
"--at",
|
|
179
|
+
mids.join(","),
|
|
180
|
+
"--w",
|
|
181
|
+
String(w),
|
|
182
|
+
"--h",
|
|
183
|
+
String(h),
|
|
184
|
+
"--alpha",
|
|
185
|
+
],
|
|
186
|
+
"render da legenda",
|
|
187
|
+
);
|
|
188
|
+
const pngs = readdirSync(join(capDir, "frames"))
|
|
189
|
+
.filter(f => f.endsWith(".png"))
|
|
190
|
+
.sort()
|
|
191
|
+
.map(f => join(capDir, "frames", f));
|
|
192
|
+
if (pngs.length !== captions.length) fail(`a legenda rendeu ${pngs.length} quadros para ${captions.length} legendas`);
|
|
193
|
+
return { pngs, style: pos.style, platform: pos.platform, anchor: pos.anchor, css };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* caption track as a slideshow: a transparent PNG in the gaps, each caption
|
|
197
|
+
from the frame where it starts to the frame where it ends (on the fps grid) */
|
|
198
|
+
function captionTrack(captions, pngs, total, fps, w, h, tmp) {
|
|
199
|
+
const empty = join(tmp, "empty.png");
|
|
200
|
+
run("ffmpeg", [
|
|
201
|
+
"-y",
|
|
202
|
+
"-loglevel",
|
|
203
|
+
"error",
|
|
204
|
+
"-f",
|
|
205
|
+
"lavfi",
|
|
206
|
+
"-i",
|
|
207
|
+
`color=c=black@0:s=${w}x${h},format=rgba`,
|
|
208
|
+
"-frames:v",
|
|
209
|
+
"1",
|
|
210
|
+
empty,
|
|
211
|
+
]);
|
|
212
|
+
const end = Math.round(total * fps);
|
|
213
|
+
const rows = ["ffconcat version 1.0"];
|
|
214
|
+
const add = (file, frames) => {
|
|
215
|
+
if (frames > 0) rows.push(`file '${file}'`, `duration ${(frames / fps).toFixed(6)}`);
|
|
216
|
+
};
|
|
217
|
+
let cursor = 0;
|
|
218
|
+
captions.forEach((c, i) => {
|
|
219
|
+
const a = Math.max(cursor, Math.round(c.s * fps));
|
|
220
|
+
const b = Math.min(end, Math.round(c.e * fps));
|
|
221
|
+
if (b <= a) return;
|
|
222
|
+
add(empty, a - cursor);
|
|
223
|
+
add(pngs[i], b - a);
|
|
224
|
+
cursor = b;
|
|
225
|
+
});
|
|
226
|
+
add(empty, end - cursor);
|
|
227
|
+
/* concat ignores the last entry's duration: repeat the file */
|
|
228
|
+
rows.push(`file '${rows.at(-2).slice(6, -1)}'`);
|
|
229
|
+
const list = join(tmp, "captions.ffconcat");
|
|
230
|
+
writeFileSync(list, rows.join("\n") + "\n");
|
|
231
|
+
return list;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* --- audio ------------------------------------------------------------------------ */
|
|
235
|
+
const PCM = ["-c:a", "pcm_s16le"];
|
|
236
|
+
|
|
237
|
+
/* voice and effects in scenes.json time, without the bed and without leveling: it is what the
|
|
238
|
+
cuts and the speed act on (the bed is isolated, see exportAudio) */
|
|
239
|
+
function premix(video, sound, total, tmp) {
|
|
240
|
+
const inputs = [];
|
|
241
|
+
for (const scene of video.scenes)
|
|
242
|
+
for (const l of scene.lines ?? []) inputs.push(...lineInputs(scene, l, join(dir, l.wav)));
|
|
243
|
+
for (const it of sound.items) inputs.push({ file: it.file, t: it.start });
|
|
244
|
+
const mixed = join(tmp, "premix.wav");
|
|
245
|
+
if (!inputs.length) {
|
|
246
|
+
run("ffmpeg", [
|
|
247
|
+
"-y",
|
|
248
|
+
"-loglevel",
|
|
249
|
+
"error",
|
|
250
|
+
"-f",
|
|
251
|
+
"lavfi",
|
|
252
|
+
"-i",
|
|
253
|
+
`anullsrc=r=${RATE}:cl=stereo`,
|
|
254
|
+
"-t",
|
|
255
|
+
String(total),
|
|
256
|
+
...PCM,
|
|
257
|
+
mixed,
|
|
258
|
+
]);
|
|
259
|
+
return mixed;
|
|
260
|
+
}
|
|
261
|
+
run(
|
|
262
|
+
"ffmpeg",
|
|
263
|
+
[
|
|
264
|
+
"-y",
|
|
265
|
+
"-loglevel",
|
|
266
|
+
"error",
|
|
267
|
+
...inputs.flatMap(e => ["-i", e.file]),
|
|
268
|
+
"-filter_complex",
|
|
269
|
+
mixGraph(inputs, total),
|
|
270
|
+
"-t",
|
|
271
|
+
String(total),
|
|
272
|
+
"-ar",
|
|
273
|
+
String(RATE),
|
|
274
|
+
...PCM,
|
|
275
|
+
mixed,
|
|
276
|
+
],
|
|
277
|
+
"mixagem",
|
|
278
|
+
);
|
|
279
|
+
return mixed;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* The export's sound: the premix with the cuts closed and the speed applied (atempo, no pitch
|
|
283
|
+
change), then the bed on top (already made for this speed by sound.mjs: it enters at its own
|
|
284
|
+
second of the final timeline, whole, never cut or sped up), then loudnorm. `tag` names the files. */
|
|
285
|
+
function exportAudio(premixFile, bed, { cuts, total, speed, finalDur, tmp, tag }) {
|
|
286
|
+
let edited = premixFile;
|
|
287
|
+
if (cuts.length || speed !== 1) {
|
|
288
|
+
edited = join(tmp, `edited-${tag}.wav`);
|
|
289
|
+
const g =
|
|
290
|
+
(cuts.length ? cutsAudio("[0:a]", keptSegments(cuts, total)) : "[0:a]anull[a]") +
|
|
291
|
+
(speed !== 1 ? `;[a]atempo=${speed},aresample=${RATE}[s]` : "");
|
|
292
|
+
run(
|
|
293
|
+
"ffmpeg",
|
|
294
|
+
[
|
|
295
|
+
"-y",
|
|
296
|
+
"-loglevel",
|
|
297
|
+
"error",
|
|
298
|
+
"-i",
|
|
299
|
+
premixFile,
|
|
300
|
+
"-filter_complex",
|
|
301
|
+
g,
|
|
302
|
+
"-map",
|
|
303
|
+
speed !== 1 ? "[s]" : "[a]",
|
|
304
|
+
"-ar",
|
|
305
|
+
String(RATE),
|
|
306
|
+
...PCM,
|
|
307
|
+
edited,
|
|
308
|
+
],
|
|
309
|
+
"cortes e velocidade do áudio",
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
let mixed = edited;
|
|
313
|
+
if (bed) {
|
|
314
|
+
mixed = join(tmp, `mixed-${tag}.wav`);
|
|
315
|
+
const inputs = [
|
|
316
|
+
{ file: edited, t: 0 },
|
|
317
|
+
{ file: bed.file, t: bed.start },
|
|
318
|
+
];
|
|
319
|
+
run(
|
|
320
|
+
"ffmpeg",
|
|
321
|
+
[
|
|
322
|
+
"-y",
|
|
323
|
+
"-loglevel",
|
|
324
|
+
"error",
|
|
325
|
+
...inputs.flatMap(e => ["-i", e.file]),
|
|
326
|
+
"-filter_complex",
|
|
327
|
+
mixGraph(inputs, finalDur),
|
|
328
|
+
"-t",
|
|
329
|
+
String(finalDur),
|
|
330
|
+
"-ar",
|
|
331
|
+
String(RATE),
|
|
332
|
+
...PCM,
|
|
333
|
+
mixed,
|
|
334
|
+
],
|
|
335
|
+
"cama",
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
/* a silent video's sound is only effects: loudnorm would raise them to the platform level, as if they were
|
|
339
|
+
a voice. With a bed (music) it levels the whole, as always. */
|
|
340
|
+
if (SILENT && !bed) return { mix: mixed, measured: null };
|
|
341
|
+
return normalize(mixed, finalDur, tmp, tag);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/* loudnorm in two passes: the first measures, the second applies linearly (no pumping) */
|
|
345
|
+
function normalize(mixed, total, tmp, tag) {
|
|
346
|
+
const target = `I=${A.lufs}:TP=${A.peak_db}:LRA=${A.lra}`;
|
|
347
|
+
const parseReport = r => JSON.parse(r.stderr.slice(r.stderr.lastIndexOf("{"), r.stderr.lastIndexOf("}") + 1));
|
|
348
|
+
const m = parseReport(
|
|
349
|
+
run(
|
|
350
|
+
"ffmpeg",
|
|
351
|
+
["-hide_banner", "-nostats", "-i", mixed, "-af", `loudnorm=${target}:print_format=json`, "-f", "null", "-"],
|
|
352
|
+
"loudnorm (medir)",
|
|
353
|
+
),
|
|
354
|
+
);
|
|
355
|
+
if (!Number.isFinite(+m.input_i)) return { mix: mixed, measured: null };
|
|
356
|
+
const norm = join(tmp, `audio-${tag}.wav`);
|
|
357
|
+
/* linear when possible; if the gain would clip the peak, loudnorm itself falls back to dynamic and says so in the report */
|
|
358
|
+
const n = parseReport(
|
|
359
|
+
run(
|
|
360
|
+
"ffmpeg",
|
|
361
|
+
[
|
|
362
|
+
"-y",
|
|
363
|
+
"-hide_banner",
|
|
364
|
+
"-nostats",
|
|
365
|
+
"-i",
|
|
366
|
+
mixed,
|
|
367
|
+
"-af",
|
|
368
|
+
`loudnorm=${target}:measured_I=${m.input_i}:measured_TP=${m.input_tp}:measured_LRA=${m.input_lra}:measured_thresh=${m.input_thresh}:offset=${m.target_offset}:linear=true:print_format=json,aresample=${RATE}`,
|
|
369
|
+
"-t",
|
|
370
|
+
String(total),
|
|
371
|
+
...PCM,
|
|
372
|
+
norm,
|
|
373
|
+
],
|
|
374
|
+
"loudnorm (aplicar)",
|
|
375
|
+
),
|
|
376
|
+
);
|
|
377
|
+
return {
|
|
378
|
+
mix: norm,
|
|
379
|
+
measured: {
|
|
380
|
+
before_lufs: +m.input_i,
|
|
381
|
+
before_peak_db: +m.input_tp,
|
|
382
|
+
after_lufs: +n.output_i,
|
|
383
|
+
after_peak_db: +n.output_tp,
|
|
384
|
+
lra: +n.output_lra,
|
|
385
|
+
mode: n.normalization_type,
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* --- sheet: one frame per scene, at a moment with a caption when there is one ------------- */
|
|
391
|
+
function moments(video, captions) {
|
|
392
|
+
const { fps } = video.format;
|
|
393
|
+
const last = Math.round(video.total_duration * fps) - 1;
|
|
394
|
+
return video.scenes.map(sc => {
|
|
395
|
+
const c = captions.find(x => x.e > sc.start + 0.1 && x.s < sc.start + sc.duration - 0.1);
|
|
396
|
+
const t = c ? (Math.max(c.s, sc.start) + Math.min(c.e, sc.start + sc.duration)) / 2 : sc.start + sc.duration / 2;
|
|
397
|
+
return { scene: sc, t: Math.min(Math.floor(t * fps + 1e-6), last) / fps, caption: c ? captions.indexOf(c) : -1 };
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function sheet(frames, out) {
|
|
402
|
+
const cols = Math.min(3, frames.length),
|
|
403
|
+
rows = Math.ceil(frames.length / cols);
|
|
404
|
+
const framesDir = dirname(frames[0]);
|
|
405
|
+
run(
|
|
406
|
+
"ffmpeg",
|
|
407
|
+
[
|
|
408
|
+
"-y",
|
|
409
|
+
"-loglevel",
|
|
410
|
+
"error",
|
|
411
|
+
"-framerate",
|
|
412
|
+
"1",
|
|
413
|
+
"-i",
|
|
414
|
+
join(framesDir, "f%03d.png"),
|
|
415
|
+
"-vf",
|
|
416
|
+
`scale=540:-1,tile=${cols}x${rows}:padding=8:margin=8:color=white`,
|
|
417
|
+
"-frames:v",
|
|
418
|
+
"1",
|
|
419
|
+
out,
|
|
420
|
+
],
|
|
421
|
+
"folha",
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* --- cuts: the kept ranges, joined -------------------------------------
|
|
426
|
+
trim/atrim of each range and concat. The picture and the sound (the premix: voice and
|
|
427
|
+
effects, never the bed) are cut apart; the sound gets a short fade at each join so the cut
|
|
428
|
+
doesn't click. Each returns a graph ending in [v] / [a]. */
|
|
429
|
+
const CUT_FADE = 0.01;
|
|
430
|
+
function cutsVideo(vIn, segs) {
|
|
431
|
+
const n = segs.length;
|
|
432
|
+
const g = [`${vIn}split=${n}${segs.map((_, i) => `[vs${i}]`).join("")}`];
|
|
433
|
+
segs.forEach(([a, b], i) =>
|
|
434
|
+
g.push(`[vs${i}]trim=start=${a.toFixed(4)}:end=${b.toFixed(4)},setpts=PTS-STARTPTS[v${i}]`),
|
|
435
|
+
);
|
|
436
|
+
g.push(`${segs.map((_, i) => `[v${i}]`).join("")}concat=n=${n}:v=1:a=0[v]`);
|
|
437
|
+
return g.join(";");
|
|
438
|
+
}
|
|
439
|
+
function cutsAudio(aIn, segs) {
|
|
440
|
+
const n = segs.length;
|
|
441
|
+
const g = [`${aIn}asplit=${n}${segs.map((_, i) => `[as${i}]`).join("")}`];
|
|
442
|
+
segs.forEach(([a, b], i) => {
|
|
443
|
+
const d = b - a,
|
|
444
|
+
f = Math.min(CUT_FADE, d / 3);
|
|
445
|
+
const fades = [
|
|
446
|
+
i > 0 ? `afade=t=in:d=${f.toFixed(4)}` : "",
|
|
447
|
+
i < n - 1 ? `afade=t=out:st=${(d - f).toFixed(4)}:d=${f.toFixed(4)}` : "",
|
|
448
|
+
].filter(Boolean);
|
|
449
|
+
g.push(
|
|
450
|
+
`[as${i}]atrim=start=${a.toFixed(4)}:end=${b.toFixed(4)},asetpts=PTS-STARTPTS${fades.length ? `,${fades.join(",")}` : ""}[a${i}]`,
|
|
451
|
+
);
|
|
452
|
+
});
|
|
453
|
+
g.push(`${segs.map((_, i) => `[a${i}]`).join("")}concat=n=${n}:v=0:a=1[a]`);
|
|
454
|
+
return g.join(";");
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/* --- speed: a second pass over the base export ----------------------------------------
|
|
458
|
+
The picture (captions burned in) comes from the base export: setpts speeds up the frames and
|
|
459
|
+
fps brings them back to the video rate (drops frames). The sound is not the base's: it is
|
|
460
|
+
built again for this speed (exportAudio: voice and effects through atempo, the isolated bed
|
|
461
|
+
on top), so the bed keeps its tempo. */
|
|
462
|
+
const COLOR = "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709:range=tv";
|
|
463
|
+
|
|
464
|
+
const pct = v => Math.round(v * 100);
|
|
465
|
+
|
|
466
|
+
/* assembly.json with the speed applied: writes export/<slug>-speed-<pct>.mp4 from the base and
|
|
467
|
+
removes versions at other speeds; 1 keeps the base as the deliverable. `audioFile`: the
|
|
468
|
+
sound built for `v` */
|
|
469
|
+
function withSpeed(m, v, audioFile) {
|
|
470
|
+
const baseRel = m.base_mp4 ?? m.mp4;
|
|
471
|
+
const baseDuration = m.base_duration ?? m.duration;
|
|
472
|
+
const exp = join(dir, "export");
|
|
473
|
+
const slug = baseRel
|
|
474
|
+
.split("/")
|
|
475
|
+
.pop()
|
|
476
|
+
.replace(/\.mp4$/, "");
|
|
477
|
+
const prefix = `${slug}-speed-`;
|
|
478
|
+
let rel = null,
|
|
479
|
+
d = null;
|
|
480
|
+
if (v !== 1) {
|
|
481
|
+
rel = `export/${prefix}${pct(v)}.mp4`;
|
|
482
|
+
const out = join(dir, rel);
|
|
483
|
+
run(
|
|
484
|
+
"ffmpeg",
|
|
485
|
+
[
|
|
486
|
+
"-y",
|
|
487
|
+
"-loglevel",
|
|
488
|
+
"error",
|
|
489
|
+
"-i",
|
|
490
|
+
join(dir, baseRel),
|
|
491
|
+
"-i",
|
|
492
|
+
audioFile,
|
|
493
|
+
"-filter_complex",
|
|
494
|
+
`[0:v]setpts=PTS/${v},fps=${m.fps},format=yuv420p,${COLOR}[v]`,
|
|
495
|
+
"-map",
|
|
496
|
+
"[v]",
|
|
497
|
+
"-map",
|
|
498
|
+
"1:a",
|
|
499
|
+
"-c:a",
|
|
500
|
+
"aac",
|
|
501
|
+
"-b:a",
|
|
502
|
+
`${A.audio_kbps}k`,
|
|
503
|
+
"-ar",
|
|
504
|
+
String(RATE),
|
|
505
|
+
"-c:v",
|
|
506
|
+
"libx264",
|
|
507
|
+
"-crf",
|
|
508
|
+
String(A.crf),
|
|
509
|
+
"-preset",
|
|
510
|
+
"slow",
|
|
511
|
+
"-t",
|
|
512
|
+
String(baseDuration / v),
|
|
513
|
+
"-movflags",
|
|
514
|
+
"+faststart",
|
|
515
|
+
out,
|
|
516
|
+
],
|
|
517
|
+
"acelerar",
|
|
518
|
+
);
|
|
519
|
+
d = duration(out);
|
|
520
|
+
}
|
|
521
|
+
for (const n of readdirSync(exp)) {
|
|
522
|
+
if (n.startsWith(prefix) && n.endsWith(".mp4") && `export/${n}` !== rel) rmSync(join(exp, n));
|
|
523
|
+
}
|
|
524
|
+
const { base_mp4, base_duration, speed, speed_at, ...rest } = m;
|
|
525
|
+
if (v === 1) return { ...rest, mp4: baseRel, duration: baseDuration };
|
|
526
|
+
const warnings = [...(rest.warnings ?? [])];
|
|
527
|
+
const expected = baseDuration / v;
|
|
528
|
+
if (d == null || Math.abs(d - expected) > 2 / m.fps)
|
|
529
|
+
warnings.push(`o MP4 a ${pct(v)}% tem ${d?.toFixed(3)}s, devia ter ${expected.toFixed(3)}s`);
|
|
530
|
+
return {
|
|
531
|
+
...rest,
|
|
532
|
+
mp4: rel,
|
|
533
|
+
duration: d,
|
|
534
|
+
base_mp4: baseRel,
|
|
535
|
+
base_duration: baseDuration,
|
|
536
|
+
speed: v,
|
|
537
|
+
speed_at: new Date().toISOString(),
|
|
538
|
+
warnings,
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* `keepMtime`: the file time stays the assembly's, which is what status
|
|
543
|
+
compares scenes, voice and captions against to say the export is outdated */
|
|
544
|
+
function writeAssembly(file, m, keepMtime) {
|
|
545
|
+
const st = keepMtime && existsSync(file) ? statSync(file) : null;
|
|
546
|
+
writeFileSync(file, JSON.stringify(m, null, 2) + "\n");
|
|
547
|
+
if (st) utimesSync(file, st.atime, st.mtime);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/* ============================================================================ */
|
|
551
|
+
const only = { sheet: has("sheet") };
|
|
552
|
+
let video = loadVideo(dir);
|
|
553
|
+
const decideCaptions = v => (SILENT || has("no-captions") ? false : has("captions") ? true : !v.captions_in_motion);
|
|
554
|
+
check(video, decideCaptions(video));
|
|
555
|
+
await turn("assembly", dir);
|
|
556
|
+
video = loadVideo(dir);
|
|
557
|
+
const withCaptions = decideCaptions(video);
|
|
558
|
+
check(video, withCaptions);
|
|
559
|
+
|
|
560
|
+
const { w, h, fps } = video.format;
|
|
561
|
+
const total = video.total_duration;
|
|
562
|
+
const cuts = normalizeCuts(video.cuts, total, fps);
|
|
563
|
+
const finalTotal = total - removedDuration(cuts);
|
|
564
|
+
/* the editor's speed (scenes.json `speed`, 1 to 1.5): a second pass after the base export */
|
|
565
|
+
const speed = sanitizeSpeed(video.speed ?? legacySpeed());
|
|
566
|
+
if (finalTotal < 1 / fps)
|
|
567
|
+
fail("os cortes tiram o vídeo inteiro: desfaça algum no editor do studio (ou em `cuts` no scenes.json)");
|
|
568
|
+
const allCaptions = captionsOf(dir, video);
|
|
569
|
+
/* `captions.individual.<id>.hidden`: turned off in the UI. With the voice in clips (editor), each caption
|
|
570
|
+
moves with the voice piece it falls in (the largest, if it spans a blade cut); in a deleted piece,
|
|
571
|
+
it's dropped */
|
|
572
|
+
const captions = allCaptions
|
|
573
|
+
.filter(c => !c.hidden)
|
|
574
|
+
.flatMap(c => {
|
|
575
|
+
if (!voiceEdited(video.scenes) || !c.line) return [c];
|
|
576
|
+
const scene = video.scenes.find(sc => (sc.lines ?? []).some(l => l.id === c.line));
|
|
577
|
+
const line = scene?.lines.find(x => x.id === c.line);
|
|
578
|
+
if (!line) return [c];
|
|
579
|
+
const base = scene.start + line.start;
|
|
580
|
+
const pieces = voiceSpans(scene, line, c.s - base, c.e - base);
|
|
581
|
+
if (!pieces.length) return [];
|
|
582
|
+
const [s, e] = pieces.reduce((m, p) => (p[1] - p[0] > m[1] - m[0] ? p : m));
|
|
583
|
+
return [{ ...c, s: +s.toFixed(3), e: +e.toFixed(3) }];
|
|
584
|
+
})
|
|
585
|
+
.sort((a, b) => a.s - b.s);
|
|
586
|
+
if (captions.length < allCaptions.length)
|
|
587
|
+
console.log(`legenda: ${allCaptions.length - captions.length} desligada(s) não entra(m) no vídeo`);
|
|
588
|
+
const tmp = join(tmpdir(), `assemble-${process.pid}`);
|
|
589
|
+
mkdirSync(tmp, { recursive: true });
|
|
590
|
+
const exp = join(dir, "export");
|
|
591
|
+
mkdirSync(exp, { recursive: true });
|
|
592
|
+
const slug = video.slug ?? dir.split("/").pop();
|
|
593
|
+
|
|
594
|
+
const cap = withCaptions ? captionFrames(video, captions) : null;
|
|
595
|
+
const marks = moments(video, captions);
|
|
596
|
+
|
|
597
|
+
/* --- sheet only: captions over each scene's frame, without assembling the video -------------- */
|
|
598
|
+
if (only.sheet) {
|
|
599
|
+
if (!cap)
|
|
600
|
+
fail("--sheet mostra a legenda queimada; este vídeo não queima legenda (use --captions para ver mesmo assim)");
|
|
601
|
+
const frames = marks.map((m, i) => {
|
|
602
|
+
const png = join(tmp, `f${String(i).padStart(3, "0")}.png`);
|
|
603
|
+
const sceneMp4 = join(dir, m.scene.mp4 ?? `motion/${m.scene.id}.mp4`);
|
|
604
|
+
const local = Math.min(m.scene.duration - 1 / fps, Math.max(0, m.t - (animationStart(m.scene) ?? m.scene.start)));
|
|
605
|
+
const ins = ["-ss", local.toFixed(4), "-i", sceneMp4, ...(m.caption >= 0 ? ["-i", cap.pngs[m.caption]] : [])];
|
|
606
|
+
run(
|
|
607
|
+
"ffmpeg",
|
|
608
|
+
[
|
|
609
|
+
"-y",
|
|
610
|
+
"-loglevel",
|
|
611
|
+
"error",
|
|
612
|
+
...ins,
|
|
613
|
+
...(m.caption >= 0 ? ["-filter_complex", "[0:v][1:v]overlay=0:0"] : []),
|
|
614
|
+
"-frames:v",
|
|
615
|
+
"1",
|
|
616
|
+
png,
|
|
617
|
+
],
|
|
618
|
+
"quadro",
|
|
619
|
+
);
|
|
620
|
+
return png;
|
|
621
|
+
});
|
|
622
|
+
const out = join(exp, `${slug}-captions-sheet.png`);
|
|
623
|
+
sheet(frames, out);
|
|
624
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
625
|
+
console.log(
|
|
626
|
+
`folha da legenda (${cap.style}, safe area ${cap.platform}, ${cap.anchor}${cap.css ? ", + _captions.css" : ""}, ${captions.length} legendas): ${out}`,
|
|
627
|
+
);
|
|
628
|
+
console.log(`quadros: ${marks.map(m => `${m.scene.id} ${m.t.toFixed(2)}s`).join(" · ")}`);
|
|
629
|
+
console.log(`a camada inteira abre no navegador: ${join(dir, "captions", "captions.html")}?t=<segundos>`);
|
|
630
|
+
process.exit(0);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const previous = keepPrevious(dir, "assembly", null, [
|
|
634
|
+
`export/${slug}.mp4`,
|
|
635
|
+
`export/${slug}-sheet.png`,
|
|
636
|
+
"export/assembly.json",
|
|
637
|
+
]);
|
|
638
|
+
|
|
639
|
+
/* --- V: scenes joined ----------------------------------------------------------- */
|
|
640
|
+
const motion = join(tmp, "motion.mp4");
|
|
641
|
+
const sceneMp4 = sc => join(dir, sc.mp4 ?? `motion/${sc.id}.mp4`);
|
|
642
|
+
if (!videoEdited(video.scenes)) {
|
|
643
|
+
writeFileSync(join(tmp, "scenes.txt"), video.scenes.map(sc => `file '${sceneMp4(sc)}'`).join("\n") + "\n");
|
|
644
|
+
run(
|
|
645
|
+
"ffmpeg",
|
|
646
|
+
["-y", "-loglevel", "error", "-f", "concat", "-safe", "0", "-i", join(tmp, "scenes.txt"), "-c", "copy", motion],
|
|
647
|
+
"emendar cenas",
|
|
648
|
+
);
|
|
649
|
+
} else {
|
|
650
|
+
/* shifted animation: each track segment is a piece of a scene, running or frozen on a frame */
|
|
651
|
+
const segs = videoTrack(video.scenes, total, fps);
|
|
652
|
+
const uses = video.scenes.map((_, i) => segs.filter(sg => sg.i === i).length);
|
|
653
|
+
const g = [];
|
|
654
|
+
const labels = video.scenes.map((_, i) => {
|
|
655
|
+
if (!uses[i]) return [];
|
|
656
|
+
if (uses[i] === 1) return [`[${i}:v]`];
|
|
657
|
+
g.push(`[${i}:v]split=${uses[i]}${Array.from({ length: uses[i] }, (_, k) => `[c${i}_${k}]`).join("")}`);
|
|
658
|
+
return Array.from({ length: uses[i] }, (_, k) => `[c${i}_${k}]`);
|
|
659
|
+
});
|
|
660
|
+
segs.forEach((sg, k) => {
|
|
661
|
+
const input = labels[sg.i].shift();
|
|
662
|
+
g.push(
|
|
663
|
+
sg.frozen
|
|
664
|
+
? `${input}trim=start_frame=${sg.since}:end_frame=${sg.since + 1},setpts=PTS-STARTPTS,tpad=stop=${sg.frames - 1}:stop_mode=clone[t${k}]`
|
|
665
|
+
: sg.speed === 1
|
|
666
|
+
? `${input}trim=start_frame=${sg.since}:end_frame=${sg.since + sg.frames},setpts=PTS-STARTPTS[t${k}]`
|
|
667
|
+
: /* a sped piece: frames × speed frames of the MP4 squeezed into `frames` (fps evens them out) */
|
|
668
|
+
`${input}trim=start_frame=${sg.since}:end_frame=${sg.since + Math.max(1, Math.round(sg.frames * sg.speed))},setpts=(PTS-STARTPTS)/${sg.speed},fps=${fps},tpad=stop=${sg.frames}:stop_mode=clone,trim=end_frame=${sg.frames},setpts=PTS-STARTPTS[t${k}]`,
|
|
669
|
+
);
|
|
670
|
+
});
|
|
671
|
+
g.push(
|
|
672
|
+
`${segs.map((_, k) => `[t${k}]`).join("")}concat=n=${segs.length}:v=1:a=0,fps=${fps},format=yuv420p,${COLOR}[v]`,
|
|
673
|
+
);
|
|
674
|
+
const used = video.scenes.map((sc, i) => (uses[i] ? sceneMp4(sc) : null));
|
|
675
|
+
/* a fully covered scene doesn't go in; the input index stays the scene's */
|
|
676
|
+
run(
|
|
677
|
+
"ffmpeg",
|
|
678
|
+
[
|
|
679
|
+
"-y",
|
|
680
|
+
"-loglevel",
|
|
681
|
+
"error",
|
|
682
|
+
...used.flatMap(a => ["-i", a ?? sceneMp4(video.scenes[0])]),
|
|
683
|
+
"-filter_complex",
|
|
684
|
+
g.join(";"),
|
|
685
|
+
"-map",
|
|
686
|
+
"[v]",
|
|
687
|
+
"-c:v",
|
|
688
|
+
"libx264",
|
|
689
|
+
"-crf",
|
|
690
|
+
"12",
|
|
691
|
+
"-preset",
|
|
692
|
+
"fast",
|
|
693
|
+
"-t",
|
|
694
|
+
String(total),
|
|
695
|
+
motion,
|
|
696
|
+
],
|
|
697
|
+
"trilha de animação",
|
|
698
|
+
);
|
|
699
|
+
console.log(
|
|
700
|
+
`animação nos clips do editor: ${video.scenes
|
|
701
|
+
.map(
|
|
702
|
+
sc =>
|
|
703
|
+
`${sc.id} ${
|
|
704
|
+
videoClips(sc)
|
|
705
|
+
.map(
|
|
706
|
+
cl =>
|
|
707
|
+
`${cl.from.toFixed(2)}–${cl.to.toFixed(2)}${cl.offset ? ` ${cl.offset > 0 ? "+" : ""}${cl.offset.toFixed(2)}s` : ""}${cl.speed ? ` ${Math.round(cl.speed * 100)}%` : ""}`,
|
|
708
|
+
)
|
|
709
|
+
.join(", ") || "apagada"
|
|
710
|
+
}`,
|
|
711
|
+
)
|
|
712
|
+
.join(" · ")}`,
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/* --- A: lines and effects ----------------------------------------------------------- */
|
|
717
|
+
let sound;
|
|
718
|
+
try {
|
|
719
|
+
/* the base export is at 100%: the bed is made for that (the speed pass makes its own) */
|
|
720
|
+
sound = prepareSound(dir, { preview: false, log: () => {}, speed: 1 });
|
|
721
|
+
} catch (e) {
|
|
722
|
+
fail(e.message);
|
|
723
|
+
}
|
|
724
|
+
const premixFile = premix(video, sound, total, tmp);
|
|
725
|
+
const { mix: mixFile, measured } = exportAudio(premixFile, sound.bed, {
|
|
726
|
+
cuts,
|
|
727
|
+
total,
|
|
728
|
+
speed: 1,
|
|
729
|
+
finalDur: finalTotal,
|
|
730
|
+
tmp,
|
|
731
|
+
tag: "base",
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
/* --- final ------------------------------------------------------------------------ */
|
|
735
|
+
const mp4 = join(exp, `${slug}.mp4`);
|
|
736
|
+
const audioOut = ["-c:a", "aac", "-b:a", `${A.audio_kbps}k`, "-ar", String(RATE)];
|
|
737
|
+
if (cap) {
|
|
738
|
+
const list = captionTrack(captions, cap.pngs, total, fps, w, h, tmp);
|
|
739
|
+
/* captions enter as yuva with the scenes' bt709 matrix: without it ffmpeg converts
|
|
740
|
+
in bt601 and the pill's white drifts to another tone */
|
|
741
|
+
const graph =
|
|
742
|
+
`[1:v]fps=${fps},scale=out_color_matrix=bt709:out_range=tv,format=yuva420p[cap];` +
|
|
743
|
+
`[0:v][cap]overlay=0:0:eof_action=pass:format=yuv420,format=yuv420p,${COLOR}${cuts.length ? "[vb];" + cutsVideo("[vb]", keptSegments(cuts, total)) : "[v]"}`;
|
|
744
|
+
run(
|
|
745
|
+
"ffmpeg",
|
|
746
|
+
[
|
|
747
|
+
"-y",
|
|
748
|
+
"-loglevel",
|
|
749
|
+
"error",
|
|
750
|
+
"-i",
|
|
751
|
+
motion,
|
|
752
|
+
"-f",
|
|
753
|
+
"concat",
|
|
754
|
+
"-safe",
|
|
755
|
+
"0",
|
|
756
|
+
"-i",
|
|
757
|
+
list,
|
|
758
|
+
"-i",
|
|
759
|
+
mixFile,
|
|
760
|
+
"-filter_complex",
|
|
761
|
+
graph,
|
|
762
|
+
"-map",
|
|
763
|
+
"[v]",
|
|
764
|
+
"-map",
|
|
765
|
+
"2:a",
|
|
766
|
+
"-c:v",
|
|
767
|
+
"libx264",
|
|
768
|
+
"-crf",
|
|
769
|
+
String(A.crf),
|
|
770
|
+
"-preset",
|
|
771
|
+
"slow",
|
|
772
|
+
...audioOut,
|
|
773
|
+
"-t",
|
|
774
|
+
String(finalTotal),
|
|
775
|
+
"-movflags",
|
|
776
|
+
"+faststart",
|
|
777
|
+
mp4,
|
|
778
|
+
],
|
|
779
|
+
"exportar",
|
|
780
|
+
);
|
|
781
|
+
} else if (cuts.length) {
|
|
782
|
+
const graph = `[0:v]format=yuv420p,${COLOR}[vb];` + cutsVideo("[vb]", keptSegments(cuts, total));
|
|
783
|
+
run(
|
|
784
|
+
"ffmpeg",
|
|
785
|
+
[
|
|
786
|
+
"-y",
|
|
787
|
+
"-loglevel",
|
|
788
|
+
"error",
|
|
789
|
+
"-i",
|
|
790
|
+
motion,
|
|
791
|
+
"-i",
|
|
792
|
+
mixFile,
|
|
793
|
+
"-filter_complex",
|
|
794
|
+
graph,
|
|
795
|
+
"-map",
|
|
796
|
+
"[v]",
|
|
797
|
+
"-map",
|
|
798
|
+
"1:a",
|
|
799
|
+
"-c:v",
|
|
800
|
+
"libx264",
|
|
801
|
+
"-crf",
|
|
802
|
+
String(A.crf),
|
|
803
|
+
"-preset",
|
|
804
|
+
"slow",
|
|
805
|
+
...audioOut,
|
|
806
|
+
"-t",
|
|
807
|
+
String(finalTotal),
|
|
808
|
+
"-movflags",
|
|
809
|
+
"+faststart",
|
|
810
|
+
mp4,
|
|
811
|
+
],
|
|
812
|
+
"exportar",
|
|
813
|
+
);
|
|
814
|
+
} else {
|
|
815
|
+
run(
|
|
816
|
+
"ffmpeg",
|
|
817
|
+
[
|
|
818
|
+
"-y",
|
|
819
|
+
"-loglevel",
|
|
820
|
+
"error",
|
|
821
|
+
"-i",
|
|
822
|
+
motion,
|
|
823
|
+
"-i",
|
|
824
|
+
mixFile,
|
|
825
|
+
"-map",
|
|
826
|
+
"0:v",
|
|
827
|
+
"-map",
|
|
828
|
+
"1:a",
|
|
829
|
+
"-c:v",
|
|
830
|
+
"copy",
|
|
831
|
+
...audioOut,
|
|
832
|
+
"-t",
|
|
833
|
+
String(total),
|
|
834
|
+
"-movflags",
|
|
835
|
+
"+faststart",
|
|
836
|
+
mp4,
|
|
837
|
+
],
|
|
838
|
+
"exportar",
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/* --- check ------------------------------------------------------------------ */
|
|
843
|
+
const d = duration(mp4);
|
|
844
|
+
const warnings = [...sound.warnings.map(a => `efeito: ${a}`)];
|
|
845
|
+
if (d == null || Math.abs(d - finalTotal) > 1.5 / fps)
|
|
846
|
+
warnings.push(
|
|
847
|
+
`o MP4 tem ${d?.toFixed(3)}s, o vídeo pede ${finalTotal.toFixed(3)}s${cuts.length ? ` (${total.toFixed(3)}s menos os cortes)` : ""}`,
|
|
848
|
+
);
|
|
849
|
+
/* with cuts, each scene's frame moves to export time (inside a cut, the cut point) */
|
|
850
|
+
const lastFrame = (Math.round(finalTotal * fps) - 1) / fps;
|
|
851
|
+
marks.forEach(m => {
|
|
852
|
+
if (cuts.length) m.t = Math.min(lastFrame, Math.round(toEdited(m.t, cuts) * fps) / fps);
|
|
853
|
+
});
|
|
854
|
+
const frames = marks.map((m, i) => {
|
|
855
|
+
const png = join(tmp, `f${String(i).padStart(3, "0")}.png`);
|
|
856
|
+
run("ffmpeg", ["-y", "-loglevel", "error", "-ss", m.t.toFixed(4), "-i", mp4, "-frames:v", "1", png], "quadro");
|
|
857
|
+
return png;
|
|
858
|
+
});
|
|
859
|
+
const sheetFile = join(exp, `${slug}-sheet.png`);
|
|
860
|
+
sheet(frames, sheetFile);
|
|
861
|
+
|
|
862
|
+
const lineCount = video.scenes.reduce((n, sc) => n + (sc.lines?.length ?? 0), 0);
|
|
863
|
+
let assembly = {
|
|
864
|
+
mp4: `export/${slug}.mp4`,
|
|
865
|
+
sheet: `export/${slug}-sheet.png`,
|
|
866
|
+
duration: d,
|
|
867
|
+
w,
|
|
868
|
+
h,
|
|
869
|
+
fps,
|
|
870
|
+
scenes: video.scenes.length,
|
|
871
|
+
lines: lineCount,
|
|
872
|
+
effects: sound.items.length,
|
|
873
|
+
bed: sound.bed?.name ?? null,
|
|
874
|
+
captions: cap
|
|
875
|
+
? {
|
|
876
|
+
burned: true,
|
|
877
|
+
style: cap.style,
|
|
878
|
+
platform: cap.platform,
|
|
879
|
+
anchor: cap.anchor,
|
|
880
|
+
video_css: cap.css,
|
|
881
|
+
count: captions.length,
|
|
882
|
+
}
|
|
883
|
+
: {
|
|
884
|
+
burned: false,
|
|
885
|
+
reason: SILENT ? "no_narration" : video.captions_in_motion ? "captions_in_motion" : "--no-captions",
|
|
886
|
+
},
|
|
887
|
+
audio: {
|
|
888
|
+
target_lufs: A.lufs,
|
|
889
|
+
peak_db: A.peak_db,
|
|
890
|
+
...(measured ?? { no_sound: !sound.items.length && !sound.bed, ...(SILENT ? { silent: true } : {}) }),
|
|
891
|
+
},
|
|
892
|
+
sheet_frames: marks.map(m => ({ scene: m.scene.id, t: m.t })),
|
|
893
|
+
...(cuts.length ? { cuts, uncut_duration: total, removed_s: +removedDuration(cuts).toFixed(4) } : {}),
|
|
894
|
+
...(videoEdited(video.scenes)
|
|
895
|
+
? { scene_clips: Object.fromEntries(video.scenes.map(sc => [sc.id, videoClips(sc)])) }
|
|
896
|
+
: {}),
|
|
897
|
+
...(voiceEdited(video.scenes)
|
|
898
|
+
? { line_clips: Object.fromEntries(video.scenes.flatMap(sc => (sc.lines ?? []).map(l => [l.id, lineClips(l)]))) }
|
|
899
|
+
: {}),
|
|
900
|
+
warnings,
|
|
901
|
+
assembled_at: new Date().toISOString(),
|
|
902
|
+
};
|
|
903
|
+
/* the speed pass: the sheet stays the base's (the same frames, just earlier). The sound is built
|
|
904
|
+
again for this speed, with the bed made for it (only the bed: no scene's effects) */
|
|
905
|
+
let spedAudio = null;
|
|
906
|
+
if (speed !== 1) {
|
|
907
|
+
const bedAtSpeed = planSound(dir, video, {
|
|
908
|
+
outDir: join(tmp, "sound-speed"),
|
|
909
|
+
scenes: new Set(),
|
|
910
|
+
clock: finalClock(video, speed),
|
|
911
|
+
}).bed;
|
|
912
|
+
spedAudio = exportAudio(premixFile, bedAtSpeed, {
|
|
913
|
+
cuts,
|
|
914
|
+
total,
|
|
915
|
+
speed,
|
|
916
|
+
finalDur: finalTotal / speed,
|
|
917
|
+
tmp,
|
|
918
|
+
tag: "speed",
|
|
919
|
+
}).mix;
|
|
920
|
+
}
|
|
921
|
+
assembly = withSpeed(assembly, speed, spedAudio);
|
|
922
|
+
writeAssembly(join(exp, "assembly.json"), assembly, false);
|
|
923
|
+
previous.close();
|
|
924
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
925
|
+
|
|
926
|
+
console.log(`exportado: ${mp4} (${d?.toFixed(2)}s, ${w}×${h} @ ${fps})`);
|
|
927
|
+
if (cuts.length)
|
|
928
|
+
console.log(
|
|
929
|
+
`cortes: ${cuts.length} trecho(s), ${removedDuration(cuts).toFixed(2)}s fora (${total.toFixed(2)}s → ${finalTotal.toFixed(2)}s): ${cuts.map(c => `${c.from.toFixed(2)}–${c.to.toFixed(2)}`).join(" · ")}`,
|
|
930
|
+
);
|
|
931
|
+
if (speed !== 1)
|
|
932
|
+
console.log(`velocidade ${pct(speed)}% reaplicada: ${join(dir, assembly.mp4)} (${assembly.duration?.toFixed(2)}s)`);
|
|
933
|
+
console.log(
|
|
934
|
+
`V: ${video.scenes.length} cenas · A: ${lineCount} falas + ${sound.items.length} efeitos${sound.bed ? " + cama" : ""} · ` +
|
|
935
|
+
`legenda ${cap ? `queimada (${cap.style}, ${cap.platform}, ${cap.anchor}, ${captions.length})` : video.captions_in_motion ? "no motion" : "não queimada"}`,
|
|
936
|
+
);
|
|
937
|
+
if (measured)
|
|
938
|
+
console.log(
|
|
939
|
+
`áudio: ${measured.before_lufs} → ${measured.after_lufs} LUFS (alvo ${A.lufs}), pico ${measured.after_peak_db} dBTP, ${measured.mode}`,
|
|
940
|
+
);
|
|
941
|
+
console.log(`folha: ${sheetFile} (${marks.map(m => `${m.scene.id} ${m.t.toFixed(2)}s`).join(" · ")})`);
|
|
942
|
+
assembly.warnings.forEach(a => console.log(`⚠ ${a}`));
|