Opened 5 years ago

Closed 5 years ago

#3300 closed defect (needs_more_info)

Muxing example crashes on avcodec_close when using DIRAC codec

Reported by: andreiC Owned by:
Priority: normal Component: undetermined
Version: 2.1.1 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hello,
I've build the muxing example as a win32 console application using VS2012. The application was run on Windows 8 x64.

The only changes to the muxing example that I made were enclosing the #include directives inside extern "C" { ... } and adding the following line:

fmt->video_codec = AV_CODEC_ID_DIRAC;


before :

if (fmt->video_codec != AV_CODEC_ID_NONE) {
		video_st = add_stream(oc, &video_codec, fmt->video_codec);
}

in order to use the DIRAC codec for encoding the video.

For building the console application I've used the latest windows static and dev build packages from zeranoe.

With any other codec the muxing example works fine, only when using the DIRAC codec the application crashes with 0xC0000005 access violation. This error occurs when calling

avcodec_close(st->codec);

from

close_video(AVFormatContext *oc, AVStream *st);

I don't have the debug symbols, I've tried building ffmpeg libraries myself, but I wasn't able to build them together with libschrodinger support using msvc, so the only stack trace that I can provide is this:

ntdll.dll!_RtlReportCriticalFailure@8
ntdll.dll!_RtlpReportHeapFailure@4
ntdll.dll!_RtlpLogHeapFailure@24
ntdll.dll!_RtlFreeHeap@12
msvcrt.dll!_free
msvcrt.dll__aligned_free
avutil-52.dll!59ad2ca3()
[Frames below may be incorrect and/or missing, no symbols loaded for avutil-52.dll]
avcodec-55.dll!6c3c1c4b()
ConsoleApplication1.exe!close_video(AVFormatContext * oc, AVStream * st) Line 441

ConsoleApplication1.exe!main(int argc, char * * argv) Line 555

ConsoleApplication1.exe__tmainCRTStartup() Line 536 C
ConsoleApplication1.exe!mainCRTStartup() Line 377 C

kernel32.dll!@BaseThreadInitThunk@12?

ntdll.dll___RtlUserThreadStart@8

ntdll.dll__RtlUserThreadStart@8

I did some investigation and I've managed to narrow where the issue is to:

static int libschroedinger_encode_close(AVCodecContext *avctx)

from libscrhrodingerenc.c, but I wasn't able to dig any deeper.

The command line that I've used together with the output:

\>ConsoleApplication1.exe outputfile.avi
[libmp3lame @ 01477be0] Channel layout not specified
Output #0, avi, to 'outputfile.avi':
    Stream #0:0: Video: dirac (libschroedinger), yuv420p, 352x288, q=2-31, 400 k
b/s, 90k tbn, 25 tbc
    Stream #0:1: Audio: mp3 (libmp3lame), 44100 Hz, 2 channels, fltp, 64 kb/s
[avi @ 01476c00] Encoder did not produce proper pts, making some up.

Also, I've played a little with ffmpeg.exe(the windows build from zeranoe) and I've noticed that quite often when using ffmpeg.exe to transcode a video from ffv1 to dirac would crash right before closing(after printing the status of the transcoding operation):

ffmpeg-20140110-git-d9481dc-win32-shared\bin>ffmpeg -i
 myOutputFile15FPS-FFV10.avi -vcodec libschroedinger outputFile.avi
ffmpeg version N-59742-gd9481dc Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan  9 2014 22:04:35 with gcc 4.8.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3
 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --ena
ble-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --e
nable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
 --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      52. 62.100 / 52. 62.100
  libavcodec     55. 47.101 / 55. 47.101
  libavformat    55. 22.103 / 55. 22.103
  libavdevice    55.  5.102 / 55.  5.102
  libavfilter     4.  1.100 /  4.  1.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 17.104 /  0. 17.104
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'myOutputFile15FPS-FFV10.avi':
  Metadata:
    encoder         : Lavf55.21.102
  Duration: 00:00:20.27, start: 0.000000, bitrate: 2229 kb/s
    Stream #0:0: Video: ffv1 (FFV1 / 0x31564646), yuv420p, 640x480, 15 tbr, 15 t
bn, 15 tbc
File 'outputFile.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'outputFile.avi':
  Metadata:
    ISFT            : Lavf55.22.103
    Stream #0:0: Video: dirac (libschroedinger) (drac / 0x63617264), yuv420p, 64
0x480, q=2-31, 200 kb/s, 15 tbn, 15 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (ffv1 -> libschroedinger)
Press [q] to stop, [?] for help
frame=   38 fps=0.0 q=0.0 size=      39kB time=00:00:01.20 bitrate= 264.2kbits/s
frame=   58 fps= 55 q=0.0 size=      74kB time=00:00:02.53 bitrate= 240.9kbits/s
frame=   79 fps= 51 q=0.0 size=     110kB time=00:00:03.93 bitrate= 228.3kbits/s
frame=  100 fps= 48 q=0.0 size=     141kB time=00:00:05.33 bitrate= 217.3kbits/s
frame=  122 fps= 47 q=0.0 size=     179kB time=00:00:06.80 bitrate= 215.2kbits/s
frame=  144 fps= 46 q=0.0 size=     214kB time=00:00:08.26 bitrate= 211.7kbits/s
frame=  166 fps= 45 q=0.0 size=     252kB time=00:00:09.73 bitrate= 212.4kbits/s
frame=  186 fps= 44 q=0.0 size=     286kB time=00:00:11.06 bitrate= 211.9kbits/s
frame=  206 fps= 44 q=0.0 size=     318kB time=00:00:12.40 bitrate= 210.2kbits/s
frame=  227 fps= 44 q=0.0 size=     351kB time=00:00:13.80 bitrate= 208.6kbits/s
frame=  247 fps= 43 q=0.0 size=     385kB time=00:00:15.13 bitrate= 208.2kbits/s
frame=  268 fps= 43 q=0.0 size=     416kB time=00:00:16.53 bitrate= 206.2kbits/s
frame=  290 fps= 43 q=0.0 size=     453kB time=00:00:18.00 bitrate= 206.2kbits/s
frame=  304 fps= 40 q=0.0 Lsize=     518kB time=00:00:20.20 bitrate= 209.9kbits/
s
video:505kB audio:0kB subtitle:0 global headers:0kB muxing overhead 2.541212%

After some investigation it seems that ffmpeg.exe crashes when calling avcodec_close() as in the muxing example, so I think it's the same problem.

Change History (5)

comment:1 Changed 5 years ago by andreiC

  • Component changed from avutil to avcodec

comment:2 Changed 5 years ago by cehoyos

  • Component changed from avcodec to undetermined

There are several problems with this report that currently make it impossible to help:
Are you reporting two different issues? Please don't do that, it makes following tickets impossible.
Please add the necessary information for crash reports, see http://ffmpeg.org/bugreports.html
If you don't want to compile FFmpeg yourself, please report the crash to wherever you found the binary, FFmpeg only provides source code.

comment:3 follow-up: Changed 5 years ago by andreiC

I'm not reporting two different issues, it's basically the same issue: avcodec_close() performs an access violation when using the dirac codec. I've only mentioned two use case scenario that reproduces it.

I've tried building ffmpeg myself, managed to do it by cross-compiling on Ubuntu using mingw32 and it still crashed in the same way. The problem with building with mingw32 is that it doesnt' create symbol files that I can use for debugging using Visual Studio. Also I've tried building it on windows using mingw32 and the msvc toolchain, but apparently libschrodinger doesn't have support for building using mingw32 + msvc.

I'm willing to try anything to provide a stack trace, but I've already tried anything I could think of and I didn't manage to build ffmpeg together with libschrodinger and debug symbols.

comment:4 in reply to: ↑ 3 Changed 5 years ago by cehoyos

Replying to andreiC:

I'm not reporting two different issues, it's basically the same issue: avcodec_close() performs an access violation when using the dirac codec. I've only mentioned two use case scenario that reproduces it.

Understood, thank you.

I've tried building ffmpeg myself, managed to do it by cross-compiling on Ubuntu using mingw32 and it still crashed in the same way. The problem with building with mingw32 is that it doesnt' create symbol files that I can use for debugging using Visual Studio. Also I've tried building it on windows using mingw32 and the msvc toolchain, but apparently libschrodinger doesn't have support for building using mingw32 + msvc.

(Did you consider that libschroedinger is the culprit?)

Please compile both libschroedinger and FFmpeg with the same compiler, then debug with the appropriate debugger (depends on the compiler) and post the backtrace and the other information following http://ffmpeg.org/bugreports.html here.

comment:5 Changed 5 years ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from new to closed

Please reopen this ticket if you can provide the missing information as explained on http://ffmpeg.org/bugreports.html

Note: See TracTickets for help on using tickets.