vadimkantorov / mpegflow

A tool for easy extraction of motion vectors stored in video files
MIT License
264 stars 61 forks source link

'Codec not found or cannot open codec' crash #22

Open SamvitJ opened 6 years ago

SamvitJ commented 6 years ago

After successful install on Mac OS:

$ ./mpegflow examples/mpi_sintel_final_alley_1.avi > examples/alley_1.txt libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Codec not found or cannot open codec. Abort trap: 6

SamvitJ commented 6 years ago

To pinpoint the crash, run the following:

> make
> sudo gdb ./mpegflow
(gdb) b 78
Breakpoint 2 at 0x100001603: file mpegflow.cpp, line 78.
(gdb) run examples/mpi_sintel_final_alley_1.avi > examples/alley_1.txt
...
78              AVCodec *pCodec = avcodec_find_decoder(enc->codec_id);
(gdb) p enc->codec_id
$1 = AV_CODEC_ID_NONE
(gdb) p avcodec_find_decoder(enc->codec_id)
$2 = 0
(gdb) s
79              AVDictionary *opts = NULL;
(gdb) p *pCodec
Cannot access memory at address 0x0

which leads to a failure on line 81: (if (!pCodec || avcodec_open2(enc, pCodec, &opts) < 0))evaluates to false, resulting in throw std::runtime_error("Codec not found or cannot open codec.");

vadimkantorov commented 6 years ago

Very strange. Does the installed ffmpeg and ffprobe work on this video?

Maybe the ffmpeg api evolved. You can check other ffmpeg examples online. I can provide only limited support for mpegflow due to lack of time.

SamvitJ commented 6 years ago

ffmpeg -i examples/mpi_sintel_final_alley_1.avi -ss 00:00:0.435 -vframes 1 out.png outputs a frame at time 00:00:0.435 as expected, so yes ffmpeg works on the video

vadimkantorov commented 6 years ago

You may try to see what's happening in this loop: https://github.com/vadimkantorov/mpegflow/blob/master/mpegflow.cpp#L73-L91

Try to comment out the exception and break to see what are the streams and codec types.