Skip to content

Commit

Permalink
feat: 转码视频支持保留元数据 TencentBlueKing#2598
Browse files Browse the repository at this point in the history
  • Loading branch information
felixncheng committed Sep 26, 2024
1 parent 4f10008 commit 3994169
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ import com.tencent.bkrepo.media.config.MediaProperties
import com.tencent.bkrepo.media.stream.TranscodeParam
import com.tencent.bkrepo.media.stream.TranscodeConfig
import com.tencent.bkrepo.media.stream.TranscodeHelper
import com.tencent.bkrepo.repository.api.MetadataClient
import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

/**
* 视频转码服务
* */
@Service
class TranscodeService(private val tokenService: TokenService, private val mediaProperties: MediaProperties) :
class TranscodeService(
private val tokenService: TokenService,
private val mediaProperties: MediaProperties,
private val metadataClient: MetadataClient,
) :
ArtifactService() {

/**
Expand Down Expand Up @@ -63,6 +69,13 @@ class TranscodeService(private val tokenService: TokenService, private val media
val context = ArtifactUploadContext(repo, newArtifactFile, newArtifactInfo)
repository.upload(context)
logger.info("Upload new file[$newArtifactInfo]")
// 复制原有视频的metadata
val originMetadata =
metadataClient.listMetadata(projectId, repoName, originArtifactInfo.getArtifactFullPath()).data
originMetadata?.let {
val copyRequest = MetadataSaveRequest(projectId, repoName, newArtifactInfo.getArtifactFullPath(), it)
metadataClient.saveMetadata(copyRequest)
}
val removeContext = ArtifactRemoveContext(repo, originArtifactInfo)
repository.remove(removeContext)
logger.info("Delete origin file[$originArtifactInfo]")
Expand Down

0 comments on commit 3994169

Please sign in to comment.