Broken Tutorial for Video Reading and Writing C++?

asked 2016-12-31 13:23:03 -0500

The-Log gravatar image

updated 2017-01-01 16:13:31 -0500

Hi I was trying to use this tutorial to do some video manipulation with OpenCV, but the program there doesn't seem to even run and results in this error:

    2016-12-31 14:17:14.509 process[9002:114718] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] AVVideoSettings dictionary must specify a positive width'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffcf4d20db __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffe4164a2a objc_exception_throw + 48
    2   AVFoundation                        0x00007fffcbb6e728 -[AVAssetWriterInput dealloc] + 0
    3   AVFoundation                        0x00007fffcbb6e0b3 +[AVAssetWriterInput assetWriterInputWithMediaType:outputSettings:] + 52
    4   libopencv_highgui.2.4.dylib         0x0000000107139132 _ZN26CvVideoWriter_AVFoundationC2EPKcid6CvSizei + 682
    5   libopencv_highgui.2.4.dylib         0x0000000107136dd3 _Z32cvCreateVideoWriter_AVFoundationPKcid6CvSizei + 69
    6   libopencv_highgui.2.4.dylib         0x000000010712a848 cvCreateVideoWriter + 80
    7   libopencv_highgui.2.4.dylib         0x000000010712b24a _ZN2cv11VideoWriter4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEidNS_5Size_IiEEb + 58
    8   process                             0x0000000106c11fa0 main + 1232
    9   libdyld.dylib                       0x00007fffe4a46255 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Is it broken or am I doing something wrong when running the program? Thanks!

EDIT: Using the newer tutorial changes the error to this:

2017-01-01 17:09:59.972 process[17637:327510] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffcf4d20db __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffe4164a2a objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffcf3ee4fb -[__NSArrayM objectAtIndex:] + 203
    3   libopencv_highgui.2.4.dylib         0x000000010285f280 _ZN13CvCaptureFileC2EPKc + 350
    4   libopencv_highgui.2.4.dylib         0x000000010285dcf2 _Z32cvCreateFileCapture_AVFoundationPKc + 34
    5   libopencv_highgui.2.4.dylib         0x00000001028517ee cvCreateFileCapture + 14
    6   libopencv_highgui.2.4.dylib         0x0000000102851a9e _ZN2cv12VideoCapture4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 64
    7   libopencv_highgui.2.4.dylib         0x00000001028518fe _ZN2cv12VideoCaptureC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 42
    8   process                             0x000000010232f9ad main + 349
    9   libdyld.dylib                       0x00007fffe4a46255 start + 1
    10  ???                                 0x0000000000000004 0x0 + 4
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
edit retag flag offensive close merge delete

Comments

2.4.1 = 5 years ago today version is 3.20 or 2.4.13 you should use one of this version

I think that links here are goods

LBerger gravatar imageLBerger ( 2017-01-01 04:35:46 -0500 )edit
1

It still gives a similar error, but it is now complaining about an array being out of bounds.

The-Log gravatar imageThe-Log ( 2017-01-01 16:15:26 -0500 )edit

Then it is not a similar problem but your code trying to access a position outside of assigned memory. Make sure that your indexes are correct throughout the whole code.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-01-02 06:10:09 -0500 )edit

Then I'll take it that the tutorial is broken as this is what their code returns.

The-Log gravatar imageThe-Log ( 2017-01-02 13:54:49 -0500 )edit

try with

video-write.exe video/Megamind.avi R N
LBerger gravatar imageLBerger ( 2017-01-02 14:20:38 -0500 )edit

Been doing that. Taking to a friend of mine and I believe its something that's related to macOS. I'll try testing with Linux.

The-Log gravatar imageThe-Log ( 2017-01-02 16:52:35 -0500 )edit