examples/video
Won't work
# ./video -f ../data/centaur_1.mpg
[mpegvideo @ 0xd9d320] Estimating duration from bitrate, this may be inaccurate
core.exception.AssertError@../../source/dcv/core/image.d(171): Assertion failure
Hi Anton,
Thanks for reporting this! So, it's obviously a bug, but I'm not sure where it is. Looks like the stream opens, but width and height properties cannot be read, and 0-sized image is to be allocated where assertion fails.
This example runs fine on my machine, so it's really hard for me to debug this. Could you tell me what system you're running on, and what FFmpeg version is installed? Also, could you try running the example app with some other video, maybe encoded with h264/3 codecs?
Also, can I ask you to try to debug the example code, and to see what precisely is going on - I'd be really grateful. As noted in example docs, this is the module where I'd really need assistance from other people with different systems, and videos to test it with.
Hi,
System is Debian Linux / Unstable - 64bit
% ffmpeg
ffmpeg version 3.1.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (Debian 5.4.0-6) 20160609
configuration: --prefix=/usr --extra-cflags='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security ' --extra-ldflags='-Wl,-z,relro' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-nonfree --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --enable-libvpx --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-librtmp --enable-avfilter --enable-libfreetype --disable-decoder=amrnb --enable-libvo-amrwbenc --enable-libtesseract --libdir=/usr/lib/x86_64-linux-gnu --disable-vda --enable-libbluray --enable-libcdio --enable-gnutls --enable-frei0r --enable-openssl --enable-libass --enable-libopus --enable-fontconfig --enable-libpulse --disable-mipsdsp --disable-mips32r2 --disable-mips32r6 --disable-mips64r6 --disable-msa --disable-mipsfpu --disable-mipsdspr2 --enable-libvidstab --enable-libzvbi --enable-avresample --enable-libfdk-aac --enable-libx265 --enable-libbs2b --enable-libilbc --enable-libopenh264 --enable-libkvazaar --enable-libsnappy --enable-libsoxr --disable-podpages --enable-libebur128 --enable-libiec61883 --enable-vaapi --enable-opencl --enable-libdc1394 --disable-altivec --shlibdir=/usr/lib/x86_64-linux-gnu
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
% dmd
DMD64 D Compiler v2.071.1
Also full trace
core.exception.AssertError@../../source/dcv/core/image.d(171): Assertion failure
----------------
??:? _d_assert [0x5aa857]
??:? void dcv.core.image.__assert(int) [0x53b507]
../../source/dcv/core/image.d:171 pure nothrow @safe dcv.core.image.Image dcv.core.image.Image.__ctor(ulong, ulong, dcv.core.image.ImageFormat, dcv.core.image.BitDepth, ubyte[]) [0x52ce53]
../../source/dcv/io/video/input.d:370 bool dcv.io.video.input.InputStream.readFrameImpl(ref dcv.core.image.Image) [0x589377]
../../source/dcv/io/video/input.d:317 bool dcv.io.video.input.InputStream.readFrame(ref dcv.core.image.Image) [0x5890f5]
source/app.d:70 _Dmain [0x517ca1]
See that
../../source/dcv/io/video/input.d:370 bool dcv.io.video.input.InputStream.readFrameImpl(ref dcv.core.image.Image) [0x589377]
I insert debug output before this line (dcv/io/video/input.d:370)
while (true)
{
ret = avcodec_decode_video2(stream.codec, frame, &gotFrame, &packet);
if (ret < 0)
{
throw new StreamException("Error decoding video frame.");
}
if (gotFrame)
break;
}
debug writefln("frame: %s\ngotFrame: %s\nPacket: %s", *frame, gotFrame, packet);
if (gotFrame)
And got
frame: AVFrame([1C72180, 1C861E0, 1C8B220, null, null, null, null, null], [320, 160, 160, 0, 0, 0, 0, 0], 1C5F7E0, 320, 240, 0, 0, 1, AV_PICTURE_TYPE_I, [100000001, 8000000000000000, null, null, null, null, null, null], AVRational(0, 0), 0, 0, 0, 0, 0, 0, 0, null, 0, 0, null, [[8000000000000000, null], [null, null]], null, null, [null, null], null, [0, 0, 0, 0, 30232480, 1, 8589934593, 8589934594], 2, 0, 0, 0, 0, 0, 9C68, 0, null, 100F, 1CB5D4B, 21, 1, 30114912, [null, 51, null, null, 1, null, 7F63A651DB00, 7F63A651B7E0], null, 0, null, 497, 0, cast(AVColorRange)29827456, cast(AVColorPrimaries)0, cast(AVColorTransferCharacteristic)29909472, AVCOL_SPC_RGB, cast(AVChromaLocation)29930016, 0, 0, 0, null, 0, 0, 320, A0)
gotFrame: 1
Packet: AVPacket(1C5CD00, 0, 0, 1C613E0, 4111, 0, 1, null, 0, 0, 9C68, null, 0, 0)
I think some invalid value in AVFrame
Thanks for such thorough checkout!
I haven't tested ffmpeg-d with FFmpeg versions above 2.8.0 (ffmpeg-d v2.5.0 is tested with FFmpeg 2.7.6), so I would guess this is the reason for an empty AVPacket. I'm not familiar with FFmpeg 3.0, so I'm unaware of API and implementation changes, but I can see no other reason for such strange behavior.
Is it possible for you to link the example to FFmpeg 2.7.6 libs and try it again?
I'll try get previous version later, Also asser failed inimage constructor
??:? void dcv.core.image.__assert(int) [0x53b507]
../../source/dcv/core/image.d:171 pure nothrow @safe dcv.core.image.Image dcv.core.image.Image.__ctor(ulong, ulong, dcv.core.image.ImageFormat, dcv.core.image.BitDepth, ubyte[]) [0x52ce53]
Where code i added debug output (dcv/io/video/input.d:370)
if (image is null || image.byteSize != frameSize)
{
debug writefln("Width=%s Height=%s Format=%s Depth=%s", width, height, AVPixelFormat_to_ImageFormat(pixelFormat), BitDepth.BD_8);
image = new Image(width, height, AVPixelFormat_to_ImageFormat(pixelFormat), BitDepth.BD_8);
}
And got
Width=1 Height=0 Format=IF_YUV Depth=BD_8
I think trouble with invalid image size - invalid initialization, where output of Frame is valid 320x240
AVFrame {
data = [1851180, 18651E0, 186A220, null, null, null, null, null]
linesize = [320, 160, 160, 0, 0, 0, 0, 0]
extended_data = 183E7E0
width = 320
height = 240
I think trouble with invalid image size - invalid initialization, where output of Frame is valid 320x240
Exactly - width and height are stream properties that are read from the stream's codec here. That's why I think there must be a problem with ffmpeg-d and FFmpeg libs.
I think we have to test the ffmpeg-d behavior with FFmpeg 3 before even trying to use it in DCV. Unfortunately, I have no spare time to do it soon.
ok, i'll try soon
Awesome, tnx!