123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- import UIKit
- public class PQVideoMakeEventTrackModel: NSObject {
-
- public var entrance: videoMakeEntranceType = .entrancePublicTabCompose {
- didSet {
- isPureUploadVideo = entrance == .entrancePublicTabUpload
- isReproduction = entrance == .entranceReproduction
- }
- }
-
- public var draftId: String?
-
- public var projectId: String?
-
- public var fatherProjectId: String?
-
- public var rootProjectId: String?
-
- public var fatherDraftId: String?
-
- public var title: String?
-
- public var videoDes: String?
-
- public var coverUrl: String?
-
- public var videoId: String?
-
- public var editTimeCost: Float64 = 0
-
- public var composeTimeCost: Float64 = 0
-
- public var uploadTimeCost: Float64 = 0
-
- public var isPureUploadVideo: Bool = false
-
- public var isReproduction: Bool = false
-
- public var isCopyVideo: Bool = false
-
- public var sectionNum: Int = 1
-
- public var secTextLength: [Int] = Array<Int>.init()
-
- public var secLocalImageNum: [Int] = Array<Int>.init()
-
- public var secLocalGifNum: [Int] = Array<Int>.init()
-
- public var secLocalVideoNum: [Int] = Array<Int>.init()
-
- public var secCloudImageNum: [Int] = Array<Int>.init()
-
- public var secCloudGifNum: [Int] = Array<Int>.init()
-
- public var secCloudVideoNum: [Int] = Array<Int>.init()
-
- public var secTextToSpeechMaterial: [String] = Array<String>.init()
-
- public var secTextToSpeechTime: [Int64] = Array<Int64>.init()
-
- public var secSpeechToTextTime: [Int64] = Array<Int64>.init()
-
- public var startUploadDate: Float64 = 0
-
- public var endUploadDate: Float64 = 0 {
- didSet {
- uploadTimeCost = (endUploadDate - startUploadDate) * 1000
- }
- }
-
- public var musicName: String = ""
-
- public var musicId: String = ""
-
- public var musicUrl: String = ""
-
- public var musicType: String = ""
-
- public var isMusicClip: Bool = false
-
- public var canvasRatio: String = "original"
-
- public var syncedUpVideoNumber: Int = 0
-
- public var syncedUpImageNumber: Int = 0
-
- public var syncedUpMusicId: String = ""
-
- public var syncedUpMusicName: String = ""
-
- public var syncedUpVideoDuration: Float64 = 0
-
- public var syncedUpOriginalMaterialDuration: Float64 = 0
-
- public var syncedUpRhythmNumber: Int = 2
- override init() {
- super.init()
- }
-
-
- init(projectModel: PQEditProjectModel?, reCreateData: PQReCreateModel?) {
- super.init()
- if projectModel != nil {
- draftId = projectModel?.draftboxId
- projectId = projectModel?.projectId
- sectionNum = projectModel?.sData?.sections.count ?? 1
- if projectModel?.sData?.sections != nil, (projectModel?.sData?.sections.count ?? 0) > 0 {
- for section in (projectModel?.sData?.sections)! {
- if section.sectionType == "normal" {
-
- let voiceType: VOICETYPT? = VOICETYPT(rawValue: section.sectionTimeline?.audioTrack?.audioTrackMaterials.first?.voiceType ?? "")
- if voiceType == .SPEECH || voiceType == .LOCAL {
- secTextLength.append(section.getInputSubtitle().count)
- } else {
- secTextLength.append(section.sectionText.count)
- }
-
- secTextToSpeechMaterial.append(section.sectionTimeline?.audioTrack?.audioTrackMaterials.first?.produceVoiceConfig?.voice ?? "")
-
- var duration: Float64 = 0
- if voiceType != nil && section.audioFilePath.count > 0 {
- let audioAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + section.audioFilePath), options: avAssertOptions)
- duration = Float64(audioAsset.duration.seconds * 1000)
- }
- if voiceType == .SPEECH || voiceType == .LOCAL {
- secSpeechToTextTime.append(Int64(duration))
- secTextToSpeechTime.append(0)
- } else {
- secTextToSpeechTime.append(Int64(duration))
- secSpeechToTextTime.append(0)
- }
-
- var localImageCount: Int = 0
-
- var localGifCount: Int = 0
-
- var localVideoCount: Int = 0
-
- var netImageCount: Int = 0
-
- var netGifCount: Int = 0
-
- var netVideoCount: Int = 0
- if section.sectionTimeline?.visionTrack?.visionTrackMaterials != nil, (section.sectionTimeline?.visionTrack?.visionTrackMaterials.count ?? 0) > 0 {
- for visionMaterial in (section.sectionTimeline?.visionTrack?.visionTrackMaterials)! {
- switch visionMaterial.type {
- case "image":
- if visionMaterial.netResCoverImageURL != nil, (visionMaterial.netResCoverImageURL?.count ?? 0) > 0 {
- netImageCount += 1
- } else {
- localImageCount += 1
- }
- case "gif":
- if visionMaterial.netResCoverImageURL != nil, (visionMaterial.netResCoverImageURL?.count ?? 0) > 0 {
- netGifCount += 1
- } else {
- localGifCount += 1
- }
- case "video":
- if visionMaterial.netResUrl.count > 0 {
- netVideoCount += 1
- } else {
- localVideoCount += 1
- }
- default:
- break
- }
- }
- }
-
- secLocalImageNum.append(localImageCount)
-
- secLocalGifNum.append(localGifCount)
-
- secLocalVideoNum.append(localVideoCount)
-
- secCloudImageNum.append(netImageCount)
-
- secCloudGifNum.append(netGifCount)
-
- secCloudVideoNum.append(netVideoCount)
- } else {
- sectionNum = sectionNum - 1
- if sectionNum <= 0 {
- sectionNum = 1
- }
- }
- }
- }
- }
- if reCreateData != nil {
- fatherProjectId = reCreateData?.projectId
- rootProjectId = reCreateData?.rootProjectId ?? reCreateData?.projectId
- fatherDraftId = reCreateData?.draftboxId
- }
- }
-
-
- public func toParams() -> [String: Any] {
- var eventTrackDic = Dictionary<String, Any>.init()
-
- eventTrackDic["entrance"] = entrance.rawValue
-
- eventTrackDic["videoId"] = videoId ?? ""
-
- eventTrackDic["draftId"] = draftId ?? ""
-
- eventTrackDic["projectId"] = projectId ?? ""
-
- eventTrackDic["fatherProjectId"] = fatherProjectId ?? ""
-
- eventTrackDic["rootProjectId"] = rootProjectId ?? ""
-
- eventTrackDic["fatherDraftId"] = fatherDraftId ?? ""
-
- eventTrackDic["title"] = title ?? ""
-
- eventTrackDic["description"] = videoDes ?? ""
-
- eventTrackDic["coverUrl"] = coverUrl ?? ""
-
- eventTrackDic["editTimeCost"] = Int64(editTimeCost)
-
- eventTrackDic["composeTimeCost"] = Int64(composeTimeCost)
-
- eventTrackDic["uploadTimeCost"] = Int64(uploadTimeCost)
-
- eventTrackDic["isPureUploadVideo"] = isPureUploadVideo
-
- eventTrackDic["isReproduction"] = isReproduction
-
- eventTrackDic["isCopyVideo"] = isCopyVideo
-
- eventTrackDic["sectionNum"] = entrance == .entrancePublicTabUpload ? 0 : sectionNum
-
- eventTrackDic["secTextLength"] = secTextLength
-
- eventTrackDic["secLocalImageNum"] = secLocalImageNum
-
- eventTrackDic["secLocalGifNum"] = secLocalGifNum
-
- eventTrackDic["secLocalVideoNum"] = secLocalVideoNum
-
- eventTrackDic["secCloudImageNum"] = secCloudImageNum
-
- eventTrackDic["secCloudGifNum"] = secCloudGifNum
-
- eventTrackDic["secCloudVideoNum"] = secCloudVideoNum
-
- eventTrackDic["secTextToSpeechMaterial"] = secTextToSpeechMaterial
-
- eventTrackDic["secTextToSpeechTime"] = secTextToSpeechTime
-
- eventTrackDic["secSpeechToTextTime"] = secSpeechToTextTime
-
- eventTrackDic["abInfoData"] = dictionaryToJsonString(PQSingletoMemoryUtil.shared.abInfoData) ?? ""
-
- eventTrackDic["musicName"] = musicName
-
- eventTrackDic["musicId"] = musicId
-
- eventTrackDic["musicUrl"] = musicUrl
-
- eventTrackDic["musicType"] = musicType
-
- if musicType.count > 0 {
- eventTrackDic["isMusicClip"] = isMusicClip
- } else {
- eventTrackDic["isMusicClip"] = ""
- }
-
- eventTrackDic["canvasRatio"] = canvasRatio
-
- eventTrackDic["syncedUpVideoNumber"] = syncedUpVideoNumber
-
- eventTrackDic["syncedUpImageNumber"] = syncedUpImageNumber
-
- eventTrackDic["syncedUpMusicId"] = syncedUpMusicId
-
- eventTrackDic["syncedUpMusicName"] = syncedUpMusicName
-
- eventTrackDic["syncedUpVideoDuration"] = syncedUpVideoDuration
-
- eventTrackDic["syncedUpOriginalMaterialDuration"] = syncedUpOriginalMaterialDuration
-
- eventTrackDic["syncedUpRhythmNumber"] = syncedUpRhythmNumber
- BFLog(message: "创作工具埋点信息数据-\(eventTrackDic)")
- return eventTrackDic
- }
- }
|