mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 22:59:25 +00:00
feat(agent): support 3D degree comments, markup annotations, and config3d in read_asset (#473)
* feat(agent): support AI embedding, autofill, and read_asset for 3D assets * feat(agent): support 3D degree comments, markup annotations, and config3d in read_asset * fix(agent): resolve 3D session annotations to turntable degree frame time
This commit is contained in:
@@ -4432,6 +4432,89 @@ describe('TranscodeService', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('generate3dViews', () => {
|
||||
it('executes ffmpeg with 2x2 grid filter, libwebp encoder, and q=85', async () => {
|
||||
let executedArgs: string[] = []
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(child_process.execFile as any).mockImplementation(
|
||||
(
|
||||
_cmd: string,
|
||||
args: string[],
|
||||
cb: (err: unknown, result: { stdout: string; stderr: string }) => void,
|
||||
) => {
|
||||
executedArgs = args
|
||||
cb(null, { stdout: '', stderr: '' })
|
||||
},
|
||||
)
|
||||
|
||||
const inputPath = path.join(tempDir, 'turntable.mp4')
|
||||
const outputPath = path.join(tempDir, 'views.webp')
|
||||
|
||||
await transcodeService.generate3dViews(inputPath, outputPath)
|
||||
|
||||
expect(child_process.execFile).toHaveBeenCalledWith(
|
||||
'ffmpeg',
|
||||
expect.any(Array),
|
||||
expect.any(Function),
|
||||
)
|
||||
expect(executedArgs).toEqual([
|
||||
'-y',
|
||||
'-loglevel',
|
||||
'warning',
|
||||
'-i',
|
||||
inputPath,
|
||||
'-filter_complex',
|
||||
"[0:v]select='eq(n\\,0)+eq(n\\,6)+eq(n\\,12)+eq(n\\,18)',scale=1440:1440,tile=2x2[views_out]",
|
||||
'-map',
|
||||
'[views_out]',
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-c:v',
|
||||
'libwebp',
|
||||
'-q:v',
|
||||
'85',
|
||||
outputPath,
|
||||
])
|
||||
})
|
||||
|
||||
it('passes abort signal to execFile when provided', async () => {
|
||||
const controller = new AbortController()
|
||||
let optionsPassed: unknown = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(child_process.execFile as any).mockImplementation(
|
||||
(_cmd: string, _args: string[], optionsOrCb: unknown, maybeCb?: unknown) => {
|
||||
const cb = (typeof optionsOrCb === 'function' ? optionsOrCb : maybeCb) as (
|
||||
err: unknown,
|
||||
result: { stdout: string; stderr: string },
|
||||
) => void
|
||||
if (typeof optionsOrCb !== 'function') {
|
||||
optionsPassed = optionsOrCb
|
||||
}
|
||||
cb(null, { stdout: '', stderr: '' })
|
||||
},
|
||||
)
|
||||
|
||||
const inputPath = path.join(tempDir, 'turntable.mp4')
|
||||
const outputPath = path.join(tempDir, 'views.webp')
|
||||
|
||||
await transcodeService.generate3dViews(inputPath, outputPath, controller.signal)
|
||||
|
||||
expect(optionsPassed).toMatchObject({ signal: controller.signal })
|
||||
})
|
||||
|
||||
it('rejects with cancellation error if aborted before execution', async () => {
|
||||
const controller = new AbortController()
|
||||
controller.abort()
|
||||
|
||||
const inputPath = path.join(tempDir, 'aborted.mp4')
|
||||
const outputPath = path.join(tempDir, 'views.webp')
|
||||
|
||||
await expect(
|
||||
transcodeService.generate3dViews(inputPath, outputPath, controller.signal),
|
||||
).rejects.toThrow('3D views generation cancelled')
|
||||
})
|
||||
})
|
||||
|
||||
describe('HLS utilities', () => {
|
||||
it('builds master playlist correctly with bandwidth and codecs', () => {
|
||||
const playlist = buildHlsMasterPlaylist([
|
||||
|
||||
@@ -3192,6 +3192,37 @@ export class TranscodeService {
|
||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args])
|
||||
}
|
||||
}
|
||||
|
||||
async generate3dViews(
|
||||
inputFile: string,
|
||||
outputViews: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<void> {
|
||||
if (signal?.aborted) {
|
||||
throw new Error('3D views generation cancelled')
|
||||
}
|
||||
const filterComplex = `[0:v]select='eq(n\\,0)+eq(n\\,6)+eq(n\\,12)+eq(n\\,18)',scale=1440:1440,tile=2x2[views_out]`
|
||||
const args = [
|
||||
'-i',
|
||||
inputFile,
|
||||
'-filter_complex',
|
||||
filterComplex,
|
||||
'-map',
|
||||
'[views_out]',
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-c:v',
|
||||
'libwebp',
|
||||
'-q:v',
|
||||
'85',
|
||||
outputViews,
|
||||
]
|
||||
if (signal) {
|
||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args], { signal })
|
||||
} else {
|
||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderAnnotationsToSvg(
|
||||
|
||||
Reference in New Issue
Block a user