mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.25k stars 2.9k forks source link

HEVC crash with videotoolbox hwdec #6375

Closed sergiou87 closed 5 years ago

sergiou87 commented 5 years ago

mpv version and platform

mpv 0.29.1 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects built on Tue Nov 6 17:30:25 GMT 2018 ffmpeg library versions: libavutil 56.22.100 libavcodec 58.35.100 libavformat 58.20.100 libswscale 5.3.100 libavfilter 7.40.101 libswresample 3.3.100 ffmpeg version: 4.1

macOS 10.14.2 (18C54)

Reproduction steps

Play this file in macOS or iOS using videotoolbox hwdec: hevc_crash_mpv.mkv.zip

mpv hevc_crash_mpv.mkv --hwdec=yes

Expected behavior

It should play.

Actual behavior

It crashes.

Other HEVC files work with videotoolbox hwdec. And it plays fine without hwdec.

Log file

mpv-crash-log.txt

Stack trace on iOS:

* thread #9, name = 'mpv/mpv core', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x000000010900227f example-mpv-ios`ff_videotoolbox_hvcc_extradata_create + 47
    frame #1: 0x0000000109002f17 example-mpv-ios`videotoolbox_start + 423
    frame #2: 0x000000010900280b example-mpv-ios`videotoolbox_common_init + 171
    frame #3: 0x0000000108d09578 example-mpv-ios`ff_get_format + 744
    frame #4: 0x0000000108eb20cc example-mpv-ios`decode_nal_unit + 1388
    frame #5: 0x0000000108eb0ccb example-mpv-ios`hevc_decode_frame + 779
    frame #6: 0x0000000108d074ff example-mpv-ios`decode_receive_frame_internal + 415
    frame #7: 0x0000000108d07311 example-mpv-ios`avcodec_send_packet + 209
  * frame #8: 0x0000000108a3f9fa example-mpv-ios`do_send_packet(vd=0x00006000000e3c40, pkt=0x000060c00017c780) at vd_lavc.c:965 [opt]
    frame #9: 0x00000001089de4f5 example-mpv-ios`lavc_process(f=0x00006000000e3c40, eof_flag=0x00007f90d5315a2d, send=(example-mpv-ios`send_packet at vd_lavc.c:993), receive=<unavailable>) at f_decoder_wrapper.c:713 [opt]
    frame #10: 0x00000001089e6952 example-mpv-ios`mp_filter_run(filter=<unavailable>) at filter.c:194 [opt]
    frame #11: 0x00000001089e6b20 example-mpv-ios`mp_pin_out_request_data [inlined] filter_recursive(f=<unavailable>) at filter.c:151 [opt]
    frame #12: 0x00000001089e6aff example-mpv-ios`mp_pin_out_request_data(p=0x000060400011ae00) at filter.c:256 [opt]
    frame #13: 0x00000001089e6dee example-mpv-ios`mp_pin_out_read(p=0x000060400011ae00) at filter.c:269 [opt]
    frame #14: 0x0000000108a27d34 example-mpv-ios`write_video at video.c:471 [opt]
    frame #15: 0x0000000108a27ada example-mpv-ios`write_video(mpctx=<unavailable>) at video.c:994 [opt]
    frame #16: 0x0000000108a23c00 example-mpv-ios`run_playloop(mpctx=0x00007f90d5806640) at playloop.c:1099 [opt]
    frame #17: 0x0000000108a1e3f4 example-mpv-ios`mp_play_files [inlined] play_current_file(mpctx=<unavailable>) at loadfile.c:1365 [opt]
    frame #18: 0x0000000108a1d936 example-mpv-ios`mp_play_files(mpctx=0x00007f90d5806640) at loadfile.c:1530 [opt]
    frame #19: 0x0000000108a08130 example-mpv-ios`core_thread(p=0x00007f90d5806640) at client.c:524 [opt]
    frame #20: 0x000000010f558305 libsystem_pthread.dylib`_pthread_body + 126
    frame #21: 0x000000010f55b26f libsystem_pthread.dylib`_pthread_start + 70
    frame #22: 0x000000010f557415 libsystem_pthread.dylib`thread_start + 13

Sample files

hevc_crash_mpv.mkv.zip

sergiou87 commented 5 years ago

It looks very similar to https://github.com/mpv-player/mpv/issues/5052#issuecomment-340893210

@tmm1 any idea what could it be? 😅

sergiou87 commented 5 years ago

Ok, seems to be a ffmpeg bug. My friend @rcombs has a patch that seems to fix the issue (🙇🙇🙇🙇🙇🙇🙇🙇🙇), we're going to test it a bit more and submit it to ffmpeg 😄

Akemi commented 5 years ago

yeah, definitely an ffmpeg bug.

ffmpeg -hwaccel videotoolbox -i /Users/Akemi/Downloads/hevc_crash_mpv.mkv  -f null -
ffmpeg version git-2018-11-14-752659327d Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-7526593 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --cc=/usr/bin/clang --host-cflags='-Os -w -pipe -march=native -mmacosx-version-min=10.14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/' --host-ldflags='-L/usr/local/opt/openssl/lib -L/usr/local/opt/libxml2/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libgsm --enable-librsvg --enable-libsoxr --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libxml2 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --disable-decoder=jpeg2000 --extra-cflags=-I/usr/local/Cellar/openjpeg/2.3.0/include/openjpeg-2.3 --enable-openssl --enable-libopus --enable-librtmp --enable-librubberband --enable-ffplay --enable-libsnappy --enable-libspeex --enable-libtesseract --enable-libtheora --enable-libwavpack --enable-libwebp --enable-libx265 --enable-lzma --enable-libzmq --enable-libzimg --enable-videotoolbox --enable-opencl
  libavutil      56. 23.101 / 56. 23.101
  libavcodec     58. 39.100 / 58. 39.100
  libavformat    58. 22.100 / 58. 22.100
  libavdevice    58.  6.100 / 58.  6.100
  libavfilter     7. 43.100 /  7. 43.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, matroska,webm, from '/Users/Akemi/Downloads/hevc_crash_mpv.mkv':
  Metadata:
    title           : Fringe.S03E01.1080p.BluRay.X265-D3FiL3R
    encoder         : libebml v0.7.8 + libmatroska v0.8.1
    creation_time   : 2016-07-28T21:25:59.000000Z
  Duration: 00:43:58.82, start: 0.000000, bitrate: 9 kb/s
    Stream #0:0: Video: hevc (Main), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (ac3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Segmentation fault: 11
tmm1 commented 5 years ago

Was the patch submitted to ffmpeg-devel?

sergiou87 commented 5 years ago

No idea, tbh, I have to check with @rcombs

tmm1 commented 5 years ago

http://ffmpeg.org/pipermail/ffmpeg-devel/2019-January/238651.html

sergiou87 commented 5 years ago

Yes! That's the one 😄

gunnarmarten commented 5 years ago

Ping @tmm1 . Looks like this patch wasn't merged into ffmpeg master yet.