mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 11:07:16 +00:00
fix(transcode): avoid selecting attached picture streams for video transcoding (#443)
* fix(transcode): avoid selecting attached picture streams for video transcoding Filter out attached picture streams (disposition.attached_pic) during video probing and stream selection, matching Immich's default and bitrate selection strategy. Forward explicit primary video and audio stream indices to FFmpeg pipelines to prevent picking embedded cover art or thumbnail streams. * fix(transcode): skip poster and sprite generation for audio-only assets and add multi-stream e2e tests * test(workflow): scope pixel format to h264 stream and use yuvj420p for mjpeg cover art
This commit is contained in:
@@ -64,7 +64,9 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
codec: '',
|
||||
}
|
||||
|
||||
if (spec.poster) {
|
||||
const isVideo = mediaInfo.proxyType === 'video'
|
||||
|
||||
if (spec.poster && isVideo) {
|
||||
const lastSlashIndex = key.lastIndexOf('/')
|
||||
const assetDir = lastSlashIndex === -1 ? '' : key.substring(0, lastSlashIndex)
|
||||
const posterSpec: PrismaJson.PosterInfo = {
|
||||
@@ -77,6 +79,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
isHdr: mediaInfo.metadata?.isHdr,
|
||||
hdrType: mediaInfo.metadata?.hdrType,
|
||||
colorTransfer: mediaInfo.metadata?.colorTransfer,
|
||||
streamIndex: mediaInfo.metadata?.videoStreamIndex,
|
||||
})
|
||||
mediaInfo.poster = posterResult.poster
|
||||
await executeActivity(workerQueue, updateAssetMediaActivity, {
|
||||
@@ -87,7 +90,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
|
||||
// Generate the sprite (and its poster fallback) before the expensive proxy transcodes so the
|
||||
// file list can show a poster/sprite preview while the asset is still processing.
|
||||
if (spec.sprite || (spec.poster && !mediaInfo.poster)) {
|
||||
if ((spec.sprite || (spec.poster && !mediaInfo.poster)) && isVideo) {
|
||||
const lastSlashIndex = key.lastIndexOf('/')
|
||||
const assetDir = lastSlashIndex === -1 ? '' : key.substring(0, lastSlashIndex)
|
||||
|
||||
@@ -124,7 +127,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
|
||||
const metadata = mediaInfo.metadata
|
||||
|
||||
if (mediaInfo.proxyType === 'video' && metadata) {
|
||||
if (isVideo && metadata) {
|
||||
const videoResolutions = getTargetVideoResolutions(
|
||||
spec.videoStrategy || 'best_match',
|
||||
metadata.originalWidth,
|
||||
@@ -163,6 +166,8 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
sourceColorTransfer: metadata.colorTransfer,
|
||||
sourceColorPrimaries: metadata.colorPrimaries,
|
||||
sourceColorSpace: metadata.colorSpace,
|
||||
streamIndex: metadata.videoStreamIndex,
|
||||
audioStreamIndex: metadata.audioStreamIndex,
|
||||
})
|
||||
|
||||
mediaInfo.videoPreview = videoTranscode
|
||||
@@ -191,6 +196,8 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
sourceColorTransfer: metadata.colorTransfer,
|
||||
sourceColorPrimaries: metadata.colorPrimaries,
|
||||
sourceColorSpace: metadata.colorSpace,
|
||||
streamIndex: metadata.videoStreamIndex,
|
||||
audioStreamIndex: metadata.audioStreamIndex,
|
||||
})
|
||||
|
||||
mediaInfo.videoTranscodes.push(videoTranscode)
|
||||
@@ -219,6 +226,8 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
sourceColorTransfer: metadata.colorTransfer,
|
||||
sourceColorPrimaries: metadata.colorPrimaries,
|
||||
sourceColorSpace: metadata.colorSpace,
|
||||
streamIndex: metadata.videoStreamIndex,
|
||||
audioStreamIndex: metadata.audioStreamIndex,
|
||||
})
|
||||
mediaInfo.isHls = true
|
||||
mediaInfo.hls = hlsResult
|
||||
@@ -233,11 +242,12 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
assetKey: key,
|
||||
filePath,
|
||||
threads: spec.threads,
|
||||
audioStreamIndex: metadata.audioStreamIndex,
|
||||
})
|
||||
mediaInfo.videoTranscodes.push(audioTranscode)
|
||||
}
|
||||
|
||||
if (spec.thumbnail) {
|
||||
if (spec.thumbnail && isVideo) {
|
||||
const thumbTranscode = await executeActivity(workerQueue, transcodeImageActivity, {
|
||||
assetKey: key,
|
||||
filePath,
|
||||
|
||||
Reference in New Issue
Block a user