Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-03-26 16:49:59 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-03-26 16:50:18 +0300
commitc0ef4e9b788b8db433bf3e92bd19ee00f86f9866 (patch)
tree3ef303f1d1cfcbfbb5c6026a20a9c288df202a75 /source/blender/blenkernel/intern/writeffmpeg.c
parentf80064f2d24408aa85c84f3c328ef470baf39e7c (diff)
Fix T44122, rendering OpenGL preview movie with audio has wrong audio
range and extra frames. Issue here is that the movie backend would unconditionally use the start frame of the scene instead of the preview frame. Solved by passing an explicit "preview" argument. Strictly speaking, the preview argument is part of the renderdata struct, that is also passed to the code, but when rendering the final result we want to unconditionally render the full range regardless of the preview setting of the render structure. However, OpenGL rendering does use the preview range so we need to account for that when making those exports. This is also a nice chance to correct the filenames, which still used the full range.
Diffstat (limited to 'source/blender/blenkernel/intern/writeffmpeg.c')
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 57a4927e149..0717369cde8 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -69,6 +69,7 @@ static int ffmpeg_audio_bitrate = 128;
static int ffmpeg_gop_size = 12;
static int ffmpeg_autosplit = 0;
static int ffmpeg_autosplit_count = 0;
+static bool ffmpeg_preview = false;
static AVFormatContext *outfile = 0;
static AVStream *video_stream = 0;
@@ -816,7 +817,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
ffmpeg_autosplit = rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT;
/* Determine the correct filename */
- BKE_ffmpeg_filepath_get(name, rd);
+ BKE_ffmpeg_filepath_get(name, rd, ffmpeg_preview);
PRINT("Starting output to %s(ffmpeg)...\n"
" Using type=%d, codec=%d, audio_codec=%d,\n"
" video_bitrate=%d, audio_bitrate=%d,\n"
@@ -1028,15 +1029,25 @@ static void flush_ffmpeg(void)
* ********************************************************************** */
/* Get the output filename-- similar to the other output formats */
-void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
+void BKE_ffmpeg_filepath_get(char *string, RenderData *rd, bool preview)
{
char autosplit[20];
const char **exts = get_file_extensions(rd->ffcodecdata.type);
const char **fe = exts;
+ int sfra, efra;
if (!string || !exts) return;
+ if (preview) {
+ sfra = rd->psfra;
+ efra = rd->pefra;
+ }
+ else {
+ sfra = rd->sfra;
+ efra = rd->efra;
+ }
+
strcpy(string, rd->pic);
BLI_path_abs(string, G.main->name);
@@ -1059,7 +1070,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
if (*fe == NULL) {
strcat(string, autosplit);
- BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ BLI_path_frame_range(string, sfra, efra, 4);
strcat(string, *exts);
}
else {
@@ -1070,18 +1081,19 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
}
else {
if (BLI_path_frame_check_chars(string)) {
- BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ BLI_path_frame_range(string, sfra, efra, 4);
}
strcat(string, autosplit);
}
}
-int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports)
+int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports, bool preview)
{
int success;
ffmpeg_autosplit_count = 0;
+ ffmpeg_preview = preview;
success = start_ffmpeg_impl(rd, rectx, recty, reports);
#ifdef WITH_AUDASPACE
@@ -1111,7 +1123,7 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty,
}
specs.rate = rd->ffcodecdata.audio_mixrate;
- audio_mixdown_device = BKE_sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume);
+ audio_mixdown_device = BKE_sound_mixdown(scene, specs, preview ? rd->psfra : rd->sfra, rd->ffcodecdata.audio_volume);
#ifdef FFMPEG_CODEC_TIME_BASE
c->time_base.den = specs.rate;
c->time_base.num = 1;
@@ -1162,7 +1174,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i
}
#ifdef WITH_AUDASPACE
- write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / (double)rd->frs_sec_base));
+ write_audio_frames((frame - start_frame) / (((double)rd->frs_sec) / (double)rd->frs_sec_base));
#endif
return success;
}