Selecting a correct order of API call sequences is important

In short, ffmpeg changes its API in recent versions. One of them is marking AVStream.codec as deprecated. On other side, a AVCodecParameters * AVStream.codecpar was added for codec information described in the stream. To decode data read from stream correctly, we must create a AVCodecContext through avcodec_alloc_context3(), copy codec information from AVStream.codecpar to this allocated AVCodecContext, and call avcodec_open2() to assign this AVCodecContext to AVCodec found by avcodec_finder_decoder() call.

Here is the point. We must call avcodec_parameters_to_context() to copy codec information to AVCodecContext before we call avcodec_open2() to assign AVCodecContext to AVCodec. If we incorrectly reversed this order, say, called avcodec_open2() before avcodec_parameters_to_context(), we can still decode many videos correctly, but we will encounter strange behavior when we try to play back .mkv or .mp4 files – Each call to decoding function will fail.

A simple shell script integrated to Xcode to generate and copy architecture adaptive dylib in

if [ "$CONFIGURATION" == "Debug" ]; then





for a in $ARCHS; do



lipo "$LIBFFMPEG_DIR/lib/libffmpeg.dylib" $EXTRACT_ARCHS -output "$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/libffmpeg.dylib"

if [ "$CODE_SIGNING_REQUIRED" == "YES" ]; then



install_name_tool -change "libffmpeg.dylib" "@executable_path/libffmpeg.dylib" "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH"

Problem again. Assembly generated by clang or written manually, using integrated assembler or not

Simply, clang has an option '--no-integrated-as' so that the compiler invokes apple’s standalone 'as' assembler instead of using clang’s built-in. But, either has its own lost pieces.

  • Without '--no-integrated-as', clang would use its internal assembler. Unfortunately it doesn’t recognize the mnemonic 'ldmltfd'
  • With '--no-integrated-as', apple’s 'as’ assembler reports an error in pesudo instruction '.ios_version_min', which was apparently generated by clang itself.

Therefore I have no choice except for changing 'ldmltfd' to two simple instructions…