Opened 9 years ago

Closed 7 years ago

#4897 closed defect (fixed)

decklink output driver segfaults

Reported by: Sesse Owned by:
Priority: important Component: avdevice
Version: git-master Keywords: decklink crash SIGSEGV
Cc: Marton Balint Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hi,

I'm using ffmpeg git as of Sep 19 (e3cf97), compiled with --enable-nonfree --enable-gpl --enable-decklink --enable-shared --enable-debug --disable-stripping. I'm using this command line to try to play files on my SDI card:

./ffmpeg -i file.mp4 -f decklink -pix_fmt uyvy422 -s 1280x720 -r 60000/1001 -ar 48000 -ac 2 'DeckLink Studio 2'

It works fine with some files, but with most it segfaults. An example of a file that segfaults is http://cdn.capped.tv/vhq/cncd_fairlight-ceasefire_all_falls_down.mp4. The stack trace looks like this:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:33
33	../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0  __memcpy_sse2_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:33
#1  0x00007f4dcd8cb24e in av_image_copy_plane (dst=<optimized out>, dst_linesize=2560, src=<optimized out>, 
    src_linesize=2560, bytewidth=2560, height=720) at libavutil/imgutils.c:282
#2  0x00007f4dcd8cb3d3 in av_image_copy (dst_data=0x1f15440, dst_linesizes=0x1f15480, 
    src_data=src_data@entry=0x2035280, src_linesizes=src_linesizes@entry=0x20352c0, pix_fmt=AV_PIX_FMT_UYVY422, 
    width=1280, height=720) at libavutil/imgutils.c:320
#3  0x00007f4dcfcbfbcc in decklink_write_video_packet (pkt=0x7ffc6047baa0, pkt=0x7ffc6047baa0, avctx=0x1ec3f80)
    at libavdevice/decklink_enc.cpp:237
#4  ff_decklink_write_packet (avctx=0x1ec3f80, pkt=0x7ffc6047baa0) at libavdevice/decklink_enc.cpp:419
#5  0x00007f4dcf630a1e in write_packet (pkt=0x7ffc6047baa0, s=0x1ec3f80) at libavformat/mux.c:660
#6  av_interleaved_write_frame (s=s@entry=0x1ec3f80, pkt=0x0, pkt@entry=0x7ffc6047bdd0) at libavformat/mux.c:970
#7  0x000000000042018f in write_frame (s=s@entry=0x1ec3f80, pkt=pkt@entry=0x7ffc6047bdd0, ost=ost@entry=0x1ec5be0)
    at ffmpeg.c:780
#8  0x000000000042359b in do_audio_out (frame=<optimized out>, ost=0x1ec5be0, s=0x1ec3f80) at ffmpeg.c:858
#9  reap_filters (flush=flush@entry=0) at ffmpeg.c:1391
#10 0x0000000000407f61 in transcode_step () at ffmpeg.c:3931
#11 transcode () at ffmpeg.c:3974
#12 main (argc=<optimized out>, argv=<optimized out>) at ffmpeg.c:4157

valgrind complains, among others, about these (I've snipped away many more that seem less relevant):

==22881== Source and destination overlap in memcpy(0x2ef2e840, 0x2ef2e840, 2560)  
==22881==    at 0x4C2D75D: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:915)
==22881==    by 0x741524D: av_image_copy_plane (imgutils.c:282)
==22881==    by 0x74153D2: av_image_copy (imgutils.c:320)
==22881==    by 0x5051BCB: decklink_write_video_packet (decklink_enc.cpp:237)
==22881==    by 0x5051BCB: ff_decklink_write_packet (decklink_enc.cpp:419)
==22881==    by 0x56B2A1D: write_packet (mux.c:660)
==22881==    by 0x56B2A1D: av_interleaved_write_frame (mux.c:970)
==22881==    by 0x42018E: write_frame (ffmpeg.c:780)
==22881==    by 0x42359A: do_audio_out (ffmpeg.c:858)
==22881==    by 0x42359A: reap_filters (ffmpeg.c:1391)
==22881==    by 0x407F60: transcode_step (ffmpeg.c:3931)
==22881==    by 0x407F60: transcode (ffmpeg.c:3974)
==22881==    by 0x407F60: main (ffmpeg.c:4157)
==22881== Invalid read of size 8
==22881==    at 0x4C2D940: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:915)
==22881==    by 0x741524D: av_image_copy_plane (imgutils.c:282)
==22881==    by 0x74153D2: av_image_copy (imgutils.c:320)
==22881==    by 0x5051BCB: decklink_write_video_packet (decklink_enc.cpp:237)
==22881==    by 0x5051BCB: ff_decklink_write_packet (decklink_enc.cpp:419)
==22881==    by 0x56B2A1D: write_packet (mux.c:660)
==22881==    by 0x56B2A1D: av_interleaved_write_frame (mux.c:970)
==22881==    by 0x42018E: write_frame (ffmpeg.c:780)
==22881==    by 0x42359A: do_audio_out (ffmpeg.c:858)
==22881==    by 0x42359A: reap_filters (ffmpeg.c:1391)
==22881==    by 0x407F60: transcode_step (ffmpeg.c:3931)
==22881==    by 0x407F60: transcode (ffmpeg.c:3974)
==22881==    by 0x407F60: main (ffmpeg.c:4157)
==22881==  Address 0x2f210220 is 0 bytes inside a block of size 1,884,191 free'd
==22881==    at 0x4C29E90: free (vg_replace_malloc.c:473)
==22881==    by 0x7407FCE: buffer_replace (buffer.c:119)
==22881==    by 0x7407FCE: av_buffer_unref (buffer.c:129)
==22881==    by 0x7412463: av_frame_unref (frame.c:479)
==22881==    by 0x420ED0: do_video_out (ffmpeg.c:1241)
==22881==    by 0x42332A: reap_filters (ffmpeg.c:1382)
==22881==    by 0x407F60: transcode_step (ffmpeg.c:3931)
==22881==    by 0x407F60: transcode (ffmpeg.c:3974)
==22881==    by 0x407F60: main (ffmpeg.c:4157)

Do you think you could have a look?

Change History (6)

comment:1 by Carl Eugen Hoyos, 9 years ago

Component: undeterminedavdevice
Keywords: decklink crash SIGSEGV added
Priority: normalimportant

Please also provide complete, uncut console output.
(Remember that basically nobody will be able to reproduce, so a solution will have to be guessed, the more information you provide, the more likely this will happen.)

And please consider to test 5965adeb (or the first version that has working decklink support).

comment:2 by Sesse, 9 years ago

Complete console output:

sesse@gruessi:~/compile/ffmpeg$ ./ffmpeg -i /home/sesse/vlc/cncd_fairlight-ceasefire_all_falls_down.mp4 -f decklink -pix_fmt uyvy422 -s 1280x720 -r 50 -ar 48000 -ac 2 'DeckLink Studio 2'
ffmpeg version N-75655-g30ce6fd Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.1 (Debian 5.2.1-15) 20150808
  configuration: --enable-nonfree --enable-gpl --enable-decklink --enable-shared --enable-debug --disable-stripping
  libavutil      55.  2.100 / 55.  2.100
  libavcodec     57.  3.100 / 57.  3.100
  libavformat    57.  2.100 / 57.  2.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6.  9.100 /  6.  5.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.100 /  2.  0.100
  libpostproc    54.  0.100 / 54.  0.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1616040] Unknown cover type: 0x0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/sesse/vlc/cncd_fairlight-ceasefire_all_falls_down.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: isommp423gp5
    creation_time   : 2010-08-07 20:04:08
    genre           : Demoscene
    artist          :  Fairlight
    comment         : Provided with love by Capped.TV - Turning Fruit into Juice since 2007 - Find more info on this vid at http://capped.tv/cncd_fairlight-ceasefire_all_falls_down
    title           : Ceasefire (All falls down..)
    url             : http://capped.tv/cncd_fairlight-ceasefire_all_falls_down
  Duration: 00:04:48.33, start: 0.000000, bitrate: 225 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x540, 6007 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2010-08-07 16:49:58
      handler_name    : Imported with GPAC 0.4.6-DEV (internal rev. 5)
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 93 kb/s (default)
    Metadata:
      creation_time   : 2010-08-07 20:04:25
      handler_name    : GPAC ISO Audio Handler
    Stream #0:2(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
    Metadata:
      creation_time   : 2010-08-07 20:04:25
      handler_name    : GPAC MPEG-4 OD Handler
    Stream #0:3(eng): Data: none (mp4s / 0x7334706D), 0 kb/s (default)
    Metadata:
      creation_time   : 2010-08-07 20:04:25
      handler_name    : GPAC MPEG-4 BIFS Handler
[decklink @ 0x161a020] Found Decklink mode 1280 x 720 with rate 50.00
Output #0, decklink, to 'DeckLink Studio 2':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: isommp423gp5
    url             : http://capped.tv/cncd_fairlight-ceasefire_all_falls_down
    genre           : Demoscene
    artist          :  Fairlight
    comment         : Provided with love by Capped.TV - Turning Fruit into Juice since 2007 - Find more info on this vid at http://capped.tv/cncd_fairlight-ceasefire_all_falls_down
    title           : Ceasefire (All falls down..)
    encoder         : Lavf57.2.100
    Stream #0:0(eng): Video: rawvideo (UYVY / 0x59565955), uyvy422, 1280x720, q=2-31, 200 kb/s, 50 fps, 50 tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2010-08-07 16:49:58
      handler_name    : Imported with GPAC 0.4.6-DEV (internal rev. 5)
      encoder         : Lavc57.3.100 rawvideo
    Stream #0:1(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2010-08-07 20:04:25
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc57.3.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> rawvideo (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[decklink @ 0x161a020] Encoder did not produce proper pts, making some up.
Past duration 0.668327 too large
Segmentation faultepeated 2 times

I'll test 5965adeb at some later point today.

comment:3 by Sesse, 9 years ago

I thought I wrote something here... but long story short, 5965adeb doesn't work for me (somehow the module isn't loaded), and a bisect to try to find some intermediate version that works, proved hard due to other segfaults coming and going.

Running without audio (-an) works, so it's probably related to the resampling.

comment:4 by Marton Balint, 7 years ago

Cc: Marton Balint added

Can you reproduce this with current git master?

comment:5 by Sesse, 7 years ago

Current git master doesn't appear to segfault, but it plays the file extremely unevenly, and says:

More than 1000 frames duplicated

I don't know if there's any audio (I don't have a way to tap that out of my DeckLink card right now).

in reply to:  5 comment:6 by Carl Eugen Hoyos, 7 years ago

Resolution: fixed
Status: newclosed

Replying to Sesse:

Current git master doesn't appear to segfault

Thank you for testing again!
Feel free to find the commit fixing the crash;-)

but it plays the file extremely unevenly, and says:

More than 1000 frames duplicated

You can reproduce this with the following command, not related to decklink:
$ ffmpeg -i cncd_fairlight-ceasefire_all_falls_down.mp4 -r 50 out.mov

Note: See TracTickets for help on using tickets.