From 215ed84779da71ab8c1c580766f1771617e4828d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 4 Oct 2011 12:30:26 +0000 Subject: Partial fix #27978: Problem exporting OGG Theora-Vorbis video (and other audio codecs) Ogg format does support only vorbis, theora, speex and flac audio codecs. Added check for result of av_write_header() and show info in header about error while initializing streams. This commit also fixed crash when using vorbis audio format. It used to be floating point exception. SOlved by initializing audio_stream->codec->time_base with proper rational value as it's done in FFmpeg sources. --- source/blender/blenkernel/intern/writeffmpeg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 6010770e1ee..21289b07f8d 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -571,6 +571,10 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex return NULL; } + /* need to prevent floating point exception when using vorbis audio codec, + initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */ + st->codec->time_base = (AVRational){1, st->codec->sample_rate}; + audio_outbuf_size = FF_MIN_BUFFER_SIZE; if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD)) @@ -743,7 +747,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } } - av_write_header(of); + if (av_write_header(of) < 0) { + BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination."); + return 0; + } + outfile = of; av_dump_format(of, 0, name, 1); -- cgit v1.2.3