Discussion:
How to avoid Frame data under-runs with mplex?
Eric Lavarde - Asb
2006-11-01 19:55:35 UTC
Permalink
Hello,

in my program asb, I'm transforming MJpeg files from my Canon camera into
MPEG1 files (because it's the only format I made work on all PCs of my
family out-of-the-box on Mac, Windows and Linux). This worked quite well,
but with my new camera, I have bigger films (640x480 instead of 320x240
and 30fps instead of 15) and I get 'Frame data under-runs detected!' from
mplex.


Here the debug output:


[...]
DEBUG: Created directory '/tmp/AsbTest/.tmpmjpg'.
DEBUG: /usr/bin/transcode -i /tmp/AsbTest/0065_MVI.AVI -y ffmpeg,mp2 -F
mpeg1video --export_fps 24 -J modfps -E 22050,16 --encode_fields p
--video_max_bitrate 14969520 -o /tmp/AsbTest/.tmpmjpg/film --ext
.m1v,.mpa --print_status 10,0

PROCESSING:
..............................................................................................................................................
DEBUG: /usr/bin/mplex -r 29258 -f 0 -V -o
/tmp/AsbTest/.thumbs/medium-0065_MVI.mpg /tmp/AsbTest/.tmpmjpg/film.m1v
/tmp/AsbTest/.tmpmjpg/film.mpa

PROCESSING: ...................................
++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=957
required(DTS)=957

++ WARN: [mplex] Video e0: buf= 38493 frame=000001 sector=00000019

++ WARN: [mplex] Audio c0: buf= 0 frame=000000 sector=00000000
.......................
**ERROR: [mplex] MUX STATUS: Frame data under-runs detected!
ERROR: Command '/usr/bin/mplex -r 29258 -f 0 -V -o
/tmp/AsbTest/.thumbs/medium-0065_MVI.mpg /tmp/AsbTest/.tmpmjpg/film.m1v
/tmp/AsbTest/.tmpmjpg/film.mpa' failed: at
/home/ericl/Comp/asb/WORK/asb/ASB/Item/File/Film/Mjpg.pm line 448.


If I repeat the last command, I get the following:


$ /usr/bin/mplex -r 29258 -f 0 -V -o
/tmp/AsbTest/.thumbs/medium-0065_MVI.mpg /tmp/AsbTest/.tmpmjpg/film.m1v
/tmp/AsbTest/.tmpmjpg/film.mpa
INFO: [mplex] mplex version 1.8.0 (2.2.4 $Date: 2005/08/28 17:50:54 $)
INFO: [mplex] File /tmp/AsbTest/.tmpmjpg/film.m1v looks like an MPEG
Video stream.
INFO: [mplex] File /tmp/AsbTest/.tmpmjpg/film.mpa looks like an MPEG
Audio stream.
INFO: [mplex] Found 1 audio streams and 1 video streams
INFO: [mplex] Selecting generic MPEG1 output profile
INFO: [mplex] Multiplexing video program stream!
INFO: [mplex] Scanning for header info: Video stream e0
(/tmp/AsbTest/.tmpmjpg/film.m1v)
INFO: [mplex] VIDEO STREAM: e0
INFO: [mplex] Frame width : 640
INFO: [mplex] Frame height : 480
INFO: [mplex] Aspect ratio : 1:1 (square pixels)
INFO: [mplex] Picture rate : 23.976 frames/sec
INFO: [mplex] Bit rate : variable
INFO: [mplex] Vbv buffer size : 63488 bytes
INFO: [mplex] CSPF : 0
INFO: [mplex] Scanning for header info: Audio stream c0
(/tmp/AsbTest/.tmpmjpg/film.mpa)
INFO: [mplex] MPEG AUDIO STREAM: c0
INFO: [mplex] Audio version : reserved
INFO: [mplex] Layer : 2
INFO: [mplex] CRC checksums : no
INFO: [mplex] Bit rate : 16384 bytes/sec (128 kbit/sec)
INFO: [mplex] Frequency : 22050 Hz
INFO: [mplex] Mode : 3 single channel
INFO: [mplex] Mode extension : 0
INFO: [mplex] Copyright bit : 0 no copyright
INFO: [mplex] Original/Copy : 1 original
INFO: [mplex] Emphasis : 0 none
INFO: [mplex] SYSTEMS/PROGRAM stream:
INFO: [mplex] rough-guess multiplexed stream data rate : 0135000
INFO: [mplex] target data-rate specified : 29258000
INFO: [mplex] Setting specified specified data rate: 29258000
INFO: [mplex] Run-in Sectors = 19 Video delay = 957 Audio delay = 4711
INFO: [mplex] New sequence commences...
INFO: [mplex] Video e0: buf= 0 frame=000000 sector=00000000
INFO: [mplex] Audio c0: buf= 0 frame=000000 sector=00000000
++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=957
required(DTS)=957
++ WARN: [mplex] Video e0: buf= 38493 frame=000001 sector=00000019
++ WARN: [mplex] Audio c0: buf= 0 frame=000000 sector=00000000
INFO: [mplex] STREAM c0 completed @ frame 875.
INFO: [mplex] STREAM e0 completed @ frame 1096.
INFO: [mplex] Multiplex completion at SCR=4104002.
INFO: [mplex] Video e0: buf= 42594 frame=001096 sector=00005180
INFO: [mplex] Audio c0: buf= 3344 frame=000875 sector=00000362
INFO: [mplex] VIDEO_STATISTICS: e0
INFO: [mplex] Video Stream length: 10503583 bytes
INFO: [mplex] Sequence headers: 74
INFO: [mplex] Sequence ends : 0
INFO: [mplex] No. Pictures : 1097
INFO: [mplex] No. Groups : 74
INFO: [mplex] No. I Frames : 74 avg. size 30344 bytes
INFO: [mplex] No. P Frames : 1024 avg. size 8057 bytes
INFO: [mplex] No. B Frames : 0 avg. size 0 bytes
INFO: [mplex] Average bit-rate : 1834800 bits/sec
INFO: [mplex] Peak bit-rate : 4122800 bits/sec
INFO: [mplex] BUFFERING min 15 Buf max 44340
INFO: [mplex] AUDIO_STATISTICS: c0
INFO: [mplex] Audio stream length 732264 bytes.
INFO: [mplex] Syncwords : 876
INFO: [mplex] Frames : 72 padded
INFO: [mplex] Frames : 804 unpadded
INFO: [mplex] BUFFERING min 17 Buf max 849
**ERROR: [mplex] MUX STATUS: Frame data under-runs detected!


And MPlayer tells me the following about the starting file:


$ mplayer -identify /tmp/AsbTest/0065_MVI.AVI
[...]
Playing /tmp/AsbTest/0065_MVI.AVI.
AVI file format detected.
ID_VIDEO_ID=0
ID_AUDIO_ID=1
VIDEO: [MJPG] 640x480 24bpp 30.000 fps 14969.5 kbps (1827.3 kbyte/s)
Clip info:
Digitization Time: SUN SEP 03 13:21:56 2006

ID_CLIP_INFO_NAME0=Digitization Time
ID_CLIP_INFO_VALUE0=SUN SEP 03 13:21:56 2006

Software: CanonMVI02
ID_CLIP_INFO_NAME1=Software
ID_CLIP_INFO_VALUE1=CanonMVI02
ID_CLIP_INFO_N=2
ID_FILENAME=/tmp/AsbTest/0065_MVI.AVI
ID_DEMUXER=avi
ID_VIDEO_FORMAT=MJPG
ID_VIDEO_BITRATE=14969520
ID_VIDEO_WIDTH=640
ID_VIDEO_HEIGHT=480
ID_VIDEO_FPS=30.000
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=1
ID_AUDIO_BITRATE=88192
ID_AUDIO_RATE=0
ID_AUDIO_NCH=0
ID_LENGTH=45.93
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
open: No such file or directory
[MGA] Couldn't open: /dev/mga_vid
[VO_TDFXFB] Can't open /dev/fb0: No such file or directory.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmjpeg] vfm: ffmpeg (FFmpeg MJPEG decoder)
==========================================================================
ID_VIDEO_CODEC=ffmjpeg
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 11024 Hz, 1 ch, u8, 88.2 kbit/100.00% (ratio: 11024->11024)
ID_AUDIO_BITRATE=11024
ID_AUDIO_RATE=11024
ID_AUDIO_NCH=1
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
alsa-init: using device default
alsa: 48000 Hz/1 channels/1 bpf/16384 bytes buffer/Unsigned 8 bit
AO: [alsa] 48000Hz 1ch u8 (1 bytes per sample)
ID_AUDIO_CODEC=pcm
[...]


I understand that it has something to do with the -r parameter of mplex,
but I can't seem to find a good value for it. I went so high that I
reached some overflow value. Any idea/hint on what I should/could change
on my mplex command or even before?

A code snippet to show how I currently come to my values:
# ID_AUDIO_BITRATE and ID_VIDEO_BITRATE from original AVI/MJPEG file
my $abr = $self->{'extra_h'}->{'ID_AUDIO_BITRATE'};
my $vbr = $self->{'extra_h'}->{'ID_VIDEO_BITRATE'};
my $maxvbr = int (2 * ($vbr + $abr) / 1024);
And then:
transcode [...] --video_max_bitrate $vbr [...]
mplex [...] -r $maxvbr [...]
(I suspect that video_max_bitrate has no influence as I'm creating MPEG1
files and the man page speaks only about MPEG2, but adding/removing this
parameter doesn't change anything)

Thanks, Eric

Some more info:
---------------
Package: transcode
Version: 2:1.0.2-0.11
Severity: normal

*** Please type your report below this line ***


-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.16-18nc6k1
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8)

Versions of packages transcode depends on:
ii gawk 1:3.1.5.dfsg-4 GNU awk, a pattern scanning
and pr
ii gnome-terminal [x-t 2.14.2-1 The GNOME 2 terminal emulator
appl
ii konsole [x-terminal 4:3.5.5a-2 X terminal emulator for KDE
ii liba52-0.7.4 0.7.4-4 Library for decoding ATSC
A/52 str
ii libaa1 1.4p5-30 ascii art library
ii libartsc0 1.5.5-1 aRts sound system C support
librar
ii libasound2 1.0.13-1 ALSA library
ii libaudio2 1.8-2 The Network Audio System
(NAS). (s
ii libaudiofile0 0.2.6-6 Open-source version of SGI's
audio
ii libavcodeccvs51 3:20060814-0.3 library to encode decode
multimedi
ii libavutilcvs49 3:20060814-0.3 avutil shared libraries
ii libbz2-1.0 1.0.3-6 high-quality block-sorting
file co
ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries
ii libdirectfb-0.9-25 0.9.25.1-4 direct frame buffer graphics
- sha
ii libdv4 1.0.0-1 software library for DV
format dig
ii libdvdread3 0.9.7-1 library for reading DVDs
ii libesd0 0.2.36-3 Enlightened Sound Daemon -
Shared
ii libfaac0 1.25-0.1 an AAC audio encoder -
library fil
ii libfaad2-0 2.5-0.1 freeware Advanced Audio
Decoder -
ii libfame-0.9 0.9.1-0.2 A video encoding library -
runtime
ii libfreetype6 2.2.1-5 FreeType 2 font engine,
shared lib
ii libgcc1 1:4.1.1-13 GCC support library
ii libglib1.2 1.2.10-13 The GLib library of C routines
ii libglib2.0-0 2.12.4-1 The GLib library of C routines
ii libgsm1 1.0.10-13 Shared libraries for GSM
speech co
ii libgtk1.2 1.2.10-18 The GIMP Toolkit set of
widgets fo
ii libice6 1:1.0.1-2 X11 Inter-Client Exchange
library
ii libjasper-1.701-1 1.701.0-2 The JasPer JPEG-2000 runtime
libra
ii libjpeg62 6b-13 The Independent JPEG Group's
JPEG
ii liblame0 3.97-0.0 LAME Ain't an MP3 Encoder
ii liblcms1 1.15-1 Color management library
ii liblzo1 1.08-3 data compression library (old
vers
ii libmagick9 7:6.2.4.5.dfsg1-0.10 Image manipulation library
ii libmjpegtools0 1:1.8.0-0.4 MJPEG video
capture/editting/playb
ii libmpeg2-4 0.4.0b-4 MPEG1 and MPEG2 video decoder
libr
ii libncurses5 5.5-5 Shared libraries for terminal
hand
ii libogg0 1.1.3-2 Ogg Bitstream Library
ii libpng12-0 1.2.8rel-7 PNG library - runtime
ii libpostproccvs51 3:20060814-0.3 postproc shared libraries
ii libpvm3 3.4.5-7 Parallel Virtual Machine -
shared
ii libquicktime0 2:0.9.7-1 library for reading and
writing Qu
ii libsdl1.2debian 1.2.11-4 Simple DirectMedia Layer
ii libslang2 2.0.6-4 The S-Lang programming
library - r
ii libsm6 1:1.0.1-3 X11 Session Management library
ii libstdc++6 4.1.1-13 The GNU Standard C++ Library v3
ii libsvga1 1:1.4.3-23 console SVGA display libraries
ii libtheora0 0.0.0.alpha7-1 The Theora Video Compression
Codec
ii libtiff4 3.8.2-6 Tag Image File Format (TIFF)
libra
ii libvorbis0a 1.1.2.dfsg-1.2 The Vorbis General Audio
Compressi
ii libvorbisenc2 1.1.2.dfsg-1.2 The Vorbis General Audio
Compressi
ii libvorbisfile3 1.1.2.dfsg-1.2 The Vorbis General Audio
Compressi
ii libx11-6 2:1.0.3-2 X11 client-side library
ii libxaw7 1:1.0.2-4 X11 Athena Widget library
ii libxext6 1:1.0.1-2 X11 miscellaneous extension
librar
ii libxi6 1:1.0.1-3 X11 Input extension library
ii libxml2 2.6.26.dfsg-4 GNOME XML library
ii libxpm4 1:3.5.5-2 X11 pixmap library
ii libxt6 1:1.0.2-2 X11 toolkit intrinsics library
ii libxv1 1:1.0.2-1 X11 Video extension library
ii libxvidcore4 2:1.1.0-final-0.1 High quality ISO MPEG4 codec
libra
ii rxvt-unicode [x-ter 7.9-2 RXVT-like terminal emulator
with U
ii xfce4-terminal [x-t 0.2.5.6rc1-2 Xfce terminal emulator
ii xterm [x-terminal-e 210-3.1 X terminal emulator
ii zlib1g 1:1.2.3-13 compression library - runtime

Versions of packages transcode recommends:
ii mjpegtools 1:1.8.0-0.4 MJPEG video
capture/editting/playb
ii sox 12.17.9-1 A universal sound sample
translato
ii toolame 02l-3 MPEG-1 layer 2 audio encoder
ii transcode-doc 2:1.0.2-0.11 Documentation for transcode
--
No need to cc me on the transcode-users mailing list
Maik Holtkamp
2006-11-03 12:46:23 UTC
Permalink
Hi,
Post by Eric Lavarde - Asb
in my program asb, I'm transforming MJpeg files from my Canon camera into
MPEG1 files (because it's the only format I made work on all PCs of my
family out-of-the-box on Mac, Windows and Linux). This worked quite well,
but with my new camera, I have bigger films (640x480 instead of 320x240
and 30fps instead of 15) and I get 'Frame data under-runs detected!' from
mplex.
[...]
DEBUG: Created directory '/tmp/AsbTest/.tmpmjpg'.
DEBUG: /usr/bin/transcode -i /tmp/AsbTest/0065_MVI.AVI -y ffmpeg,mp2 -F
mpeg1video --export_fps 24 -J modfps -E 22050,16 --encode_fields p
When using modfps IMHO it's a good idea to specify input frame rate
(-f 30,5) too.

--encode_fields p should be default.

Dunno if it matters but -E 22050.. is IMHO somewhat strange, too.

Your ears should IMHO notice signals above 11025 Hz and if nothing
stands against it I would use a more common one like 44100 or 48000.
Post by Eric Lavarde - Asb
--video_max_bitrate 14969520 -o /tmp/AsbTest/.tmpmjpg/film --ext
*Ups*. If I got it right that means you ask transcode that it can
spend 14969520 bits/sec (> 14 Mbit/sec) for a bloody mpeg1 file
(assuming transcode will not interpret this value as kbit/sec
already).

Further the manpage says MPEG-2 vbr here and you use it to create an
mpeg1 file.

If in luck transcode will just ignore this statement. However, I
would drop it, as your result should not reach such bitrates at all.
Post by Eric Lavarde - Asb
.m1v,.mpa --print_status 10,0
..............................................................................................................................................
DEBUG: /usr/bin/mplex -r 29258 -f 0 -V -o
Probably it is better not to use -r here, as man mplex suggested:

---cut---
-f
0 - Generic MPEG1. A simple general-purpose MPEG1 format
primarily suitable for software decoders. Buffer
sizes and VBR must be specified. Bit-rate can be
auto-detected.
---cut---

so I would drop -r and probably add -b (I would start @ -b 230 see
man mplex).

I think your problem is based on mplex and a bitrate issue.
Post by Eric Lavarde - Asb
++ WARN: [mplex] Stream e0: data will arrive too late sent(SCR)=957
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Leads you to this thread:

http://www.mail-archive.com/mjpeg-***@lists.sourceforge.net/msg06909.html

Further IIRC ffmpeg was known to have problems with to high peak
bitrates when introducing dvd (mpeg2) support. As I suppose nearly
no one will use mpeg1 (especially if out of dvd/vcd specs) nowadays,
there is probably some similar issue left in ffmpeg. So, it is
IMHO worth a trial to use -y mpeg2enc,mp2enc -F 0 for encoding, if
all other efforts fail.
--
bye maik
Eric Lavarde - ASB
2006-11-11 18:56:00 UTC
Permalink
Hi Maik,

thanks for your answer, you gave me some useful inputs, which I'll
probably put in action into ASB for the next release (which should anyway
improve the film handling capabilities, expect more questions in this
forum :-^ ).
In the mean time, shame on me, I'm just ignoring the error code...
Post by Maik Holtkamp
Post by Eric Lavarde - Asb
DEBUG: /usr/bin/transcode -i /tmp/AsbTest/0065_MVI.AVI -y ffmpeg,mp2 -F
mpeg1video --export_fps 24 -J modfps -E 22050,16 --encode_fields p
When using modfps IMHO it's a good idea to specify input frame rate
(-f 30,5) too.
--encode_fields p should be default.
Didn't know, thanks.
Post by Maik Holtkamp
Dunno if it matters but -E 22050.. is IMHO somewhat strange, too.
The source films have 11025,8 but mplex doesn't like it, 22050,16 is a
tentative to not increase too much the size while making mplex happy.
Post by Maik Holtkamp
Post by Eric Lavarde - Asb
--video_max_bitrate 14969520 -o /tmp/AsbTest/.tmpmjpg/film --ext
*Ups*. If I got it right that means you ask transcode that it can
spend 14969520 bits/sec (> 14 Mbit/sec) for a bloody mpeg1 file
(assuming transcode will not interpret this value as kbit/sec
already).
The man page is not explicit here, if someone knowing the code could
comment, I'd be grateful.
Post by Maik Holtkamp
Further the manpage says MPEG-2 vbr here and you use it to create an
mpeg1 file.
If in luck transcode will just ignore this statement. However, I
would drop it, as your result should not reach such bitrates at all.
I was desperate :-)
Post by Maik Holtkamp
Post by Eric Lavarde - Asb
Post by Eric Lavarde - Asb
DEBUG: /usr/bin/mplex -r 29258 -f 0 -V -o
---cut---
-f
0 - Generic MPEG1. A simple general-purpose MPEG1 format
primarily suitable for software decoders. Buffer
sizes and VBR must be specified. Bit-rate can be
auto-detected.
---cut---
man mplex).
I've seen this but I don't think it's true, mplex definitely complains
with vbr and without -r.
Post by Maik Holtkamp
Further IIRC ffmpeg was known to have problems with to high peak
bitrates when introducing dvd (mpeg2) support. As I suppose nearly
no one will use mpeg1 (especially if out of dvd/vcd specs) nowadays,
there is probably some similar issue left in ffmpeg. So, it is
IMHO worth a trial to use -y mpeg2enc,mp2enc -F 0 for encoding, if
all other efforts fail.
I landed at MPEG1 in an effort to produce something to be viewed and
heared out-of-the-box on Mac OS and Windows XP (I'm the only one in the
family with Linux, and computer knowledge...). Anyway, I didn't pay
attention to DVD conformance, that's perhaps the reason why I wasn't
successful with my MPEG2 tentatives. I'll give it a try again.
Does someone have multi-platform experience with even more modern formats?

Thanks, Eric
Post by Maik Holtkamp
--
bye maik
--
Eric de France, d'Allemagne et de Navarre
Francesco Romani
2006-11-11 19:12:53 UTC
Permalink
On Sat, 11 Nov 2006 19:56:00 +0100 (CET)
"Eric Lavarde - ASB" <***@zorglub.s.bawue.de> wrote:

[...]
Post by Eric Lavarde - ASB
Post by Maik Holtkamp
Post by Eric Lavarde - Asb
--video_max_bitrate 14969520 -o /tmp/AsbTest/.tmpmjpg/film --ext
*Ups*. If I got it right that means you ask transcode that it can
spend 14969520 bits/sec (> 14 Mbit/sec) for a bloody mpeg1 file
(assuming transcode will not interpret this value as kbit/sec
already).
The man page is not explicit here, if someone knowing the code could
comment, I'd be grateful.
transcode, perhaps counter-intuitively, expect a *kbps* (kilo bits per second)
value here. manpage will be updated soon (in CVS HEAD).
Post by Eric Lavarde - ASB
Post by Maik Holtkamp
Further the manpage says MPEG-2 vbr here and you use it to create an
mpeg1 file.
This statement can be misleading too, --video_max_bitrate, if given, is
passed to libavcodec so it can be used for other codecs avalaible
in here (of course, if honoured/meaningfull).

[...]

Best regards,
--
Francesco Romani - Ikitt ['people always complain, no matther what you do']
IM contact : (email first, Antispam default deny!) icq://27-83-87-867
known bugs : http://www.transcoding.org/cgi-bin/transcode?Bug_Showcase
tiny homepage : http://fromani.exit1.org (see IDEAS if you want send code!)
Loading...