Opened 5 years ago

Closed 5 years ago

#4051 closed defect (fixed)

Assertion error in mux.c with a slow input

Reported by: ubitux Owned by:
Priority: important Component: avformat
Version: unspecified Keywords: mux crash abort
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

A bit tricky to trigger, I wasn't able to simplify any further. Here is the first python script you'll need:

☭ cat <<EOF > /tmp/feed.py
import sys, time

fifo = open(sys.argv[1], 'wb')
frame = '\x00' * (320*240*3)
framecount = 0
for i in range(1000):
    print 'write frame #%d' % framecount
    fifo.write(frame)
    framecount += 1
    time.sleep(.1)
EOF

Create the video FIFO:

☭ mkfifo /tmp/videofifo

Start ffmpeg:

☭ ./ffmpeg -f rawvideo -pixel_format rgb24 -video_size 320x240 -i /tmp/videofifo -f s32le -ac 2 -ar 44100 -i /dev/zero -map 0:v -map 1:a -c:v libx264 -c:a aac -strict -2 -y -f matroska /dev/null
ffmpeg version N-67067-g1372c55 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 21 2014 16:36:11 with gcc 4.9.1 (GCC) 20140903 (prerelease)
  configuration: --enable-gpl --enable-libfribidi --enable-fontconfig --enable-libfreetype --enable-libx264 --enable-libvorbis --enable-libmp3lame --enable-libmodplug --enable-libass --enable-libfaac --enable-nonfree --assert-level=2 --samples=/home/ux/fate-samples --cpu=native --cc='ccache cc'
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.102 / 56.  8.102
  libavformat    56.  9.101 / 56.  9.101
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  2.100 /  5.  2.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100

While ffmpeg is in stand-by, run the video feeder:

☭ python2 /tmp/feed.py /tmp/videofifo
write frame #0
write frame #1
write frame #2
write frame #3
write frame #4
...

After about 50 frames, ffmpeg asserts:

☭ ./ffmpeg -f rawvideo -pixel_format rgb24 -video_size 320x240 -i /tmp/videofifo -f s32le -ac 2 -ar 44100 -i /dev/zero -map 0:v -map 1:a -c:v libx264 -c:a aac -strict -2 -y -f matroska /dev/null 
ffmpeg version N-67067-g1372c55 Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct 21 2014 16:36:11 with gcc 4.9.1 (GCC) 20140903 (prerelease)
  configuration: --enable-gpl --enable-libfribidi --enable-fontconfig --enable-libfreetype --enable-libx264 --enable-libvorbis --enable-libmp3lame --enable-libmodplug --enable-libass --enable-libfaac --enable-nonfree --assert-level=2 --samples=/home/ux/fate-samples --cpu=native --cc='ccache cc'
  libavutil      54. 10.100 / 54. 10.100
  libavcodec     56.  8.102 / 56.  8.102
  libavformat    56.  9.101 / 56.  9.101
  libavdevice    56.  1.100 / 56.  1.100
  libavfilter     5.  2.100 /  5.  2.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, rawvideo, from '/tmp/videofifo':
  Duration: N/A, start: 0.000000, bitrate: 46080 kb/s
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240, 46080 kb/s, 25 tbr, 25 tbn, 25 tbc
Guessed Channel Layout for  Input Stream #1.0 : stereo
Input #1, s32le, from '/dev/zero':
  Duration: N/A, bitrate: 2822 kb/s
    Stream #1:0: Audio: pcm_s32le, 44100 Hz, 2 channels, s32, 2822 kb/s
No pixel format specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x1a7a080] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x1a7a080] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x1a7a080] 264 - core 142 r2455 021c0dc - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=6 lookahead_threads=1 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=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 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, matroska, to '/dev/null':
  Metadata:
    encoder         : Lavf56.9.101
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv444p, 320x240, q=-1--1, 25 fps, 1k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.8.102 libx264
    Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc56.8.102 aac
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (pcm_s32le (native) -> aac (native))
Press [q] to stop, [?] for help
Assertion pkt->dts == ((int64_t)0x8000000000000000UL) || pkt->dts >= 0 failed at libavformat/mux.c:577
zsh: abort (core dumped)  ./ffmpeg -f rawvideo -pixel_format rgb24 -video_size 320x240 -i /tmp/videofif

I tried -c:v mpeg4 instead of -c:v libx264 but the assert didn't occur, so I let it as is.

This is not reproducible with 2.4, so it's a regression. I haven't bisected yet.

Change History (4)

comment:1 Changed 5 years ago by ubitux

  • Keywords regression removed

Actually not a regression, it wasn't built with the same assert level.

So to reproduce the above, you need --assert-level=2 (1 should work as well).

Without assert level, and replacing matroska with flv, you'll get this instead of the assert:

[flv @ 0x17de280] Packets are not in the proper order with respect to DTS
av_interleaved_write_frame(): Invalid argument
Last edited 5 years ago by ubitux (previous) (diff)

comment:2 Changed 5 years ago by cehoyos

  • Keywords crash abort added; assert removed

comment:3 Changed 5 years ago by ubitux

This script can be more handy for reproducing:

import sys

fifo = open(sys.argv[1], 'wb')
frame = '\x00' * (320*240*3)
framecount = 0
for i in range(1000):
    fifo.write(frame)
    raw_input('wrote frame #%d press enter for next frame' % framecount)
    framecount += 1

After pushing 2 frames, ffmpeg starts pulling the audio indefinitely. Then pushing 40 more video frames triggers the crash.

comment:4 Changed 5 years ago by michael

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.