• sharpbai's avatar
    avcodec/videotoolboxenc: fix encoding frame crash on iOS 11 · 6966548c
    sharpbai authored
    On iOS 11, encoding a frame may return error with log
    "Error encoding frame 0", which means vtenc_output_callback
    is called with status=0 and sample_buffer=NULL. Then the
    encoding session will be crashed on next callback wether or not
    closing the codec context.
    
    Let us look through the link below introducing VTCompressionOutputCallback,
    
    https://developer.apple.com/documentation/videotoolbox/vtcompressionoutputcallback?language=objc
    
    "status=0" (noErr) means compression was successful.
    "sampleBuffer=NULL" means the frame was dropped when compression
    was successful (status=0) or compression was not successful (status!=0).
    
    So we should not set AVERROR_EXTERNAL on "status=0" and "sample_buffer=NULL"
    as it is not a error.
    
    The fix is that we only set AVERROR_EXTERNAL with status value non zero.
    When sample_buffer is NULL and status value is zero, we simply return
    with no other operation.
    
    This crash often occurs on iOS 11 for example encoding 720p@25fps.
    Signed-off-by: 's avatarsharpbai <sharpbai@gmail.com>
    Signed-off-by: 's avatarRick Kern <kernrj@gmail.com>
    6966548c
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
configure Loading commit data...