2006-02-05 19:14:46 +00:00
|
|
|
/*
|
2011-02-23 18:03:40 +00:00
|
|
|
*
|
2006-02-05 19:14:46 +00:00
|
|
|
* ffmpeg-write support
|
|
|
|
*
|
|
|
|
* Partial Copyright (c) 2006 Peter Schlaile
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-10-10 09:38:02 +00:00
|
|
|
/** \file blender/blenkernel/intern/writeffmpeg.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#ifdef WITH_FFMPEG
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-10-18 07:24:08 +00:00
|
|
|
#if defined(_WIN32) && defined(DEBUG) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
2006-12-06 09:48:27 +00:00
|
|
|
/* This does not seem necessary or present on MSVC 8, but may be needed in earlier versions? */
|
|
|
|
#if _MSC_VER < 1400
|
2006-03-12 14:11:23 +00:00
|
|
|
#include <stdint.h>
|
2006-11-18 02:48:18 +00:00
|
|
|
#endif
|
2006-12-06 09:48:27 +00:00
|
|
|
#endif
|
2006-11-18 02:48:18 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#include <stdlib.h>
|
2006-11-18 02:48:18 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavutil/rational.h>
|
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
#include <libavcodec/opt.h>
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
2009-12-22 12:01:32 +00:00
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
2011-06-23 09:27:56 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
|
|
|
# include "AUD_C-API.h"
|
|
|
|
#endif
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#include "BKE_global.h"
|
2008-05-11 20:40:55 +00:00
|
|
|
#include "BKE_idprop.h"
|
2009-12-22 12:01:32 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_report.h"
|
|
|
|
#include "BKE_sound.h"
|
|
|
|
#include "BKE_writeffmpeg.h"
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
2011-05-27 23:33:40 +00:00
|
|
|
#include "ffmpeg_compat.h"
|
2011-05-27 07:47:42 +00:00
|
|
|
|
2010-12-03 17:05:21 +00:00
|
|
|
extern void do_init_ffmpeg(void);
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
static int ffmpeg_type = 0;
|
|
|
|
static int ffmpeg_codec = CODEC_ID_MPEG4;
|
2010-02-07 23:41:17 +00:00
|
|
|
static int ffmpeg_audio_codec = CODEC_ID_NONE;
|
2006-02-05 19:14:46 +00:00
|
|
|
static int ffmpeg_video_bitrate = 1150;
|
|
|
|
static int ffmpeg_audio_bitrate = 128;
|
|
|
|
static int ffmpeg_gop_size = 12;
|
|
|
|
static int ffmpeg_autosplit = 0;
|
|
|
|
static int ffmpeg_autosplit_count = 0;
|
|
|
|
|
2006-06-04 18:05:47 +00:00
|
|
|
static AVFormatContext* outfile = 0;
|
|
|
|
static AVStream* video_stream = 0;
|
|
|
|
static AVStream* audio_stream = 0;
|
|
|
|
static AVFrame* current_frame = 0;
|
2007-09-23 14:05:22 +00:00
|
|
|
static struct SwsContext *img_convert_ctx = 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
static uint8_t* video_buffer = 0;
|
|
|
|
static int video_buffersize = 0;
|
|
|
|
|
|
|
|
static uint8_t* audio_input_buffer = 0;
|
2010-02-14 15:38:05 +00:00
|
|
|
static int audio_input_samples = 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
static uint8_t* audio_output_buffer = 0;
|
|
|
|
static int audio_outbuf_size = 0;
|
2010-02-07 23:41:17 +00:00
|
|
|
static double audio_time = 0.0f;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2009-08-09 21:16:39 +00:00
|
|
|
static AUD_Device* audio_mixdown_device = 0;
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#define FFMPEG_AUTOSPLIT_SIZE 2000000000
|
|
|
|
|
|
|
|
/* Delete a picture buffer */
|
|
|
|
|
2006-07-09 13:05:09 +00:00
|
|
|
static void delete_picture(AVFrame* f)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
if (f) {
|
|
|
|
if (f->data[0]) MEM_freeN(f->data[0]);
|
|
|
|
av_free(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2006-07-09 13:05:09 +00:00
|
|
|
static int write_audio_frame(void)
|
|
|
|
{
|
2006-02-05 19:14:46 +00:00
|
|
|
AVCodecContext* c = NULL;
|
|
|
|
AVPacket pkt;
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
c = audio_stream->codec;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
av_init_packet(&pkt);
|
2010-02-07 23:41:17 +00:00
|
|
|
pkt.size = 0;
|
|
|
|
|
2010-02-14 15:38:05 +00:00
|
|
|
AUD_readDevice(audio_mixdown_device, audio_input_buffer, audio_input_samples);
|
|
|
|
audio_time += (double) audio_input_samples / (double) c->sample_rate;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
pkt.size = avcodec_encode_audio(c, audio_output_buffer,
|
2010-02-07 23:41:17 +00:00
|
|
|
audio_outbuf_size,
|
2006-02-05 19:14:46 +00:00
|
|
|
(short*) audio_input_buffer);
|
2010-02-07 23:41:17 +00:00
|
|
|
|
2010-02-14 15:38:05 +00:00
|
|
|
if(pkt.size < 0)
|
2010-02-07 23:41:17 +00:00
|
|
|
{
|
|
|
|
// XXX error("Error writing audio packet");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
pkt.data = audio_output_buffer;
|
2010-02-07 23:41:17 +00:00
|
|
|
|
|
|
|
if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
|
|
|
|
{
|
|
|
|
pkt.pts = av_rescale_q(c->coded_frame->pts,
|
2011-05-26 21:57:02 +00:00
|
|
|
c->time_base, audio_stream->time_base);
|
2010-02-07 23:41:17 +00:00
|
|
|
fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
|
|
|
|
}
|
2006-07-09 13:05:09 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
pkt.stream_index = audio_stream->index;
|
2011-05-26 21:57:02 +00:00
|
|
|
|
|
|
|
pkt.flags |= AV_PKT_FLAG_KEY;
|
|
|
|
|
2007-01-28 18:45:53 +00:00
|
|
|
if (av_interleaved_write_frame(outfile, &pkt) != 0) {
|
2010-09-27 07:37:36 +00:00
|
|
|
fprintf(stderr, "Error writing audio packet!\n");
|
2006-02-05 19:14:46 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif // #ifdef WITH_AUDASPACE
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
/* Allocate a temporary frame */
|
2006-07-09 13:05:09 +00:00
|
|
|
static AVFrame* alloc_picture(int pix_fmt, int width, int height)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
AVFrame* f;
|
|
|
|
uint8_t* buf;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
/* allocate space for the struct */
|
|
|
|
f = avcodec_alloc_frame();
|
|
|
|
if (!f) return NULL;
|
|
|
|
size = avpicture_get_size(pix_fmt, width, height);
|
|
|
|
/* allocate the actual picture buffer */
|
|
|
|
buf = MEM_mallocN(size, "AVFrame buffer");
|
|
|
|
if (!buf) {
|
|
|
|
free(f);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
avpicture_fill((AVPicture*)f, buf, pix_fmt, width, height);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
2006-07-09 13:05:09 +00:00
|
|
|
/* Get the correct file extensions for the requested format,
|
|
|
|
first is always desired guess_format parameter */
|
|
|
|
static const char** get_file_extensions(int format)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
switch(format) {
|
2006-07-09 13:05:09 +00:00
|
|
|
case FFMPEG_DV: {
|
|
|
|
static const char * rv[] = { ".dv", NULL };
|
|
|
|
return rv;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
2006-07-09 13:05:09 +00:00
|
|
|
case FFMPEG_MPEG1: {
|
|
|
|
static const char * rv[] = { ".mpg", ".mpeg", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_MPEG2: {
|
|
|
|
static const char * rv[] = { ".dvd", ".vob", ".mpg", ".mpeg",
|
2010-03-22 09:30:00 +00:00
|
|
|
NULL };
|
2006-07-09 13:05:09 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_MPEG4: {
|
|
|
|
static const char * rv[] = { ".mp4", ".mpg", ".mpeg", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_AVI: {
|
|
|
|
static const char * rv[] = { ".avi", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_MOV: {
|
|
|
|
static const char * rv[] = { ".mov", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_H264: {
|
|
|
|
/* FIXME: avi for now... */
|
|
|
|
static const char * rv[] = { ".avi", NULL };
|
|
|
|
return rv;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 13:05:09 +00:00
|
|
|
case FFMPEG_XVID: {
|
|
|
|
/* FIXME: avi for now... */
|
|
|
|
static const char * rv[] = { ".avi", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
2008-04-13 18:50:16 +00:00
|
|
|
case FFMPEG_FLV: {
|
|
|
|
static const char * rv[] = { ".flv", NULL };
|
2008-05-12 09:01:15 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_MKV: {
|
|
|
|
static const char * rv[] = { ".mkv", NULL };
|
2008-04-13 18:50:16 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2008-10-05 17:31:33 +00:00
|
|
|
case FFMPEG_OGG: {
|
|
|
|
static const char * rv[] = { ".ogg", ".ogv", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
2010-02-07 23:41:17 +00:00
|
|
|
case FFMPEG_MP3: {
|
|
|
|
static const char * rv[] = { ".mp3", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
case FFMPEG_WAV: {
|
|
|
|
static const char * rv[] = { ".wav", NULL };
|
|
|
|
return rv;
|
|
|
|
}
|
2006-07-09 13:05:09 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write a frame to the output file */
|
2012-01-13 09:20:13 +00:00
|
|
|
static int write_video_frame(RenderData *rd, int cfra, AVFrame* frame, ReportList *reports)
|
2006-07-09 13:05:09 +00:00
|
|
|
{
|
2006-02-05 19:14:46 +00:00
|
|
|
int outsize = 0;
|
2009-12-22 12:01:32 +00:00
|
|
|
int ret, success= 1;
|
2011-05-26 21:57:02 +00:00
|
|
|
AVCodecContext* c = video_stream->codec;
|
|
|
|
|
2012-01-13 09:20:13 +00:00
|
|
|
frame->pts = cfra;
|
2011-05-26 21:57:02 +00:00
|
|
|
|
2009-06-09 10:30:16 +00:00
|
|
|
if (rd->mode & R_FIELDS) {
|
|
|
|
frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0);
|
2009-06-08 20:08:19 +00:00
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
outsize = avcodec_encode_video(c, video_buffer, video_buffersize,
|
2010-03-22 09:30:00 +00:00
|
|
|
frame);
|
2012-02-07 17:11:56 +00:00
|
|
|
|
|
|
|
if (outsize > 0) {
|
2006-02-05 19:14:46 +00:00
|
|
|
AVPacket packet;
|
|
|
|
av_init_packet(&packet);
|
|
|
|
|
2008-10-05 17:31:33 +00:00
|
|
|
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
|
|
|
|
packet.pts = av_rescale_q(c->coded_frame->pts,
|
|
|
|
c->time_base,
|
|
|
|
video_stream->time_base);
|
2009-09-17 14:46:22 +00:00
|
|
|
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
|
2008-10-05 17:31:33 +00:00
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Video Frame PTS: not set\n");
|
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
if (c->coded_frame->key_frame)
|
2011-05-26 21:57:02 +00:00
|
|
|
packet.flags |= AV_PKT_FLAG_KEY;
|
2006-02-05 19:14:46 +00:00
|
|
|
packet.stream_index = video_stream->index;
|
|
|
|
packet.data = video_buffer;
|
|
|
|
packet.size = outsize;
|
2007-01-28 18:45:53 +00:00
|
|
|
ret = av_interleaved_write_frame(outfile, &packet);
|
2012-02-07 17:11:56 +00:00
|
|
|
success = (ret == 0);
|
|
|
|
} else if (outsize < 0) {
|
|
|
|
success = 0;
|
2010-09-27 07:37:36 +00:00
|
|
|
}
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
if (!success)
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Error writing frame.");
|
|
|
|
|
|
|
|
return success;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* read and encode a frame of audio from the buffer */
|
2009-12-22 12:01:32 +00:00
|
|
|
static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
uint8_t* rendered_frame;
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
AVCodecContext* c = video_stream->codec;
|
2006-02-05 19:14:46 +00:00
|
|
|
int width = c->width;
|
|
|
|
int height = c->height;
|
|
|
|
AVFrame* rgb_frame;
|
|
|
|
|
2012-02-07 20:39:40 +00:00
|
|
|
if (c->pix_fmt != PIX_FMT_BGR32) {
|
|
|
|
rgb_frame = alloc_picture(PIX_FMT_BGR32, width, height);
|
2006-02-05 19:14:46 +00:00
|
|
|
if (!rgb_frame) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Couldn't allocate temporary frame.");
|
2006-02-05 19:14:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rgb_frame = current_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
rendered_frame = pixels;
|
|
|
|
|
|
|
|
/* Do RGBA-conversion and flipping in one step depending
|
|
|
|
on CPU-Endianess */
|
|
|
|
|
2008-12-19 19:11:02 +00:00
|
|
|
if (ENDIAN_ORDER == L_ENDIAN) {
|
2006-02-05 19:14:46 +00:00
|
|
|
int y;
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
uint8_t* target = rgb_frame->data[0]
|
|
|
|
+ width * 4 * (height - y - 1);
|
|
|
|
uint8_t* src = rendered_frame + width * 4 * y;
|
|
|
|
uint8_t* end = src + width * 4;
|
|
|
|
while (src != end) {
|
|
|
|
target[3] = src[3];
|
2009-04-20 15:06:46 +00:00
|
|
|
target[2] = src[2];
|
2006-02-05 19:14:46 +00:00
|
|
|
target[1] = src[1];
|
2009-04-20 15:06:46 +00:00
|
|
|
target[0] = src[0];
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
target += 4;
|
|
|
|
src += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int y;
|
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
uint8_t* target = rgb_frame->data[0]
|
|
|
|
+ width * 4 * (height - y - 1);
|
|
|
|
uint8_t* src = rendered_frame + width * 4 * y;
|
|
|
|
uint8_t* end = src + width * 4;
|
|
|
|
while (src != end) {
|
2009-04-20 15:06:46 +00:00
|
|
|
target[3] = src[0];
|
2006-02-05 19:14:46 +00:00
|
|
|
target[2] = src[1];
|
2009-04-20 15:06:46 +00:00
|
|
|
target[1] = src[2];
|
2006-02-05 19:14:46 +00:00
|
|
|
target[0] = src[3];
|
|
|
|
|
|
|
|
target += 4;
|
|
|
|
src += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-07 20:39:40 +00:00
|
|
|
if (c->pix_fmt != PIX_FMT_BGR32) {
|
2010-06-05 16:52:19 +00:00
|
|
|
sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data,
|
2011-11-11 13:09:14 +00:00
|
|
|
rgb_frame->linesize, 0, c->height,
|
|
|
|
current_frame->data, current_frame->linesize);
|
2006-02-05 19:14:46 +00:00
|
|
|
delete_picture(rgb_frame);
|
|
|
|
}
|
|
|
|
return current_frame;
|
|
|
|
}
|
|
|
|
|
2008-05-11 20:40:55 +00:00
|
|
|
static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
|
|
|
|
{
|
|
|
|
char name[128];
|
|
|
|
char * param;
|
2008-05-11 22:51:56 +00:00
|
|
|
const AVOption * rv = NULL;
|
2008-05-11 20:40:55 +00:00
|
|
|
|
|
|
|
fprintf(stderr, "FFMPEG expert option: %s: ", prop->name);
|
|
|
|
|
2010-04-18 09:12:18 +00:00
|
|
|
BLI_strncpy(name, prop->name, sizeof(name));
|
2008-05-11 20:40:55 +00:00
|
|
|
|
|
|
|
param = strchr(name, ':');
|
|
|
|
|
|
|
|
if (param) {
|
|
|
|
*param++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(prop->type) {
|
|
|
|
case IDP_STRING:
|
|
|
|
fprintf(stderr, "%s.\n", IDP_String(prop));
|
2011-05-26 21:57:02 +00:00
|
|
|
av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
|
2008-05-11 20:40:55 +00:00
|
|
|
break;
|
|
|
|
case IDP_FLOAT:
|
|
|
|
fprintf(stderr, "%g.\n", IDP_Float(prop));
|
|
|
|
rv = av_set_double(c, prop->name, IDP_Float(prop));
|
|
|
|
break;
|
|
|
|
case IDP_INT:
|
|
|
|
fprintf(stderr, "%d.\n", IDP_Int(prop));
|
|
|
|
|
|
|
|
if (param) {
|
|
|
|
if (IDP_Int(prop)) {
|
2011-05-26 21:57:02 +00:00
|
|
|
av_set_string3(c, name, param, 1, &rv);
|
2008-05-11 20:40:55 +00:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rv = av_set_int(c, prop->name, IDP_Int(prop));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rv) {
|
|
|
|
fprintf(stderr, "ffmpeg-option not supported: %s! Skipping.\n",
|
|
|
|
prop->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
static int ffmpeg_proprty_valid(AVCodecContext *c, const char *prop_name, IDProperty *curr)
|
|
|
|
{
|
|
|
|
int valid= 1;
|
|
|
|
|
|
|
|
if(strcmp(prop_name, "video")==0) {
|
|
|
|
if(strcmp(curr->name, "bf")==0) {
|
|
|
|
/* flash codec doesn't support b frames */
|
|
|
|
valid&= c->codec_id!=CODEC_ID_FLV1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char * prop_name)
|
2008-05-11 20:40:55 +00:00
|
|
|
{
|
|
|
|
IDProperty * prop;
|
|
|
|
void * iter;
|
|
|
|
IDProperty * curr;
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if (!rd->ffcodecdata.properties) {
|
2008-05-11 20:40:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-21 08:16:15 +00:00
|
|
|
prop = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, prop_name);
|
2008-05-11 20:40:55 +00:00
|
|
|
if (!prop) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iter = IDP_GetGroupIterator(prop);
|
|
|
|
|
|
|
|
while ((curr = IDP_GroupIterNext(iter)) != NULL) {
|
2011-10-23 17:52:20 +00:00
|
|
|
if(ffmpeg_proprty_valid(c, prop_name, curr))
|
|
|
|
set_ffmpeg_property_option(c, curr);
|
2008-05-11 20:40:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
/* prepare a video stream for the output file */
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext* of,
|
2010-03-22 09:30:00 +00:00
|
|
|
int rectx, int recty)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
AVStream* st;
|
|
|
|
AVCodecContext* c;
|
|
|
|
AVCodec* codec;
|
|
|
|
st = av_new_stream(of, 0);
|
|
|
|
if (!st) return NULL;
|
|
|
|
|
|
|
|
/* Set up the codec context */
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
c = st->codec;
|
2006-02-05 19:14:46 +00:00
|
|
|
c->codec_id = codec_id;
|
2011-05-26 21:57:02 +00:00
|
|
|
c->codec_type = AVMEDIA_TYPE_VIDEO;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Get some values from the current render settings */
|
|
|
|
|
|
|
|
c->width = rectx;
|
|
|
|
c->height = recty;
|
|
|
|
|
|
|
|
/* FIXME: Really bad hack (tm) for NTSC support */
|
2009-01-04 14:14:06 +00:00
|
|
|
if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
|
2006-02-06 19:27:24 +00:00
|
|
|
c->time_base.den = 2997;
|
|
|
|
c->time_base.num = 100;
|
2009-01-04 14:14:06 +00:00
|
|
|
} else if ((double) ((int) rd->frs_sec_base) ==
|
|
|
|
rd->frs_sec_base) {
|
|
|
|
c->time_base.den = rd->frs_sec;
|
|
|
|
c->time_base.num = (int) rd->frs_sec_base;
|
== Core ==
This adds fractional FPS support to blender and should finally
make NTSC work correctly.
NTSC has an FPS of 30.0/1.001 which is approximately 29.97 FPS.
Therefore, it is not enough to simply make frs_sec a float, since
you can't represent this accurately enough.
I added a seperate variable frs_sec_base and FPS is now
frs_sec / frs_sec_base.
I changed all the places, where frs_sec was used to my best knowledge.
For convenience sake, I added several macros, that should make life
easier in the future:
FRA2TIME(a) : convert frame number to a double precision time in seconds
TIME2FRA(a) : the same in the opposite direction
FPS : return current FPS as a double precision number
(last resort)
This closes bug #6715
Standard framerates not supported / breaks sync -- 23.967 29.967 etc.
https://projects.blender.org/tracker/?func=detail&aid=6715&group_id=9&atid=125
Please give this heavy testing with NTSC files, quicktime in/export
and the python interface.
Errors are most probably only spotted on longer timelines, so that is
also important.
The patch was tested by Troy Sobotka and me, so it most probably should
work out of the box, but wider testing is important, since errors are
very subtle.
Enjoy!
2007-10-21 15:42:08 +00:00
|
|
|
} else {
|
2009-01-04 14:14:06 +00:00
|
|
|
c->time_base.den = rd->frs_sec * 100000;
|
|
|
|
c->time_base.num = ((double) rd->frs_sec_base) * 100000;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c->gop_size = ffmpeg_gop_size;
|
|
|
|
c->bit_rate = ffmpeg_video_bitrate*1000;
|
2009-01-04 14:14:06 +00:00
|
|
|
c->rc_max_rate = rd->ffcodecdata.rc_max_rate*1000;
|
|
|
|
c->rc_min_rate = rd->ffcodecdata.rc_min_rate*1000;
|
|
|
|
c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024;
|
2006-02-05 19:14:46 +00:00
|
|
|
c->rc_initial_buffer_occupancy
|
2009-01-04 14:14:06 +00:00
|
|
|
= rd->ffcodecdata.rc_buffer_size*3/4;
|
2006-02-05 19:14:46 +00:00
|
|
|
c->rc_buffer_aggressivity = 1.0;
|
|
|
|
c->me_method = ME_EPZS;
|
|
|
|
|
|
|
|
codec = avcodec_find_encoder(c->codec_id);
|
|
|
|
if (!codec) return NULL;
|
|
|
|
|
|
|
|
/* Be sure to use the correct pixel format(e.g. RGB, YUV) */
|
2012-02-07 17:11:56 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
if (codec->pix_fmts) {
|
|
|
|
c->pix_fmt = codec->pix_fmts[0];
|
|
|
|
} else {
|
|
|
|
/* makes HuffYUV happy ... */
|
|
|
|
c->pix_fmt = PIX_FMT_YUV422P;
|
|
|
|
}
|
2006-06-09 19:48:50 +00:00
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
if (ffmpeg_type == FFMPEG_XVID) {
|
2006-06-09 19:48:50 +00:00
|
|
|
/* arghhhh ... */
|
|
|
|
c->pix_fmt = PIX_FMT_YUV420P;
|
2010-09-13 12:56:39 +00:00
|
|
|
c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X');
|
2006-06-09 19:48:50 +00:00
|
|
|
}
|
2010-05-04 00:28:41 +00:00
|
|
|
|
|
|
|
if (codec_id == CODEC_ID_H264) {
|
|
|
|
/* correct wrong default ffmpeg param which crash x264 */
|
|
|
|
c->qmin=10;
|
|
|
|
c->qmax=51;
|
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2011-10-03 03:25:05 +00:00
|
|
|
// Keep lossless encodes in the RGB domain.
|
2012-02-24 09:49:44 +00:00
|
|
|
if (codec_id == CODEC_ID_HUFFYUV) {
|
2011-10-03 03:25:05 +00:00
|
|
|
/* HUFFYUV was PIX_FMT_YUV422P before */
|
|
|
|
c->pix_fmt = PIX_FMT_RGB32;
|
|
|
|
}
|
|
|
|
|
2012-02-24 09:49:44 +00:00
|
|
|
if (codec_id == CODEC_ID_FFV1) {
|
2012-02-24 15:34:57 +00:00
|
|
|
#ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
|
2012-02-24 09:49:44 +00:00
|
|
|
if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
|
|
|
|
c->pix_fmt = PIX_FMT_RGB32;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c->pix_fmt = PIX_FMT_BGR0;
|
|
|
|
}
|
2012-02-24 15:34:57 +00:00
|
|
|
#else
|
|
|
|
c->pix_fmt = PIX_FMT_RGB32;
|
|
|
|
#endif
|
2012-02-24 09:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (codec_id == CODEC_ID_QTRLE ) {
|
2012-02-07 17:11:56 +00:00
|
|
|
if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
|
|
|
|
c->pix_fmt = PIX_FMT_ARGB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
if ((of->oformat->flags & AVFMT_GLOBALHEADER)
|
|
|
|
// || !strcmp(of->oformat->name, "mp4")
|
|
|
|
// || !strcmp(of->oformat->name, "mov")
|
|
|
|
// || !strcmp(of->oformat->name, "3gp")
|
|
|
|
) {
|
2006-02-05 19:14:46 +00:00
|
|
|
fprintf(stderr, "Using global header\n");
|
|
|
|
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine whether we are encoding interlaced material or not */
|
2009-01-04 14:14:06 +00:00
|
|
|
if (rd->mode & R_FIELDS) {
|
2006-02-05 19:14:46 +00:00
|
|
|
fprintf(stderr, "Encoding interlaced video\n");
|
|
|
|
c->flags |= CODEC_FLAG_INTERLACED_DCT;
|
|
|
|
c->flags |= CODEC_FLAG_INTERLACED_ME;
|
2008-05-11 20:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* xasp & yasp got float lately... */
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
st->sample_aspect_ratio = c->sample_aspect_ratio = av_d2q(
|
2009-01-04 14:14:06 +00:00
|
|
|
((double) rd->xasp / (double) rd->yasp), 255);
|
2008-05-11 20:40:55 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
set_ffmpeg_properties(rd, c, "video");
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
if (avcodec_open(c, codec) < 0) {
|
2008-01-02 12:35:30 +00:00
|
|
|
//
|
|
|
|
//XXX error("Couldn't initialize codec");
|
2006-02-05 19:14:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
if ( codec_id == CODEC_ID_QTRLE ) {
|
|
|
|
// normally it should be enough to have buffer with actual image size,
|
|
|
|
// but some codecs like QTRLE might store extra information in this buffer,
|
|
|
|
// so it should be a way larger
|
|
|
|
|
|
|
|
// maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664)
|
|
|
|
// (from FFmpeg sources)
|
|
|
|
int size = c->width * c->height;
|
|
|
|
video_buffersize = 7*size + 10000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
video_buffersize = avpicture_get_size(c->pix_fmt, c->width, c->height);
|
|
|
|
|
2011-10-03 03:25:05 +00:00
|
|
|
video_buffer = (uint8_t*)MEM_mallocN(video_buffersize*sizeof(uint8_t),
|
2010-03-22 09:30:00 +00:00
|
|
|
"FFMPEG video buffer");
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
|
2007-09-23 14:05:22 +00:00
|
|
|
|
|
|
|
img_convert_ctx = sws_getContext(c->width, c->height,
|
2012-02-07 20:39:40 +00:00
|
|
|
PIX_FMT_BGR32,
|
2007-09-23 14:05:22 +00:00
|
|
|
c->width, c->height,
|
|
|
|
c->pix_fmt,
|
|
|
|
SWS_BICUBIC,
|
|
|
|
NULL, NULL, NULL);
|
2006-02-05 19:14:46 +00:00
|
|
|
return st;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prepare an audio stream for the output file */
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext* of)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
AVStream* st;
|
|
|
|
AVCodecContext* c;
|
|
|
|
AVCodec* codec;
|
|
|
|
|
|
|
|
st = av_new_stream(of, 1);
|
|
|
|
if (!st) return NULL;
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
c = st->codec;
|
2006-02-05 19:14:46 +00:00
|
|
|
c->codec_id = codec_id;
|
2011-05-26 21:57:02 +00:00
|
|
|
c->codec_type = AVMEDIA_TYPE_AUDIO;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2009-09-20 14:00:00 +00:00
|
|
|
c->sample_rate = rd->ffcodecdata.audio_mixrate;
|
2006-02-05 19:14:46 +00:00
|
|
|
c->bit_rate = ffmpeg_audio_bitrate*1000;
|
2010-02-07 23:41:17 +00:00
|
|
|
c->sample_fmt = SAMPLE_FMT_S16;
|
2011-06-21 20:39:41 +00:00
|
|
|
c->channels = rd->ffcodecdata.audio_channels;
|
2006-02-05 19:14:46 +00:00
|
|
|
codec = avcodec_find_encoder(c->codec_id);
|
|
|
|
if (!codec) {
|
2008-01-02 12:35:30 +00:00
|
|
|
//XXX error("Couldn't find a valid audio codec");
|
2006-02-05 19:14:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-05-11 20:40:55 +00:00
|
|
|
|
2009-01-04 18:16:34 +00:00
|
|
|
set_ffmpeg_properties(rd, c, "audio");
|
2008-05-11 20:40:55 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
if (avcodec_open(c, codec) < 0) {
|
2008-01-02 12:35:30 +00:00
|
|
|
//XXX error("Couldn't initialize audio codec");
|
2006-02-05 19:14:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-10-04 12:30:26 +00:00
|
|
|
/* 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) */
|
2011-10-04 15:10:24 +00:00
|
|
|
st->codec->time_base.num= 1;
|
|
|
|
st->codec->time_base.den= st->codec->sample_rate;
|
2011-10-04 12:30:26 +00:00
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
audio_outbuf_size = FF_MIN_BUFFER_SIZE;
|
|
|
|
|
|
|
|
if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
|
2010-02-14 15:38:05 +00:00
|
|
|
audio_input_samples = audio_outbuf_size * 8 / c->bits_per_coded_sample / c->channels;
|
2010-02-07 23:41:17 +00:00
|
|
|
else
|
2010-02-14 15:38:05 +00:00
|
|
|
{
|
|
|
|
audio_input_samples = c->frame_size;
|
|
|
|
if(c->frame_size * c->channels * sizeof(int16_t) * 4 > audio_outbuf_size)
|
|
|
|
audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4;
|
|
|
|
}
|
|
|
|
|
2011-06-21 20:39:41 +00:00
|
|
|
audio_output_buffer = (uint8_t*)av_malloc(
|
|
|
|
audio_outbuf_size);
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2011-06-21 20:39:41 +00:00
|
|
|
audio_input_buffer = (uint8_t*)av_malloc(
|
|
|
|
audio_input_samples * c->channels * sizeof(int16_t));
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
audio_time = 0.0f;
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
return st;
|
|
|
|
}
|
|
|
|
/* essential functions -- start, append, end */
|
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, ReportList *reports)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
|
|
|
/* Handle to the output file */
|
|
|
|
AVFormatContext* of;
|
|
|
|
AVOutputFormat* fmt;
|
2006-03-27 22:20:24 +00:00
|
|
|
char name[256];
|
2006-07-09 13:05:09 +00:00
|
|
|
const char ** exts;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
ffmpeg_type = rd->ffcodecdata.type;
|
|
|
|
ffmpeg_codec = rd->ffcodecdata.codec;
|
|
|
|
ffmpeg_audio_codec = rd->ffcodecdata.audio_codec;
|
|
|
|
ffmpeg_video_bitrate = rd->ffcodecdata.video_bitrate;
|
|
|
|
ffmpeg_audio_bitrate = rd->ffcodecdata.audio_bitrate;
|
|
|
|
ffmpeg_gop_size = rd->ffcodecdata.gop_size;
|
|
|
|
ffmpeg_autosplit = rd->ffcodecdata.flags
|
|
|
|
& FFMPEG_AUTOSPLIT_OUTPUT;
|
|
|
|
|
|
|
|
do_init_ffmpeg();
|
|
|
|
|
|
|
|
/* Determine the correct filename */
|
2010-01-08 13:52:38 +00:00
|
|
|
filepath_ffmpeg(name, rd);
|
2006-06-07 12:53:51 +00:00
|
|
|
fprintf(stderr, "Starting output to %s(ffmpeg)...\n"
|
|
|
|
" Using type=%d, codec=%d, audio_codec=%d,\n"
|
|
|
|
" video_bitrate=%d, audio_bitrate=%d,\n"
|
2010-02-07 23:41:17 +00:00
|
|
|
" gop_size=%d, autosplit=%d\n"
|
2006-06-07 12:53:51 +00:00
|
|
|
" render width=%d, render height=%d\n",
|
|
|
|
name, ffmpeg_type, ffmpeg_codec, ffmpeg_audio_codec,
|
|
|
|
ffmpeg_video_bitrate, ffmpeg_audio_bitrate,
|
2010-02-07 23:41:17 +00:00
|
|
|
ffmpeg_gop_size, ffmpeg_autosplit, rectx, recty);
|
2006-02-05 19:14:46 +00:00
|
|
|
|
2006-07-09 13:05:09 +00:00
|
|
|
exts = get_file_extensions(ffmpeg_type);
|
|
|
|
if (!exts) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "No valid formats found.");
|
|
|
|
return 0;
|
2006-07-09 13:05:09 +00:00
|
|
|
}
|
2011-05-26 21:57:02 +00:00
|
|
|
fmt = av_guess_format(NULL, exts[0], NULL);
|
2006-02-05 19:14:46 +00:00
|
|
|
if (!fmt) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "No valid formats found.");
|
|
|
|
return 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
of = avformat_alloc_context();
|
2006-02-05 19:14:46 +00:00
|
|
|
if (!of) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Error opening output file");
|
|
|
|
return 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
of->oformat = fmt;
|
2009-01-04 14:14:06 +00:00
|
|
|
of->packet_size= rd->ffcodecdata.mux_packet_size;
|
2010-02-07 23:41:17 +00:00
|
|
|
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
|
2009-01-04 14:14:06 +00:00
|
|
|
of->mux_rate = rd->ffcodecdata.mux_rate;
|
2006-02-05 19:14:46 +00:00
|
|
|
} else {
|
|
|
|
of->mux_rate = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
of->preload = (int)(0.5*AV_TIME_BASE);
|
|
|
|
of->max_delay = (int)(0.7*AV_TIME_BASE);
|
2006-05-21 12:20:45 +00:00
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
fmt->audio_codec = ffmpeg_audio_codec;
|
|
|
|
|
2011-08-30 10:07:50 +00:00
|
|
|
BLI_snprintf(of->filename, sizeof(of->filename), "%s", name);
|
2006-02-05 19:14:46 +00:00
|
|
|
/* set the codec to the user's selection */
|
|
|
|
switch(ffmpeg_type) {
|
2006-06-09 19:48:50 +00:00
|
|
|
case FFMPEG_AVI:
|
|
|
|
case FFMPEG_MOV:
|
2008-10-05 17:31:33 +00:00
|
|
|
case FFMPEG_MKV:
|
2006-06-09 19:48:50 +00:00
|
|
|
fmt->video_codec = ffmpeg_codec;
|
|
|
|
break;
|
2011-08-10 07:36:44 +00:00
|
|
|
case FFMPEG_OGG:
|
|
|
|
fmt->video_codec = CODEC_ID_THEORA;
|
|
|
|
break;
|
2006-06-09 19:48:50 +00:00
|
|
|
case FFMPEG_DV:
|
|
|
|
fmt->video_codec = CODEC_ID_DVVIDEO;
|
|
|
|
break;
|
|
|
|
case FFMPEG_MPEG1:
|
|
|
|
fmt->video_codec = CODEC_ID_MPEG1VIDEO;
|
|
|
|
break;
|
|
|
|
case FFMPEG_MPEG2:
|
|
|
|
fmt->video_codec = CODEC_ID_MPEG2VIDEO;
|
|
|
|
break;
|
|
|
|
case FFMPEG_H264:
|
|
|
|
fmt->video_codec = CODEC_ID_H264;
|
|
|
|
break;
|
|
|
|
case FFMPEG_XVID:
|
2011-05-26 21:57:02 +00:00
|
|
|
fmt->video_codec = CODEC_ID_MPEG4;
|
2006-06-09 19:48:50 +00:00
|
|
|
break;
|
2008-04-13 18:50:16 +00:00
|
|
|
case FFMPEG_FLV:
|
|
|
|
fmt->video_codec = CODEC_ID_FLV1;
|
|
|
|
break;
|
2010-02-07 23:41:17 +00:00
|
|
|
case FFMPEG_MP3:
|
|
|
|
fmt->audio_codec = CODEC_ID_MP3;
|
|
|
|
case FFMPEG_WAV:
|
|
|
|
fmt->video_codec = CODEC_ID_NONE;
|
|
|
|
break;
|
2006-06-09 19:48:50 +00:00
|
|
|
case FFMPEG_MPEG4:
|
|
|
|
default:
|
|
|
|
fmt->video_codec = CODEC_ID_MPEG4;
|
|
|
|
break;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
2006-06-07 12:53:51 +00:00
|
|
|
if (fmt->video_codec == CODEC_ID_DVVIDEO) {
|
|
|
|
if (rectx != 720) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Render width has to be 720 pixels for DV!");
|
|
|
|
return 0;
|
2006-06-07 12:53:51 +00:00
|
|
|
}
|
2009-01-04 14:14:06 +00:00
|
|
|
if (rd->frs_sec != 25 && recty != 480) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Render height has to be 480 pixels for DV-NTSC!");
|
|
|
|
return 0;
|
2006-06-07 12:53:51 +00:00
|
|
|
}
|
2009-01-04 14:14:06 +00:00
|
|
|
if (rd->frs_sec == 25 && recty != 576) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Render height has to be 576 pixels for DV-PAL!");
|
|
|
|
return 0;
|
2006-06-07 12:53:51 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-22 07:40:04 +00:00
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
if (ffmpeg_type == FFMPEG_DV) {
|
|
|
|
fmt->audio_codec = CODEC_ID_PCM_S16LE;
|
2011-06-21 20:39:41 +00:00
|
|
|
if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!");
|
|
|
|
return 0;
|
2006-06-07 12:53:51 +00:00
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
if (fmt->video_codec != CODEC_ID_NONE) {
|
|
|
|
video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty);
|
|
|
|
printf("alloc video stream %p\n", video_stream);
|
|
|
|
if (!video_stream) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Error initializing video stream.");
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
2010-02-07 23:41:17 +00:00
|
|
|
|
|
|
|
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
|
2009-01-04 14:14:06 +00:00
|
|
|
audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of);
|
2006-02-05 19:14:46 +00:00
|
|
|
if (!audio_stream) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Error initializing audio stream.");
|
|
|
|
return 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (av_set_parameters(of, NULL) < 0) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Error setting output parameters.");
|
|
|
|
return 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
if (!(fmt->flags & AVFMT_NOFILE)) {
|
2011-05-26 21:57:02 +00:00
|
|
|
if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
|
2009-12-22 12:01:32 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Could not open file for writing.");
|
|
|
|
return 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-04 12:30:26 +00:00
|
|
|
if (av_write_header(of) < 0) {
|
|
|
|
BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
outfile = of;
|
2011-05-26 21:57:02 +00:00
|
|
|
av_dump_format(of, 0, name, 1);
|
2009-12-22 12:01:32 +00:00
|
|
|
|
|
|
|
return 1;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
2010-09-27 07:37:36 +00:00
|
|
|
/**
|
|
|
|
* Writes any delayed frames in the encoder. This function is called before
|
|
|
|
* closing the encoder.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* Since an encoder may use both past and future frames to predict
|
|
|
|
* inter-frames (H.264 B-frames, for example), it can output the frames
|
|
|
|
* in a different order from the one it was given.
|
|
|
|
* For example, when sending frames 1, 2, 3, 4 to the encoder, it may write
|
|
|
|
* them in the order 1, 4, 2, 3 - first the two frames used for predition,
|
|
|
|
* and then the bidirectionally-predicted frames. What this means in practice
|
|
|
|
* is that the encoder may not immediately produce one output frame for each
|
|
|
|
* input frame. These delayed frames must be flushed before we close the
|
|
|
|
* stream. We do this by calling avcodec_encode_video with NULL for the last
|
|
|
|
* parameter.
|
|
|
|
* </p>
|
|
|
|
*/
|
|
|
|
void flush_ffmpeg(void)
|
|
|
|
{
|
|
|
|
int outsize = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
AVCodecContext* c = video_stream->codec;
|
2010-09-27 07:37:36 +00:00
|
|
|
/* get the delayed frames */
|
|
|
|
while (1) {
|
|
|
|
AVPacket packet;
|
|
|
|
av_init_packet(&packet);
|
|
|
|
|
|
|
|
outsize = avcodec_encode_video(c, video_buffer, video_buffersize, NULL);
|
|
|
|
if (outsize < 0) {
|
|
|
|
fprintf(stderr, "Error encoding delayed frame %d\n", outsize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (outsize == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
|
|
|
|
packet.pts = av_rescale_q(c->coded_frame->pts,
|
|
|
|
c->time_base,
|
|
|
|
video_stream->time_base);
|
|
|
|
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Video Frame PTS: not set\n");
|
|
|
|
}
|
|
|
|
if (c->coded_frame->key_frame) {
|
2011-05-26 21:57:02 +00:00
|
|
|
packet.flags |= AV_PKT_FLAG_KEY;
|
2010-09-27 07:37:36 +00:00
|
|
|
}
|
|
|
|
packet.stream_index = video_stream->index;
|
|
|
|
packet.data = video_buffer;
|
|
|
|
packet.size = outsize;
|
|
|
|
ret = av_interleaved_write_frame(outfile, &packet);
|
|
|
|
if (ret != 0) {
|
|
|
|
fprintf(stderr, "Error writing delayed frame %d\n", ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-05-26 21:57:02 +00:00
|
|
|
avcodec_flush_buffers(video_stream->codec);
|
2010-09-27 07:37:36 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 13:05:09 +00:00
|
|
|
/* **********************************************************************
|
|
|
|
* public interface
|
|
|
|
********************************************************************** */
|
|
|
|
|
|
|
|
/* Get the output filename-- similar to the other output formats */
|
2011-09-28 05:53:40 +00:00
|
|
|
void filepath_ffmpeg(char* string, RenderData* rd)
|
|
|
|
{
|
2006-07-09 13:05:09 +00:00
|
|
|
char autosplit[20];
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
const char ** exts = get_file_extensions(rd->ffcodecdata.type);
|
2006-07-09 13:05:09 +00:00
|
|
|
const char ** fe = exts;
|
|
|
|
|
|
|
|
if (!string || !exts) return;
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
strcpy(string, rd->pic);
|
2010-10-18 06:41:16 +00:00
|
|
|
BLI_path_abs(string, G.main->name);
|
2006-07-09 13:05:09 +00:00
|
|
|
|
|
|
|
BLI_make_existing_file(string);
|
|
|
|
|
|
|
|
autosplit[0] = 0;
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) {
|
2006-07-09 13:05:09 +00:00
|
|
|
sprintf(autosplit, "_%03d", ffmpeg_autosplit_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*fe) {
|
|
|
|
if (BLI_strcasecmp(string + strlen(string) - strlen(*fe),
|
|
|
|
*fe) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fe++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*fe) {
|
|
|
|
strcat(string, autosplit);
|
2010-01-26 21:41:38 +00:00
|
|
|
|
2010-03-09 17:36:23 +00:00
|
|
|
BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
|
2010-01-26 21:41:38 +00:00
|
|
|
strcat(string, *exts);
|
2006-07-09 13:05:09 +00:00
|
|
|
} else {
|
|
|
|
*(string + strlen(string) - strlen(*fe)) = 0;
|
|
|
|
strcat(string, autosplit);
|
|
|
|
strcat(string, *fe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
2009-12-22 12:01:32 +00:00
|
|
|
int success;
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
ffmpeg_autosplit_count = 0;
|
|
|
|
|
2009-12-22 12:01:32 +00:00
|
|
|
success = start_ffmpeg_impl(rd, rectx, recty, reports);
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2010-02-07 23:41:17 +00:00
|
|
|
if(audio_stream)
|
2009-08-09 21:16:39 +00:00
|
|
|
{
|
2011-05-26 21:57:02 +00:00
|
|
|
AVCodecContext* c = audio_stream->codec;
|
2010-01-01 05:09:30 +00:00
|
|
|
AUD_DeviceSpecs specs;
|
2009-08-09 21:16:39 +00:00
|
|
|
specs.channels = c->channels;
|
|
|
|
specs.format = AUD_FORMAT_S16;
|
2009-09-20 14:00:00 +00:00
|
|
|
specs.rate = rd->ffcodecdata.audio_mixrate;
|
2010-02-07 23:41:17 +00:00
|
|
|
audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume);
|
2011-06-23 07:16:06 +00:00
|
|
|
#ifdef FFMPEG_CODEC_TIME_BASE
|
|
|
|
c->time_base.den = specs.rate;
|
|
|
|
c->time_base.num = 1;
|
|
|
|
#endif
|
2009-08-09 21:16:39 +00:00
|
|
|
}
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif
|
2009-12-22 12:01:32 +00:00
|
|
|
return success;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void end_ffmpeg(void);
|
|
|
|
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2010-02-07 23:41:17 +00:00
|
|
|
static void write_audio_frames(double to_pts)
|
2007-01-28 18:45:53 +00:00
|
|
|
{
|
|
|
|
int finished = 0;
|
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
while (audio_stream && !finished) {
|
|
|
|
if((audio_time >= to_pts) ||
|
|
|
|
(write_audio_frame())) {
|
2007-01-28 18:45:53 +00:00
|
|
|
finished = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif
|
2007-01-28 18:45:53 +00:00
|
|
|
|
2012-01-13 09:20:13 +00:00
|
|
|
int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports)
|
2006-02-05 19:14:46 +00:00
|
|
|
{
|
2009-12-22 12:01:32 +00:00
|
|
|
AVFrame* avframe;
|
2010-02-07 23:41:17 +00:00
|
|
|
int success = 1;
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2006-06-07 12:53:51 +00:00
|
|
|
fprintf(stderr, "Writing frame %i, "
|
|
|
|
"render width=%d, render height=%d\n", frame,
|
|
|
|
rectx, recty);
|
2007-01-28 18:45:53 +00:00
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
// why is this done before writing the video frame and again at end_ffmpeg?
|
|
|
|
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
if(video_stream)
|
|
|
|
{
|
|
|
|
avframe= generate_video_frame((unsigned char*) pixels, reports);
|
2012-01-13 09:20:13 +00:00
|
|
|
success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
|
2010-02-07 23:41:17 +00:00
|
|
|
|
|
|
|
if (ffmpeg_autosplit) {
|
2011-05-26 21:57:02 +00:00
|
|
|
if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) {
|
2010-02-07 23:41:17 +00:00
|
|
|
end_ffmpeg();
|
|
|
|
ffmpeg_autosplit_count++;
|
|
|
|
success &= start_ffmpeg_impl(rd, rectx, recty, reports);
|
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-22 12:01:32 +00:00
|
|
|
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2010-02-26 21:08:06 +00:00
|
|
|
write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / rd->frs_sec_base));
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif
|
2009-12-22 12:01:32 +00:00
|
|
|
return success;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void end_ffmpeg(void)
|
|
|
|
{
|
2010-10-21 08:32:53 +00:00
|
|
|
unsigned int i;
|
2006-02-05 19:14:46 +00:00
|
|
|
|
|
|
|
fprintf(stderr, "Closing ffmpeg...\n");
|
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
/* if (audio_stream) { SEE UPPER
|
2007-09-23 14:05:22 +00:00
|
|
|
write_audio_frames();
|
2010-02-07 23:41:17 +00:00
|
|
|
}*/
|
2009-08-09 21:16:39 +00:00
|
|
|
|
2011-06-23 16:10:48 +00:00
|
|
|
#ifdef WITH_AUDASPACE
|
2009-08-09 21:16:39 +00:00
|
|
|
if(audio_mixdown_device)
|
|
|
|
{
|
|
|
|
AUD_closeReadDevice(audio_mixdown_device);
|
|
|
|
audio_mixdown_device = 0;
|
|
|
|
}
|
2011-06-23 16:10:48 +00:00
|
|
|
#endif
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
if (video_stream && video_stream->codec) {
|
2010-09-27 07:37:36 +00:00
|
|
|
fprintf(stderr, "Flushing delayed frames...\n");
|
|
|
|
flush_ffmpeg ();
|
|
|
|
}
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
if (outfile) {
|
|
|
|
av_write_trailer(outfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the video codec */
|
|
|
|
|
2011-05-26 21:57:02 +00:00
|
|
|
if (video_stream && video_stream->codec) {
|
|
|
|
avcodec_close(video_stream->codec);
|
2009-12-22 12:01:32 +00:00
|
|
|
printf("zero video stream %p\n", video_stream);
|
2010-09-27 07:37:36 +00:00
|
|
|
video_stream = 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Close the output file */
|
|
|
|
if (outfile) {
|
|
|
|
for (i = 0; i < outfile->nb_streams; i++) {
|
|
|
|
if (&outfile->streams[i]) {
|
|
|
|
av_freep(&outfile->streams[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* free the temp buffer */
|
|
|
|
if (current_frame) {
|
|
|
|
delete_picture(current_frame);
|
2006-06-04 18:05:47 +00:00
|
|
|
current_frame = 0;
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
if (outfile && outfile->oformat) {
|
|
|
|
if (!(outfile->oformat->flags & AVFMT_NOFILE)) {
|
2011-05-26 21:57:02 +00:00
|
|
|
avio_close(outfile->pb);
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (outfile) {
|
|
|
|
av_free(outfile);
|
|
|
|
outfile = 0;
|
|
|
|
}
|
|
|
|
if (video_buffer) {
|
|
|
|
MEM_freeN(video_buffer);
|
|
|
|
video_buffer = 0;
|
|
|
|
}
|
|
|
|
if (audio_output_buffer) {
|
2011-06-21 20:39:41 +00:00
|
|
|
av_free(audio_output_buffer);
|
2006-02-05 19:14:46 +00:00
|
|
|
audio_output_buffer = 0;
|
|
|
|
}
|
|
|
|
if (audio_input_buffer) {
|
2011-06-21 20:39:41 +00:00
|
|
|
av_free(audio_input_buffer);
|
2006-02-05 19:14:46 +00:00
|
|
|
audio_input_buffer = 0;
|
|
|
|
}
|
2007-09-23 14:05:22 +00:00
|
|
|
|
|
|
|
if (img_convert_ctx) {
|
|
|
|
sws_freeContext(img_convert_ctx);
|
|
|
|
img_convert_ctx = 0;
|
|
|
|
}
|
2006-02-05 19:14:46 +00:00
|
|
|
}
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
|
|
|
void ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
|
|
|
|
{
|
|
|
|
struct IDProperty *prop = (struct IDProperty *) prop_;
|
|
|
|
IDProperty * group;
|
|
|
|
|
|
|
|
if (!rd->ffcodecdata.properties) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-21 08:16:15 +00:00
|
|
|
group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if (group && prop) {
|
|
|
|
IDP_RemFromGroup(group, prop);
|
|
|
|
IDP_FreeProperty(prop);
|
|
|
|
MEM_freeN(prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-05 11:04:28 +00:00
|
|
|
IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index)
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
{
|
|
|
|
AVCodecContext c;
|
|
|
|
const AVOption * o;
|
|
|
|
const AVOption * parent;
|
|
|
|
IDProperty * group;
|
|
|
|
IDProperty * prop;
|
|
|
|
IDPropertyTemplate val;
|
|
|
|
int idp_type;
|
|
|
|
char name[256];
|
2010-10-21 07:39:18 +00:00
|
|
|
|
|
|
|
val.i = 0;
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
|
|
|
avcodec_get_context_defaults(&c);
|
|
|
|
|
|
|
|
o = c.av_class->option + opt_index;
|
|
|
|
parent = c.av_class->option + parent_index;
|
|
|
|
|
|
|
|
if (!rd->ffcodecdata.properties) {
|
|
|
|
rd->ffcodecdata.properties
|
2011-11-15 10:01:18 +00:00
|
|
|
= IDP_New(IDP_GROUP, &val, "ffmpeg");
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
}
|
|
|
|
|
2011-10-21 08:16:15 +00:00
|
|
|
group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
|
|
|
if (!group) {
|
2011-11-15 10:01:18 +00:00
|
|
|
group = IDP_New(IDP_GROUP, &val, type);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
IDP_AddToGroup(rd->ffcodecdata.properties, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent_index) {
|
2012-01-11 12:33:51 +00:00
|
|
|
BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
} else {
|
2012-01-11 12:33:51 +00:00
|
|
|
BLI_strncpy(name, o->name, sizeof(name));
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n",
|
|
|
|
type, parent_index, opt_index, name);
|
|
|
|
|
|
|
|
prop = IDP_GetPropertyFromGroup(group, name);
|
|
|
|
if (prop) {
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (o->type) {
|
|
|
|
case FF_OPT_TYPE_INT:
|
|
|
|
case FF_OPT_TYPE_INT64:
|
2011-05-27 23:33:40 +00:00
|
|
|
val.i = FFMPEG_DEF_OPT_VAL_INT(o);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
idp_type = IDP_INT;
|
|
|
|
break;
|
|
|
|
case FF_OPT_TYPE_DOUBLE:
|
|
|
|
case FF_OPT_TYPE_FLOAT:
|
2011-05-27 23:33:40 +00:00
|
|
|
val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
idp_type = IDP_FLOAT;
|
|
|
|
break;
|
|
|
|
case FF_OPT_TYPE_STRING:
|
2011-11-15 10:01:18 +00:00
|
|
|
val.string.str = (char *)" ";
|
|
|
|
val.string.len = 80;
|
|
|
|
/* val.str = (char *)" ";*/
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
idp_type = IDP_STRING;
|
|
|
|
break;
|
|
|
|
case FF_OPT_TYPE_CONST:
|
|
|
|
val.i = 1;
|
|
|
|
idp_type = IDP_INT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-11-15 10:01:18 +00:00
|
|
|
prop = IDP_New(idp_type, &val, name);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
IDP_AddToGroup(group, prop);
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not all versions of ffmpeg include that, so here we go ... */
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
static const AVOption *my_av_find_opt(void *v, const char *name,
|
|
|
|
const char *unit, int mask, int flags)
|
|
|
|
{
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
AVClass *c= *(AVClass**)v;
|
|
|
|
const AVOption *o= c->option;
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
for(;o && o->name; o++) {
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if(!strcmp(o->name, name) &&
|
|
|
|
(!unit || (o->unit && !strcmp(o->unit, unit))) &&
|
|
|
|
(o->flags & mask) == flags )
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str)
|
|
|
|
{
|
|
|
|
AVCodecContext c;
|
|
|
|
const AVOption * o = 0;
|
|
|
|
const AVOption * p = 0;
|
|
|
|
char name_[128];
|
|
|
|
char * name;
|
|
|
|
char * param;
|
|
|
|
IDProperty * prop;
|
|
|
|
|
|
|
|
avcodec_get_context_defaults(&c);
|
|
|
|
|
2010-04-18 09:12:18 +00:00
|
|
|
strncpy(name_, str, sizeof(name_));
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
|
|
|
name = name_;
|
|
|
|
while (*name == ' ') name++;
|
|
|
|
|
|
|
|
param = strchr(name, ':');
|
|
|
|
|
|
|
|
if (!param) {
|
|
|
|
param = strchr(name, ' ');
|
|
|
|
}
|
|
|
|
if (param) {
|
|
|
|
*param++ = 0;
|
|
|
|
while (*param == ' ') param++;
|
|
|
|
}
|
|
|
|
|
|
|
|
o = my_av_find_opt(&c, name, NULL, 0, 0);
|
|
|
|
if (!o) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (param && o->type == FF_OPT_TYPE_CONST) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (param && o->type != FF_OPT_TYPE_CONST && o->unit) {
|
|
|
|
p = my_av_find_opt(&c, param, o->unit, 0, 0);
|
|
|
|
prop = ffmpeg_property_add(rd,
|
|
|
|
(char*) type, p - c.av_class->option,
|
|
|
|
o - c.av_class->option);
|
|
|
|
} else {
|
|
|
|
prop = ffmpeg_property_add(rd,
|
|
|
|
(char*) type, o - c.av_class->option, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param && !p) {
|
|
|
|
switch (prop->type) {
|
|
|
|
case IDP_INT:
|
|
|
|
IDP_Int(prop) = atoi(param);
|
|
|
|
break;
|
|
|
|
case IDP_FLOAT:
|
|
|
|
IDP_Float(prop) = atof(param);
|
|
|
|
break;
|
|
|
|
case IDP_STRING:
|
|
|
|
strncpy(IDP_String(prop), param, prop->len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
static void ffmpeg_set_expert_options(RenderData *rd)
|
2012-01-13 12:34:23 +00:00
|
|
|
{
|
2012-02-07 17:11:56 +00:00
|
|
|
int codec_id = rd->ffcodecdata.codec;
|
|
|
|
|
2012-01-13 12:34:23 +00:00
|
|
|
if(rd->ffcodecdata.properties)
|
|
|
|
IDP_FreeProperty(rd->ffcodecdata.properties);
|
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
if(codec_id == CODEC_ID_H264) {
|
2012-01-13 12:34:23 +00:00
|
|
|
/*
|
|
|
|
* All options here are for x264, but must be set via ffmpeg.
|
|
|
|
* The names are therefore different - Search for "x264 to FFmpeg option mapping"
|
|
|
|
* to get a list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use CABAC coder. Using "coder:1", which should be equivalent,
|
|
|
|
* crashes Blender for some reason. Either way - this is no big deal.
|
|
|
|
*/
|
|
|
|
ffmpeg_property_add_string(rd, "video", "coder:vlc");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The other options were taken from the libx264-default.preset
|
|
|
|
* included in the ffmpeg distribution.
|
|
|
|
*/
|
2012-02-16 11:52:02 +00:00
|
|
|
// ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT
|
2012-01-13 12:34:23 +00:00
|
|
|
ffmpeg_property_add_string(rd, "video", "cmp:chroma");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "partitions:parti4x4");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "partitions:partp8x8");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "partitions:partb8x8");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "me:hex");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "subq:6");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "me_range:16");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "qdiff:4");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "keyint_min:25");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "sc_threshold:40");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "b_strategy:1");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "bf:3");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "refs:2");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "qcomp:0.6");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "directpred:3");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "trellis:0");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "flags2:wpred");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "flags2:dct8x8");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "flags2:fastpskip");
|
|
|
|
ffmpeg_property_add_string(rd, "video", "wpredp:2");
|
|
|
|
|
|
|
|
if(rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
|
|
|
|
ffmpeg_property_add_string(rd, "video", "cqp:0");
|
|
|
|
}
|
2012-02-07 17:11:56 +00:00
|
|
|
#if 0 /* disabled for after release */
|
|
|
|
else if(codec_id == CODEC_ID_DNXHD) {
|
|
|
|
if(rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT)
|
|
|
|
ffmpeg_property_add_string(rd, "video", "mbd:rd");
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-13 12:34:23 +00:00
|
|
|
}
|
|
|
|
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
void ffmpeg_set_preset(RenderData *rd, int preset)
|
|
|
|
{
|
|
|
|
int isntsc = (rd->frs_sec != 25);
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
if(rd->ffcodecdata.properties)
|
|
|
|
IDP_FreeProperty(rd->ffcodecdata.properties);
|
|
|
|
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
switch (preset) {
|
|
|
|
case FFMPEG_PRESET_VCD:
|
|
|
|
rd->ffcodecdata.type = FFMPEG_MPEG1;
|
|
|
|
rd->ffcodecdata.video_bitrate = 1150;
|
|
|
|
rd->xsch = 352;
|
|
|
|
rd->ysch = isntsc ? 240 : 288;
|
|
|
|
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
|
|
|
|
rd->ffcodecdata.rc_max_rate = 1150;
|
|
|
|
rd->ffcodecdata.rc_min_rate = 1150;
|
|
|
|
rd->ffcodecdata.rc_buffer_size = 40*8;
|
|
|
|
rd->ffcodecdata.mux_packet_size = 2324;
|
|
|
|
rd->ffcodecdata.mux_rate = 2352 * 75 * 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FFMPEG_PRESET_SVCD:
|
|
|
|
rd->ffcodecdata.type = FFMPEG_MPEG2;
|
|
|
|
rd->ffcodecdata.video_bitrate = 2040;
|
|
|
|
rd->xsch = 480;
|
|
|
|
rd->ysch = isntsc ? 480 : 576;
|
|
|
|
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
|
|
|
|
rd->ffcodecdata.rc_max_rate = 2516;
|
|
|
|
rd->ffcodecdata.rc_min_rate = 0;
|
|
|
|
rd->ffcodecdata.rc_buffer_size = 224*8;
|
|
|
|
rd->ffcodecdata.mux_packet_size = 2324;
|
|
|
|
rd->ffcodecdata.mux_rate = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FFMPEG_PRESET_DVD:
|
|
|
|
rd->ffcodecdata.type = FFMPEG_MPEG2;
|
|
|
|
rd->ffcodecdata.video_bitrate = 6000;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
/* Don't set resolution, see [#21351]
|
|
|
|
* rd->xsch = 720;
|
|
|
|
* rd->ysch = isntsc ? 480 : 576; */
|
|
|
|
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
|
|
|
|
rd->ffcodecdata.rc_max_rate = 9000;
|
|
|
|
rd->ffcodecdata.rc_min_rate = 0;
|
|
|
|
rd->ffcodecdata.rc_buffer_size = 224*8;
|
|
|
|
rd->ffcodecdata.mux_packet_size = 2048;
|
|
|
|
rd->ffcodecdata.mux_rate = 10080000;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FFMPEG_PRESET_DV:
|
|
|
|
rd->ffcodecdata.type = FFMPEG_DV;
|
|
|
|
rd->xsch = 720;
|
|
|
|
rd->ysch = isntsc ? 480 : 576;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FFMPEG_PRESET_H264:
|
|
|
|
rd->ffcodecdata.type = FFMPEG_AVI;
|
|
|
|
rd->ffcodecdata.codec = CODEC_ID_H264;
|
|
|
|
rd->ffcodecdata.video_bitrate = 6000;
|
|
|
|
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
|
|
|
|
rd->ffcodecdata.rc_max_rate = 9000;
|
|
|
|
rd->ffcodecdata.rc_min_rate = 0;
|
|
|
|
rd->ffcodecdata.rc_buffer_size = 224*8;
|
|
|
|
rd->ffcodecdata.mux_packet_size = 2048;
|
|
|
|
rd->ffcodecdata.mux_rate = 10080000;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FFMPEG_PRESET_THEORA:
|
|
|
|
case FFMPEG_PRESET_XVID:
|
|
|
|
if(preset == FFMPEG_PRESET_XVID) {
|
|
|
|
rd->ffcodecdata.type = FFMPEG_AVI;
|
2011-05-26 21:57:02 +00:00
|
|
|
rd->ffcodecdata.codec = CODEC_ID_MPEG4;
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
}
|
|
|
|
else if(preset == FFMPEG_PRESET_THEORA) {
|
|
|
|
rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken
|
|
|
|
rd->ffcodecdata.codec = CODEC_ID_THEORA;
|
|
|
|
}
|
|
|
|
|
|
|
|
rd->ffcodecdata.video_bitrate = 6000;
|
|
|
|
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
|
|
|
|
rd->ffcodecdata.rc_max_rate = 9000;
|
|
|
|
rd->ffcodecdata.rc_min_rate = 0;
|
|
|
|
rd->ffcodecdata.rc_buffer_size = 224*8;
|
|
|
|
rd->ffcodecdata.mux_packet_size = 2048;
|
|
|
|
rd->ffcodecdata.mux_rate = 10080000;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2012-02-07 17:11:56 +00:00
|
|
|
|
|
|
|
ffmpeg_set_expert_options(rd);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
}
|
|
|
|
|
2011-12-23 22:07:34 +00:00
|
|
|
void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf)
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
{
|
|
|
|
int audio= 0;
|
|
|
|
|
2011-12-23 22:07:34 +00:00
|
|
|
if(imf->imtype == R_IMF_IMTYPE_FFMPEG) {
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if(rd->ffcodecdata.type <= 0 ||
|
|
|
|
rd->ffcodecdata.codec <= 0 ||
|
|
|
|
rd->ffcodecdata.audio_codec <= 0 ||
|
|
|
|
rd->ffcodecdata.video_bitrate <= 1) {
|
|
|
|
|
|
|
|
rd->ffcodecdata.codec = CODEC_ID_MPEG2VIDEO;
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD);
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
}
|
2011-08-10 07:36:44 +00:00
|
|
|
if(rd->ffcodecdata.type == FFMPEG_OGG) {
|
|
|
|
rd->ffcodecdata.type = FFMPEG_MPEG2;
|
|
|
|
}
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
|
|
|
|
audio= 1;
|
|
|
|
}
|
2011-12-23 22:07:34 +00:00
|
|
|
else if(imf->imtype == R_IMF_IMTYPE_H264) {
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if(rd->ffcodecdata.codec != CODEC_ID_H264) {
|
|
|
|
ffmpeg_set_preset(rd, FFMPEG_PRESET_H264);
|
|
|
|
audio= 1;
|
|
|
|
}
|
|
|
|
}
|
2011-12-23 22:07:34 +00:00
|
|
|
else if(imf->imtype == R_IMF_IMTYPE_XVID) {
|
2011-05-26 21:57:02 +00:00
|
|
|
if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
|
|
|
|
audio= 1;
|
|
|
|
}
|
|
|
|
}
|
2011-12-23 22:07:34 +00:00
|
|
|
else if(imf->imtype == R_IMF_IMTYPE_THEORA) {
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
if(rd->ffcodecdata.codec != CODEC_ID_THEORA) {
|
|
|
|
ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA);
|
|
|
|
audio= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-07 23:41:17 +00:00
|
|
|
if(audio && rd->ffcodecdata.audio_codec < 0) {
|
|
|
|
rd->ffcodecdata.audio_codec = CODEC_ID_NONE;
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
rd->ffcodecdata.audio_bitrate = 128;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-07 17:11:56 +00:00
|
|
|
void ffmpeg_verify_codec_settings(RenderData *rd)
|
2012-01-13 12:34:23 +00:00
|
|
|
{
|
2012-02-07 17:11:56 +00:00
|
|
|
ffmpeg_set_expert_options(rd);
|
2012-01-13 12:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-02-24 09:49:44 +00:00
|
|
|
int ffmpeg_alpha_channel_supported(RenderData *rd)
|
|
|
|
{
|
|
|
|
int codec = rd->ffcodecdata.codec;
|
|
|
|
|
2012-02-24 15:34:57 +00:00
|
|
|
if (codec == CODEC_ID_QTRLE)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
#ifdef FFMPEG_FFV1_ALPHA_SUPPORTED
|
|
|
|
if (codec == CODEC_ID_FFV1)
|
|
|
|
return TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return FALSE;
|
2012-02-24 09:49:44 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 19:14:46 +00:00
|
|
|
#endif
|