Skip to content

Instantly share code, notes, and snippets.

@oozoofrog
Last active September 4, 2016 07:08
Show Gist options
  • Save oozoofrog/1b8305aa7ea88b4030bb1265bfdb1b2a to your computer and use it in GitHub Desktop.
Save oozoofrog/1b8305aa7ea88b4030bb1265bfdb1b2a to your computer and use it in GitHub Desktop.
FFmpeg 3.xで新しく追加されたAPIの分析。 ref: http://qiita.com/funcodes/items/20b7c78723c6d1c4a958
defer {
avcodec_send_packet(avctx, NULL)
while true {
if AVERROR_EOF == avcodec_receive_packet(avctx, frame) {
break
}
}
}
while 0 <= av_read_frame(avctx, packet) {
// avcodec_decode_video2[audio4](...)を下のコードに変更します。
// もっと簡単に出来ると思いますが。サイドーイフェックトを避けるためほとんど変更しないままで適用してみました。
...
var ret = avcodec_send_packet(avctx, packet)
// retがAVERROR(EAGAIN)の場合, receive_frameでAVERROR_EOFが返還されるまで、packet繰り返して送ります。
if 0 > ret && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF {
if 0 > ret { // error
break
}
continue
}
   ret = avcodec_receive_frame(avctx, frame)
if 0 > ret && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF {
if 0 > ret {
break
}
}
// success to get frame
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment