Opened 8 years ago

Closed 8 years ago

#5347 closed defect (fixed)

Use of borderw with attached font crashes ffmpeg

Reported by: Mulvya Owned by:
Priority: important Component: avfilter
Version: git-master Keywords: drawtext crash SIGSEGV
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Use of command below causes ffmpeg to crash. Use of same command without borderw results in successful completion. Use of same command with borderw but with cour.ttf (Courier) results in successful completion.

Using 2016-03-17 Zeranoe build on Windows 7 Ultimate 64-bit (no SP installed). Behaviour reproduced on another system with same OS and set of font files.

Command:

ffmpeg -f lavfi -i "color=black:s=1280x720" -filter_complex "drawtext=fontfile=bpmono.ttf:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5" -c:v libx264 -preset veryfast -t 5 textwithborder.mp4 -report

Report:

ffmpeg started on 2016-03-17 at 15:50:25
Report written to "ffmpeg-20160317-155025.log"
Command line:
ffmpeg -f lavfi -i "color=black:s=1280x720" -filter_complex "drawtext=fontfile=bpmono.ttf:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5" -c:v libx264 -preset veryfast -t 5 textwithborder.mp4 -report
ffmpeg version N-79068-g6b7ce0e Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.103 / 57. 28.103
  libavformat    57. 28.102 / 57. 28.102
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'lavfi'.
Reading option '-i' ... matched as input file with argument 'color=black:s=1280x720'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument 'drawtext=fontfile=bpmono.ttf:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'libx264'.
Reading option '-preset' ... matched as AVOption 'preset' with argument 'veryfast'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '5'.
Reading option 'textwithborder.mp4' ... matched as output file.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option filter_complex (create a complex filtergraph) with argument drawtext=fontfile=bpmono.ttf:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file color=black:s=1280x720.
Applying option f (force format) with argument lavfi.
Successfully parsed a group of options.
Opening an input file: color=black:s=1280x720.
detected 4 logical cores
[Parsed_color_0 @ 00000000003cb3e0] Setting 'color' to value 'black'
[Parsed_color_0 @ 00000000003cb3e0] Setting 's' to value '1280x720'
[Parsed_color_0 @ 00000000003cb3e0] size:1280x720 rate:25/1 duration:-1.000000 sar:1/1
[AVFilterGraph @ 000000000056ae00] query_formats: 2 queried, 1 merged, 0 already done, 0 delayed
[lavfi @ 00000000003c9dc0] All info found
Input #0, lavfi, from 'color=black:s=1280x720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 1, 1/25: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'fontfile' to value 'bpmono.ttf'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'text' to value 'Hello World'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'fontcolor' to value 'white@1.0'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'fontsize' to value '16'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'borderw' to value '5'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'x' to value 'w-tw-10'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'y' to value '10'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'box' to value '1'
[Parsed_drawtext_0 @ 00000000005e7240] Setting 'boxcolor' to value 'black@0.5'
Parsing a group of options: output file textwithborder.mp4.
Applying option c:v (codec name) with argument libx264.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 5.
Successfully parsed a group of options.
Opening an output file: textwithborder.mp4.
[file @ 00000000005e9200] Setting default whitelist 'file'
Successfully opened the file.
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'fontfile' to value 'bpmono.ttf'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'text' to value 'Hello World'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'fontcolor' to value 'white@1.0'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'fontsize' to value '16'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'borderw' to value '5'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'x' to value 'w-tw-10'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'y' to value '10'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'box' to value '1'
[Parsed_drawtext_0 @ 00000000005e73c0] Setting 'boxcolor' to value 'black@0.5'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'time_base' to value '1/25'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 00000000005e7240] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 00000000005e7240] w:1280 h:720 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[format @ 00000000005e7600] compat: called with args=[yuv420p|yuvj420p|yuv422p|yuvj422p|yuv444p|yuvj444p|nv12|nv16|nv21]
[format @ 00000000005e7600] Setting 'pix_fmts' to value 'yuv420p|yuvj420p|yuv422p|yuvj422p|yuv444p|yuvj444p|nv12|nv16|nv21'
[AVFilterGraph @ 00000000005e30c0] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[libx264 @ 00000000005f44a0] using mv_range_thread = 56
[libx264 @ 00000000005f44a0] using SAR=1/1
[libx264 @ 00000000005f44a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 LZCNT BMI2
[libx264 @ 00000000005f44a0] profile High, level 3.1
[libx264 @ 00000000005f44a0] 264 - core 148 r2665 a01e339 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'textwithborder.mp4':
  Metadata:
    encoder         : Lavf57.28.102
    Stream #0:0, 0, 1/12800: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.28.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 (rawvideo) -> drawtext
  drawtext -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[rawvideo @ 00000000003ca3c0] PACKET SIZE: 1382400, STRIDE: 1920
[Parsed_drawtext_0 @ 00000000005e73c0] Copying data in avfilter.

Windows Error:

Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	ffmpeg.exe
  Application Version:	0.0.0.0
  Application Timestamp:	a528a508
  Fault Module Name:	StackHash_a90e
  Fault Module Version:	6.1.7600.16385
  Fault Module Timestamp:	4a5be02b
  Exception Code:	c0000374
  Exception Offset:	00000000000c6cd2
  OS Version:	6.1.7600.2.0.0.256.1
  Locale ID:	1033
  Additional Information 1:	a90e
  Additional Information 2:	a90e2c32031d7513030a0c0a3edb6e5d
  Additional Information 3:	ac17
  Additional Information 4:	ac177ea7eaeeb184d564166faca9bf33

Font files bpmono.ttf (error-producing) and cour.ttf (error-free) attached.

Attachments (1)

BPMONO.TTF (97.6 KB ) - added by Mulvya 8 years ago.
font file crashing ffmpeg when drawtext has borderw enabled.

Download all attachments as: .zip

Change History (5)

by Mulvya, 8 years ago

Attachment: BPMONO.TTF added

font file crashing ffmpeg when drawtext has borderw enabled.

comment:1 by Carl Eugen Hoyos, 8 years ago

Component: undeterminedavfilter
Priority: normalimportant
Reproduced by developer: set
Status: newopen
(gdb) r -f lavfi -i "color=black:s=1280x720" -filter_complex "drawtext=fontfile=BPMONO.TTF:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5" -qscale 2 -t 5 out.avi
Starting program: ffmpeg_g -f lavfi -i "color=black:s=1280x720" -filter_complex "drawtext=fontfile=BPMONO.TTF:text='Hello World':fontcolor=white@1.0:fontsize=16:borderw=5:x=w-tw-10:y=10:box=1:boxcolor=black@0.5" -qscale 2 -t 5 out.avi
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
ffmpeg version N-79068-g6b7ce0e Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libfreetype --enable-fontconfig
  libavutil      55. 19.100 / 55. 19.100
  libavcodec     57. 28.103 / 57. 28.103
  libavformat    57. 28.102 / 57. 28.102
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 39.102 /  6. 39.102
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
[New Thread 0x7ffff0e05700 (LWP 14955)]
[New Thread 0x7ffff0604700 (LWP 14956)]
[New Thread 0x7fffefe03700 (LWP 14957)]
[New Thread 0x7fffef602700 (LWP 14958)]
[New Thread 0x7fffeee01700 (LWP 14959)]
[New Thread 0x7fffee600700 (LWP 14960)]
[New Thread 0x7fffeddff700 (LWP 14961)]
[New Thread 0x7fffed5fe700 (LWP 14962)]
[New Thread 0x7fffecdfd700 (LWP 14963)]
Input #0, lavfi, from 'color=black:s=1280x720':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
[New Thread 0x7fffec4aa700 (LWP 14964)]
[New Thread 0x7fffebca9700 (LWP 14965)]
[New Thread 0x7fffeb4a8700 (LWP 14966)]
[New Thread 0x7fffeaca7700 (LWP 14967)]
[New Thread 0x7fffea4a6700 (LWP 14968)]
[New Thread 0x7fffe9ca5700 (LWP 14969)]
[New Thread 0x7fffe94a4700 (LWP 14970)]
[New Thread 0x7fffe8ca3700 (LWP 14971)]
[New Thread 0x7fffe84a2700 (LWP 14972)]
[Thread 0x7fffe9ca5700 (LWP 14969) exited]
[Thread 0x7fffe84a2700 (LWP 14972) exited]
[Thread 0x7fffec4aa700 (LWP 14964) exited]
[Thread 0x7fffe8ca3700 (LWP 14971) exited]
[Thread 0x7fffea4a6700 (LWP 14968) exited]
[Thread 0x7fffe94a4700 (LWP 14970) exited]
[Thread 0x7fffebca9700 (LWP 14965) exited]
[Thread 0x7fffeaca7700 (LWP 14967) exited]
[Thread 0x7fffeb4a8700 (LWP 14966) exited]
Please use -q:a or -q:v, -qscale is ambiguous
[New Thread 0x7fffe84a2700 (LWP 14973)]
[New Thread 0x7fffe8ca3700 (LWP 14974)]
[New Thread 0x7fffe94a4700 (LWP 14975)]
[New Thread 0x7fffe9ca5700 (LWP 14976)]
[New Thread 0x7fffec4aa700 (LWP 14977)]
[New Thread 0x7fffebca9700 (LWP 14978)]
[New Thread 0x7fffeb4a8700 (LWP 14979)]
[New Thread 0x7fffeaca7700 (LWP 14980)]
[New Thread 0x7fffea4a6700 (LWP 14981)]
[New Thread 0x7fffe7ca1700 (LWP 14982)]
[New Thread 0x7fffe74a0700 (LWP 14983)]
[New Thread 0x7fffe6c9f700 (LWP 14984)]
[New Thread 0x7fffe649e700 (LWP 14985)]
[New Thread 0x7fffe5c9d700 (LWP 14986)]
[New Thread 0x7fffe549c700 (LWP 14987)]
[New Thread 0x7fffe4c9b700 (LWP 14988)]
[New Thread 0x7fffe449a700 (LWP 14989)]
[New Thread 0x7fffe3c99700 (LWP 14990)]
Output #0, avi, to 'out.avi':
  Metadata:
    ISFT            : Lavf57.28.102
    Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.28.103 mpeg4
    Side data:
      cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
Stream mapping:
  Stream #0:0 (rawvideo) -> drawtext
  drawtext -> Stream #0:0 (mpeg4)
Press [q] to stop, [?] for help

Program received signal SIGSEGV, Segmentation fault.
draw_text (ctx=ctx@entry=0x1e2baa0, frame=0x1ee23c0, width=1280, height=720)
    at libavfilter/vf_drawtext.c:1228
1228            y_min = FFMIN(glyph->bbox.yMin, y_min);
(gdb) bt
#0  draw_text (ctx=ctx@entry=0x1e2baa0, frame=0x1ee23c0, width=1280, height=720)
    at libavfilter/vf_drawtext.c:1228
#1  0x00000000004f30c0 in filter_frame (inlink=inlink@entry=0x1e39d60, frame=0x1)
    at libavfilter/vf_drawtext.c:1351
#2  0x00000000004b805e in ff_filter_frame_framed (link=link@entry=0x1e39d60, frame=0x1)
    at libavfilter/avfilter.c:1123
#3  0x00000000004b8e47 in ff_filter_frame (link=link@entry=0x1e39d60, frame=0x1ee2180)
    at libavfilter/avfilter.c:1221
#4  0x00000000004bcfc2 in request_frame (link=0x1e39d60) at libavfilter/buffersrc.c:450
#5  0x00000000004bd25b in av_buffersrc_add_frame_internal (ctx=ctx@entry=0x1e39160,
    frame=frame@entry=0x1ee1d00, flags=flags@entry=4) at libavfilter/buffersrc.c:239
#6  0x00000000004bd70d in av_buffersrc_add_frame_flags (ctx=0x1e39160,
    frame=frame@entry=0x1ee1d00, flags=flags@entry=4) at libavfilter/buffersrc.c:164
#7  0x0000000000499f92 in decode_video (ist=ist@entry=0x1e1e280,
    pkt=pkt@entry=0x7fffffffda00, got_output=got_output@entry=0x7fffffffd6fc)
    at ffmpeg.c:2187
#8  0x000000000049d1bd in process_input_packet (no_eof=0, pkt=0x7fffffffd9a0, ist=0x1e1e280)
    at ffmpeg.c:2331
#9  process_input (file_index=0) at ffmpeg.c:4001
#10 transcode_step () at ffmpeg.c:4089
#11 transcode () at ffmpeg.c:4143
#12 0x000000000047f29b in main (argc=<optimized out>, argv=0x7fffffffdc48) at ffmpeg.c:4334
(gdb) disass $pc-32,$pc+32
Dump of assembler code from 0x4f2522 to 0x4f2562:
   0x00000000004f2522 <draw_text+546>:  rex.R and $0x40,%al
   0x00000000004f2525 <draw_text+549>:  callq  0x107fde0 <av_tree_find>
   0x00000000004f252a <draw_text+554>:  test   %rax,%rax
   0x00000000004f252d <draw_text+557>:  mov    %rax,0x70(%rsp)
   0x00000000004f2532 <draw_text+562>:  mov    0x40(%rsp),%r8d
   0x00000000004f2537 <draw_text+567>:  movslq 0x20(%rsp),%r9
   0x00000000004f253c <draw_text+572>:  je     0x4f2f19 <draw_text+3097>
=> 0x00000000004f2542 <draw_text+578>:  mov    0x70(%rax),%rdx
   0x00000000004f2546 <draw_text+582>:  movslq %r14d,%r14
   0x00000000004f2549 <draw_text+585>:  movzbl 0x0(%r13),%ecx
   0x00000000004f254e <draw_text+590>:  movslq %ebx,%rbx
   0x00000000004f2551 <draw_text+593>:  movslq %r15d,%r15
   0x00000000004f2554 <draw_text+596>:  cmp    %rdx,%r14
   0x00000000004f2557 <draw_text+599>:  cmovg  %rdx,%r14
   0x00000000004f255b <draw_text+603>:  mov    0x80(%rax),%rdx
End of assembler dump.
(gdb) info register
rax            0x0      0
rbx            0x7d00   32000
rcx            0x0      0
rdx            0x7ffff5050678   140737304135288
rsi            0x1      1
rdi            0x0      0
rbp            0x1e2bb40        0x1e2bb40
rsp            0x7fffffffce30   0x7fffffffce30
r8             0x0      0
r9             0xffffffffffff8300       -32000
r10            0x0      0
r11            0x7ffff4d360f2   140737300881650
r12            0x1e2baa0        31636128
r13            0x1e2bb7d        31636349
r14            0x7d00   32000
r15            0xffff8300       4294935296
rip            0x4f2542 0x4f2542 <draw_text+578>
eflags         0x10206  [ PF IF RF ]
cs             0x33     51
ss             0x2b     43
ds             0x0      0
es             0x0      0
fs             0x0      0
gs             0x0      0

comment:2 by Carl Eugen Hoyos, 8 years ago

Keywords: drawtext crash SIGSEGV added

comment:3 by Carl Eugen Hoyos, 8 years ago

Summary: Use of borderw with attached font crashes ffmpeg on WindowsUse of borderw with attached font crashes ffmpeg

comment:4 by Michael Niedermayer, 8 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.