Skip to content

Instantly share code, notes, and snippets.

@norio-nomura
Created December 28, 2014 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norio-nomura/a0c9f9af512c0b49b57d to your computer and use it in GitHub Desktop.
Save norio-nomura/a0c9f9af512c0b49b57d to your computer and use it in GitHub Desktop.
AVMutableComposition使う必要ないのでは?
diff --git a/SimpleGaplessPlayer/HKLGaplessPlayer/AssetReaderFragment.swift b/SimpleGaplessPlayer/HKLGaplessPlayer/AssetReaderFragment.swift
index 9fdd89d..2d41bf4 100644
--- a/SimpleGaplessPlayer/HKLGaplessPlayer/AssetReaderFragment.swift
+++ b/SimpleGaplessPlayer/HKLGaplessPlayer/AssetReaderFragment.swift
@@ -121,7 +121,7 @@ internal class AssetReaderFragment: NSObject {
// 注意点:
// - このビデオトラックにはコンポジション上のビデオトラックを指定すること
// - IOSurfaceで作成しなくても再生できるが、念のため付けておく
- let compoVideoTracks = composition.tracksWithMediaType(AVMediaTypeVideo)
+ let compoVideoTracks = asset.tracksWithMediaType(AVMediaTypeVideo)
var output = AVAssetReaderVideoCompositionOutput(videoTracks: compoVideoTracks,
videoSettings: [kCVPixelBufferPixelFormatTypeKey : kCVPixelFormatType_32BGRA,
kCVPixelBufferIOSurfacePropertiesKey : [:]])
@@ -131,7 +131,7 @@ internal class AssetReaderFragment: NSObject {
output.alwaysCopiesSampleData = false
// コンポジションからアセットリーダーを作成し、アウトプットを接続
- if let reader = AVAssetReader(asset: composition, error: &error) {
+ if let reader = AVAssetReader(asset: asset, error: &error) {
if reader.canAddOutput(output) {
reader.addOutput(output)
}
@hirohitokato
Copy link

ありがとうございます。再生開始時間を指定したいので、AVMutableCompositionは必要なのです。なのですが、そうしないと再生開始までに時間がかかるのが気になりますね…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment