1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AVAssetExportSessionで"Cannot Decode"エラー

Posted at

概要

AVAssetExportSessionを使った動画出力に関するコードを書いていたところ、以下のエラーが発生した。

Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode" UserInfo=0x7fea915d4ed0 {NSLocalizedDescription=Cannot Decode, NSLocalizedFailureReason=The media data could not be decoded. It may be damaged.}

実機だと動くが、シミュレータだと動かない。

やったこと

  • 修正前のソースコード
AVAssetExportSession * session = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetHighestQuality];
session.outputFileType = AVFileTypeMPEG4;
  • 修正後のソースコード
AVAssetExportSession * session = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetPassthrough];
session.outputFileType = AVFileTypeMPEG4;

変更したのは、引数のpresetNameに指定する値。
エンコードしないよう、AVAssetExportPresetPassthroughを指定した。

memo

Presetの値は、以下を参考にした。
https://developer.apple.com/jp/documentation/AVFoundationPG.pdf

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?