[FFmpeg-user] Segfault for 2 pass x264 encoding

Joakim Simonsson nospam at joakims.com
Fri Jan 18 13:59:02 CET 2013


Hi,

When I transcode some streams with 2-pass x264, ffmpeg segaults. x264
complains about "2nd pass has more frames than 1st pass".

Maybe this is a pure x264 issue and not a ffmpeg one. If so, I appologize
for posting here.

ffmpeg doesn't segfault when transcoding without the audio. I.e. when using
-an in the second pass.
But it segfaults no matter of what audio codec I am using (libmp3lame,
aac, adpcm_ima_wav).

I am using the latest git version of ffmpeg. x264 version, 20121113-1


==The input file to reproduce==

http://joakims.com/vid/tmp/in.ts


==The commands to reproduce==

ffmpeg -i in.ts -c:v libx264 -f mpegts -pass 1 -an -y /dev/null
ffmpeg -i in.ts -c:v libx264 -f mpegts -pass 2 -c:a libmp3lame -b:v 236k
-b:a 128k -y out.ts


==The output==

~/vid/2passfail > ~/dev/3pp/ffmpeg/ffmpeg_g -i in.ts -c:v libx264 -f mpegts
-pass 1 -an -y /dev/null

ffmpeg version N-48990-ga003c5b Copyright (c) 2000-2013 the FFmpeg
developers
  built on Jan 18 2013 12:44:01 with gcc 4.7.2 (GCC)
  configuration: --enable-libx264 --enable-libmp3lame --enable-gpl
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 89.100 / 54. 89.100
  libavformat    54. 61.100 / 54. 61.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x2315ea0] max_analyze_duration 5000000 reached at 5000000
microseconds
Input #0, mpegts, from 'in.ts':
  Duration: 00:02:42.01, start: 1.374944, bitrate: 667 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p, 640x360, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 44100 Hz,
stereo, s16p, 128 kb/s
[libx264 @ 0x231be60] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2
[libx264 @ 0x231be60] profile Main, level 3.0
Output #0, mpegts, to '/dev/null':
  Metadata:
    encoder         : Lavf54.61.100
    Stream #0:0: Video: h264, yuv420p, 640x360, q=-1--1, pass 1, 90k tbn,
25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
frame= 4048 fps=284 q=-1.0 Lsize=    9823kB time=00:02:41.84 bitrate=
497.2kbits/s
video:8628kB audio:0kB subtitle:0 global headers:0kB muxing overhead
13.846040%
[libx264 @ 0x231be60] frame I:73    Avg QP:18.62  size: 19060
[libx264 @ 0x231be60] frame P:1741  Avg QP:22.86  size:  3552
[libx264 @ 0x231be60] frame B:2234  Avg QP:25.91  size:   564
[libx264 @ 0x231be60] consecutive B-frames: 22.9%  7.2%  9.7% 60.2%
[libx264 @ 0x231be60] mb I  I16..4: 20.3%  0.0% 79.7%
[libx264 @ 0x231be60] mb P  I16..4:  8.2%  0.0%  0.0%  P16..4: 60.6%  0.0%
 0.0%  0.0%  0.0%    skip:31.2%
[libx264 @ 0x231be60] mb B  I16..4:  0.4%  0.0%  0.0%  B16..8: 15.9%  0.0%
 0.0%  direct: 3.9%  skip:79.8%  L0:38.4% L1:42.3% BI:19.4%
[libx264 @ 0x231be60] coded y,uvDC,uvAC intra: 37.1% 84.0% 41.8% inter:
7.8% 15.7% 0.5%
[libx264 @ 0x231be60] i16 v,h,dc,p: 44% 30% 19%  6%
[libx264 @ 0x231be60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 23%  9%  6%  6%
 6%  5%  7%  5%
[libx264 @ 0x231be60] i8c dc,h,v,p: 37% 26% 27% 10%
[libx264 @ 0x231be60] Weighted P-Frames: Y:0.6% UV:0.5%
[libx264 @ 0x231be60] kb/s:436.52


~/vid/2passfail > ~/dev/3pp/ffmpeg/ffmpeg_g -i in.ts -c:v libx264 -f mpegts
-pass 2 -c:a libmp3lame -b:v 236k -b:a 128k -y out.ts
ffmpeg version N-48990-ga003c5b Copyright (c) 2000-2013 the FFmpeg
developers
  built on Jan 18 2013 12:44:01 with gcc 4.7.2 (GCC)
  configuration: --enable-libx264 --enable-libmp3lame --enable-gpl
  libavutil      52. 15.100 / 52. 15.100
  libavcodec     54. 89.100 / 54. 89.100
  libavformat    54. 61.100 / 54. 61.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
[mpegts @ 0x16d3e80] max_analyze_duration 5000000 reached at 5000000
microseconds
Input #0, mpegts, from 'in.ts':
  Duration: 00:02:42.01, start: 1.374944, bitrate: 667 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
yuv420p, 640x360, 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x101]: Audio: mp3 ([3][0][0][0] / 0x0003), 44100 Hz,
stereo, s16p, 128 kb/s
[libx264 @ 0x16da160] using cpu capabilities: MMX2 SSE2Fast SSSE3
FastShuffle SSE4.2
[libx264 @ 0x16da160] profile High, level 3.0
Output #0, mpegts, to 'out.ts':
  Metadata:
    encoder         : Lavf54.61.100
    Stream #0:0: Video: h264, yuv420p, 640x360, q=-1--1, pass 2, 236 kb/s,
90k tbn, 25 tbc
    Stream #0:1: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
  Stream #0:1 -> #0:1 (mp3 -> libmp3lame)
Press [q] to stop, [?] for help
2nd pass has more frames than 1st pass (4048)me=00:02:41.56 bitrate=
417.5kbits/s dup=1 drop=0
[libx264 @ 0x16da160] continuing anyway, at constant QP=32
[libx264 @ 0x16da160] disabling adaptive B-frames
Segmentation fault (core dumped)


==

Backtrace in gdb:

#0  0x00007ffff6eefad3 in ?? () from /usr/lib/libx264.so.128
#1  0x00007ffff6ef2410 in ?? () from /usr/lib/libx264.so.128
#2  0x00007ffff6f0ee3e in x264_slicetype_decide () from
/usr/lib/libx264.so.128
#3  0x00007ffff6f4401a in x264_lookahead_get_frames () from
/usr/lib/libx264.so.128
#4  0x00007ffff6f41da0 in x264_encoder_encode () from
/usr/lib/libx264.so.128
#5  0x000000000084d133 in X264_frame (ctx=0x15ff160, pkt=0x7fffffffe190,
frame=<optimized out>, got_packet=0x7fffffffe18c) at
libavcodec/libx264.c:190
#6  0x000000000099b5c8 in avcodec_encode_video2 (avctx=avctx at entry=0x15ff160,
avpkt=avpkt at entry=0x7fffffffe190, frame=frame at entry=0x0,
got_packet_ptr=got_packet_ptr at entry=0x7fffffffe18c) at
libavcodec/utils.c:1439
#7  0x00000000004512b2 in flush_encoders () at ffmpeg.c:1299
#8  transcode () at ffmpeg.c:3058
#9  main (argc=<optimized out>, argv=<optimized out>) at ffmpeg.c:3210

Maybe the above backtrace isn't of much help, since I don't have symbols
for x264.


/ Joakim


More information about the ffmpeg-user mailing list