video.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package archive
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. const (
  6. // VideoUploadInfo 视频上传完成
  7. VideoUploadInfo = int8(0)
  8. // VideoXcodeSDFail 视频转码失败
  9. VideoXcodeSDFail = int8(1)
  10. // VideoXcodeSDFinish 一转完成
  11. VideoXcodeSDFinish = int8(2)
  12. // VideoXcodeHDFail 二转失败
  13. VideoXcodeHDFail = int8(3)
  14. // VideoXcodeHDFinish 二转完成
  15. VideoXcodeHDFinish = int8(4)
  16. // VideoDispatchRunning 正在分发
  17. VideoDispatchRunning = int8(5)
  18. // VideoDispatchFinish 分发完成
  19. VideoDispatchFinish = int8(6)
  20. // VideoStatusOpen 视频开放浏览
  21. VideoStatusOpen = int16(0)
  22. // VideoStatusAccess 视频会员可见
  23. VideoStatusAccess = int16(10000)
  24. // VideoStatusWait 视频待审
  25. VideoStatusWait = int16(-1)
  26. // VideoStatusRecicle 视频被打回
  27. VideoStatusRecicle = int16(-2)
  28. // VideoStatusLock 视频被锁定
  29. VideoStatusLock = int16(-4)
  30. // VideoStatusXcodeFail 视频转码失败
  31. VideoStatusXcodeFail = int16(-16)
  32. // VideoStatusSubmit 视频创建已提交
  33. VideoStatusSubmit = int16(-30)
  34. // VideoStatusDelete 视频被删除
  35. VideoStatusDelete = int16(-100)
  36. // XcodeFailZero 转码失败
  37. XcodeFailZero = 0
  38. // SrcTypeForVupload 合作方嵌套
  39. SrcTypeForVupload = "vupload"
  40. // SrcTypeForQQ 腾讯视频
  41. SrcTypeForQQ = "qq"
  42. // SrcTypeForHunan 湖南
  43. SrcTypeForHunan = "hunan"
  44. // SrcTypeForSohu 搜狐
  45. SrcTypeForSohu = "sohu"
  46. )
  47. var (
  48. // XcodeFailCodes is bvc message mapping int value.
  49. //http://git.bilibili.co/bili_xcode/bili_xcode_docs/blob/master/%E7%B3%BB%E7%BB%9F%E6%95%B0%E6%8D%AE/%E8%BD%AC%E7%A0%81%E9%94%99%E8%AF%AF%E5%8E%9F%E5%9B%A0.md
  50. XcodeFailCodes = map[string]int8{
  51. "FileDataUnrecognized": 1, // 上传文件不是视频
  52. "VideoTrackAbsent": 2, // 没有视频轨
  53. "AudioTrackAbsent": 3, // 没有音频轨
  54. "VideoTrackEmpty": 4, // 视频轨无有效内容
  55. "AudioTrackEmpty": 5, // 音频轨无有效内容
  56. "DurationOverflow": 6, // 视频过长
  57. "VideoTooNarrow": 7, // 画面太窄
  58. "VideoTooFlat": 8, // 画面太扁
  59. "DataCorrupted": 9, // 文件损坏
  60. "WatermarkDownloadFail": 10, // 水印图片损坏
  61. "DurationUnderflow": 11, // 可检测到的时长不足一秒
  62. "StreamDataCorrupted": 12, // 文件编码数据错误
  63. "IncorrectDataPackaging": 13, // 文件的封包数据错误
  64. "UntolerableTimestampJump": 14, // 文件中时间戳有跳变
  65. "UntolerableTimestampStretch": 15, // 文件中时间戳异常
  66. "AACDataCorrupted": 16, // AAC音频数据错误
  67. }
  68. // XcodeFailMsgs is int value mapping comment.
  69. XcodeFailMsgs = map[int8]string{
  70. 1: "文件格式错误,请检查是否上传了错误文件并尝试重新上传",
  71. 2: "无视频轨,请补充视频轨并重新压制上传",
  72. 3: "无音频轨,请补充音频轨并重新压制上传",
  73. 4: "视频轨无有效内容,请补充缺失的视频数据重新压制上传",
  74. 5: "音频轨无有效内容,请补充缺失的音频数据重新压制上传",
  75. 6: "单个视频时长超过10小时,请剪辑后通过分P上传",
  76. 7: "视频画面过窄,请纵向裁剪视频后重新上传",
  77. 8: "视频画面过扁,请横向裁剪视频后重新上传",
  78. 9: "视频数据有误,请重新编码后重新上传",
  79. 10: "水印图片损坏",
  80. 11: "单个视频时长不足1秒,请检查视频时长并尝试重新上传",
  81. 12: "文件编码数据错误",
  82. 13: "文件封包数据错误,请重新压制后上传",
  83. 14: "视频时间戳有异常,请修正后重新压制上传",
  84. 15: "视频时间戳有异常,请检查音视频数据并重新压制上传",
  85. 16: "AAC音频数据错误,请重新使用AAC编码后上传",
  86. }
  87. )
  88. // Video is archive_video model.
  89. type Video struct {
  90. ID int64
  91. Filename string
  92. Cid int64
  93. Aid int64
  94. Title string
  95. Desc string
  96. SrcType string
  97. Duration int64
  98. Filesize int64
  99. Resolutions string
  100. Playurl string
  101. FailCode int8
  102. Index int
  103. Attribute int32
  104. XcodeState int8
  105. Status int16
  106. WebLink string
  107. Dimensions string
  108. CTime xtime.Time
  109. MTime xtime.Time
  110. }
  111. //AuditParam is from video audit
  112. type AuditParam struct {
  113. IsAudit bool
  114. }
  115. // AttrVal get attribute value.
  116. func (v *Video) AttrVal(bit uint) int32 {
  117. return (v.Attribute >> bit) & int32(1)
  118. }
  119. // AttrSet set attribute value.
  120. func (v *Video) AttrSet(vl int32, bit uint) {
  121. v.Attribute = v.Attribute&(^(1 << bit)) | (vl << bit)
  122. }