20 # ifdef WITH_AUDASPACE
21 # include <AUD_Device.h>
22 # include <AUD_Special.h>
43 # include <libavcodec/avcodec.h>
44 # include <libavformat/avformat.h>
45 # include <libavutil/channel_layout.h>
46 # include <libavutil/imgutils.h>
47 # include <libavutil/opt.h>
48 # include <libavutil/rational.h>
49 # include <libavutil/samplefmt.h>
50 # include <libswscale/swscale.h>
56 typedef struct FFMpegContext {
59 int ffmpeg_audio_codec;
60 int ffmpeg_video_bitrate;
61 int ffmpeg_audio_bitrate;
63 int ffmpeg_max_b_frames;
65 int ffmpeg_autosplit_count;
71 AVFormatContext *outfile;
72 AVCodecContext *video_codec;
73 AVCodecContext *audio_codec;
74 AVStream *video_stream;
75 AVStream *audio_stream;
76 AVFrame *current_frame;
80 AVFrame *img_convert_frame;
81 struct SwsContext *img_convert_ctx;
84 uint8_t *audio_deinterleave_buffer;
85 int audio_input_samples;
87 double audio_time_total;
88 bool audio_deinterleave;
89 int audio_sample_size;
93 # ifdef WITH_AUDASPACE
94 AUD_Device *audio_mixdown_device;
98 # define FFMPEG_AUTOSPLIT_SIZE 2000000000
101 if (G.debug & G_DEBUG_FFMPEG) \
104 static void ffmpeg_dict_set_int(AVDictionary **dict,
const char *key,
int value);
105 static void ffmpeg_filepath_get(FFMpegContext *
context,
113 static void delete_picture(AVFrame *f)
123 static int request_float_audio_buffer(
int codec_id)
126 return codec_id == AV_CODEC_ID_AAC || codec_id == AV_CODEC_ID_AC3 ||
127 codec_id == AV_CODEC_ID_VORBIS;
130 # ifdef WITH_AUDASPACE
132 static int write_audio_frame(FFMpegContext *
context)
135 AVCodecContext *
c =
context->audio_codec;
140 frame = av_frame_alloc();
143 frame->format =
c->sample_fmt;
144 # ifdef FFMPEG_USE_OLD_CHANNEL_VARS
145 frame->channels =
c->channels;
146 frame->channel_layout =
c->channel_layout;
147 const int num_channels =
c->channels;
149 av_channel_layout_copy(&
frame->ch_layout, &
c->ch_layout);
150 const int num_channels =
c->ch_layout.nb_channels;
153 if (
context->audio_deinterleave) {
157 for (channel = 0; channel < num_channels; channel++) {
158 for (i = 0; i <
frame->nb_samples; i++) {
159 memcpy(
context->audio_deinterleave_buffer +
160 (i + channel *
frame->nb_samples) *
context->audio_sample_size,
162 (num_channels * i + channel) *
context->audio_sample_size,
167 temp =
context->audio_deinterleave_buffer;
169 context->audio_input_buffer = temp;
172 avcodec_fill_audio_frame(
frame,
176 context->audio_input_samples * num_channels *
185 fprintf(stderr,
"Can't send audio frame: %s\n", av_err2str(
ret));
189 AVPacket *pkt = av_packet_alloc();
193 ret = avcodec_receive_packet(
c, pkt);
194 if (
ret == AVERROR(EAGAIN) ||
ret == AVERROR_EOF) {
198 fprintf(stderr,
"Error encoding audio frame: %s\n", av_err2str(
ret));
202 pkt->stream_index =
context->audio_stream->index;
203 av_packet_rescale_ts(pkt,
c->time_base,
context->audio_stream->time_base);
204 # ifdef FFMPEG_USE_DURATION_WORKAROUND
208 pkt->flags |= AV_PKT_FLAG_KEY;
210 int write_ret = av_interleaved_write_frame(
context->outfile, pkt);
211 if (write_ret != 0) {
212 fprintf(stderr,
"Error writing audio packet: %s\n", av_err2str(write_ret));
218 av_packet_free(&pkt);
219 av_frame_free(&
frame);
226 static AVFrame *alloc_picture(
int pix_fmt,
int width,
int height)
233 f = av_frame_alloc();
245 av_image_fill_arrays(f->data, f->linesize, buf, pix_fmt,
width,
height, 1);
255 static const char **get_file_extensions(
int format)
259 static const char *rv[] = {
".dv",
NULL};
263 static const char *rv[] = {
".mpg",
".mpeg",
NULL};
267 static const char *rv[] = {
".dvd",
".vob",
".mpg",
".mpeg",
NULL};
271 static const char *rv[] = {
".mp4",
".mpg",
".mpeg",
NULL};
275 static const char *rv[] = {
".avi",
NULL};
279 static const char *rv[] = {
".mov",
NULL};
284 static const char *rv[] = {
".avi",
NULL};
290 static const char *rv[] = {
".avi",
NULL};
294 static const char *rv[] = {
".flv",
NULL};
298 static const char *rv[] = {
".mkv",
NULL};
302 static const char *rv[] = {
".ogv",
".ogg",
NULL};
306 static const char *rv[] = {
".webm",
NULL};
317 int ret, success = 1;
318 AVPacket *packet = av_packet_alloc();
320 AVCodecContext *
c =
context->video_codec;
328 fprintf(stderr,
"Can't send video frame: %s\n", av_err2str(
ret));
333 ret = avcodec_receive_packet(
c, packet);
335 if (
ret == AVERROR(EAGAIN) ||
ret == AVERROR_EOF) {
340 fprintf(stderr,
"Error encoding frame: %s\n", av_err2str(
ret));
344 packet->stream_index =
context->video_stream->index;
345 av_packet_rescale_ts(packet,
c->time_base,
context->video_stream->time_base);
346 # ifdef FFMPEG_USE_DURATION_WORKAROUND
350 if (av_interleaved_write_frame(
context->outfile, packet) != 0) {
358 PRINT(
"Error writing frame: %s\n", av_err2str(
ret));
361 av_packet_free(&packet);
367 static AVFrame *generate_video_frame(FFMpegContext *
context,
const uint8_t *pixels)
369 AVCodecParameters *codec =
context->video_stream->codecpar;
370 int height = codec->height;
375 rgb_frame =
context->img_convert_frame;
379 rgb_frame =
context->current_frame;
384 int linesize = rgb_frame->linesize[0];
386 uint8_t *target = rgb_frame->data[0] + linesize * (
height -
y - 1);
389 # if ENDIAN_ORDER == L_ENDIAN
390 memcpy(target,
src, linesize);
392 # elif ENDIAN_ORDER == B_ENDIAN
404 # error ENDIAN_ORDER should either be L_ENDIAN or B_ENDIAN.
411 sws_scale(
context->img_convert_ctx,
412 (
const uint8_t *
const *)rgb_frame->data,
417 context->current_frame->linesize);
423 static AVRational calc_time_base(
uint den,
double num,
int codec_id)
430 float eps = FLT_EPSILON;
431 const uint DENUM_MAX = (codec_id == AV_CODEC_ID_MPEG4) ? (1UL << 16) - 1 : (1UL << 31) - 1;
442 eps = (
float)(1 << num_integer_bits) * FLT_EPSILON;
446 const int max_num_shift =
fabsf(log10f(
eps));
448 const int max_den_shift = log10f(DENUM_MAX) - log10f(den);
449 const int max_iter =
min_ii(max_num_shift, max_den_shift);
451 for (
int i = 0; i < max_iter &&
fabs(num - round(num)) >
eps; i++) {
458 AVRational time_base;
460 time_base.num = (int)num;
467 static AVStream *alloc_video_stream(FFMpegContext *
context,
477 const AVCodec *codec;
478 AVDictionary *opts =
NULL;
482 st = avformat_new_stream(of,
NULL);
490 codec = avcodec_find_encoder(codec_id);
492 fprintf(stderr,
"Couldn't find valid video codec\n");
497 context->video_codec = avcodec_alloc_context3(codec);
498 AVCodecContext *
c =
context->video_codec;
507 c->time_base.den = 2997;
508 c->time_base.num = 100;
524 if (
c->time_base.num != 1) {
525 AVRational new_time_base;
527 &new_time_base.num, &new_time_base.den,
c->time_base.num,
c->time_base.den, INT_MAX)) {
529 c->time_base = new_time_base;
533 st->time_base =
c->time_base;
535 c->gop_size =
context->ffmpeg_gop_size;
536 c->max_b_frames =
context->ffmpeg_max_b_frames;
538 if (
context->ffmpeg_type == FFMPEG_WEBM &&
context->ffmpeg_crf == 0) {
539 ffmpeg_dict_set_int(&opts,
"lossless", 1);
541 else if (
context->ffmpeg_crf >= 0) {
547 ffmpeg_dict_set_int(&opts,
"crf",
context->ffmpeg_crf);
550 c->bit_rate =
context->ffmpeg_video_bitrate * 1000;
560 char const *preset_name =
NULL;
561 char const *deadline_name =
NULL;
562 switch (
context->ffmpeg_preset) {
564 preset_name =
"medium";
565 deadline_name =
"good";
568 preset_name =
"slower";
569 deadline_name =
"best";
572 preset_name =
"superfast";
573 deadline_name =
"realtime";
576 printf(
"Unknown preset number %i, ignoring.\n",
context->ffmpeg_preset);
578 if (preset_name !=
NULL) {
579 av_dict_set(&opts,
"preset", preset_name, 0);
581 if (deadline_name !=
NULL) {
582 av_dict_set(&opts,
"deadline", deadline_name, 0);
588 if (codec->pix_fmts) {
589 c->pix_fmt = codec->pix_fmts[0];
593 c->pix_fmt = AV_PIX_FMT_YUV422P;
596 if (
context->ffmpeg_type == FFMPEG_XVID) {
598 c->pix_fmt = AV_PIX_FMT_YUV420P;
599 c->codec_tag = ((
'D' << 24) + (
'I' << 16) + (
'V' << 8) +
'X');
603 if (codec_id == AV_CODEC_ID_HUFFYUV) {
605 c->pix_fmt = AV_PIX_FMT_BGRA;
608 c->pix_fmt = AV_PIX_FMT_RGB32;
612 if (codec_id == AV_CODEC_ID_DNXHD) {
619 if (codec_id == AV_CODEC_ID_FFV1) {
620 c->pix_fmt = AV_PIX_FMT_RGB32;
623 if (codec_id == AV_CODEC_ID_QTRLE) {
625 c->pix_fmt = AV_PIX_FMT_ARGB;
630 c->pix_fmt = AV_PIX_FMT_YUVA420P;
632 else if (
ELEM(codec_id, AV_CODEC_ID_H264, AV_CODEC_ID_VP9) && (
context->ffmpeg_crf == 0)) {
634 c->pix_fmt = AV_PIX_FMT_YUV444P;
637 if (codec_id == AV_CODEC_ID_PNG) {
639 c->pix_fmt = AV_PIX_FMT_RGBA;
643 if (of->oformat->flags & AVFMT_GLOBALHEADER) {
644 PRINT(
"Using global header\n");
645 c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
650 st->sample_aspect_ratio =
c->sample_aspect_ratio = av_d2q(((
double)rd->
xasp / (
double)rd->
yasp),
652 st->avg_frame_rate = av_inv_q(
c->time_base);
654 if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
661 if (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) {
662 c->thread_type = FF_THREAD_FRAME;
664 else if (codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) {
665 c->thread_type = FF_THREAD_SLICE;
668 int ret = avcodec_open2(
c, codec, &opts);
671 fprintf(stderr,
"Couldn't initialize video codec: %s\n", av_err2str(
ret));
674 avcodec_free_context(&
c);
681 context->current_frame = alloc_picture(
c->pix_fmt,
c->width,
c->height);
683 if (
c->pix_fmt == AV_PIX_FMT_RGBA) {
690 context->img_convert_frame = alloc_picture(AV_PIX_FMT_RGBA,
c->width,
c->height);
691 context->img_convert_ctx = sws_getContext(
c->width,
703 avcodec_parameters_from_context(
st->codecpar,
c);
710 static AVStream *alloc_audio_stream(FFMpegContext *
context,
718 const AVCodec *codec;
722 st = avformat_new_stream(of,
NULL);
728 codec = avcodec_find_encoder(codec_id);
730 fprintf(stderr,
"Couldn't find valid audio codec\n");
735 context->audio_codec = avcodec_alloc_context3(codec);
736 AVCodecContext *
c =
context->audio_codec;
738 c->thread_type = FF_THREAD_SLICE;
741 c->bit_rate =
context->ffmpeg_audio_bitrate * 1000;
742 c->sample_fmt = AV_SAMPLE_FMT_S16;
745 int channel_layout_mask = 0;
748 channel_layout_mask = AV_CH_LAYOUT_MONO;
751 channel_layout_mask = AV_CH_LAYOUT_STEREO;
754 channel_layout_mask = AV_CH_LAYOUT_QUAD;
757 channel_layout_mask = AV_CH_LAYOUT_5POINT1_BACK;
760 channel_layout_mask = AV_CH_LAYOUT_7POINT1;
765 # ifdef FFMPEG_USE_OLD_CHANNEL_VARS
766 c->channels = num_channels;
767 c->channel_layout = channel_layout_mask;
769 av_channel_layout_from_mask(&
c->ch_layout, channel_layout_mask);
772 if (request_float_audio_buffer(codec_id)) {
774 c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
775 c->sample_fmt = AV_SAMPLE_FMT_FLT;
778 if (codec->sample_fmts) {
784 const enum AVSampleFormat *p = codec->sample_fmts;
785 for (; *p != -1; p++) {
786 if (*p ==
c->sample_fmt) {
792 c->sample_fmt = codec->sample_fmts[0];
796 if (codec->supported_samplerates) {
797 const int *p = codec->supported_samplerates;
799 int best_dist = INT_MAX;
801 int dist =
abs(
c->sample_rate - *p);
802 if (dist < best_dist) {
808 c->sample_rate = best;
811 if (of->oformat->flags & AVFMT_GLOBALHEADER) {
812 c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
815 int ret = avcodec_open2(
c, codec,
NULL);
818 fprintf(stderr,
"Couldn't initialize audio codec: %s\n", av_err2str(
ret));
820 avcodec_free_context(&
c);
827 c->time_base.num = 1;
828 c->time_base.den =
c->sample_rate;
830 if (
c->frame_size == 0) {
834 context->audio_input_samples = AV_INPUT_BUFFER_MIN_SIZE * 8 /
c->bits_per_coded_sample /
838 context->audio_input_samples =
c->frame_size;
841 context->audio_deinterleave = av_sample_fmt_is_planar(
c->sample_fmt);
843 context->audio_sample_size = av_get_bytes_per_sample(
c->sample_fmt);
847 if (
context->audio_deinterleave) {
849 context->audio_input_samples * num_channels *
context->audio_sample_size);
854 avcodec_parameters_from_context(
st->codecpar,
c);
860 static void ffmpeg_dict_set_int(AVDictionary **dict,
const char *key,
int value)
866 av_dict_set(dict, key,
buffer, 0);
869 static void ffmpeg_add_metadata_callback(
void *
data,
870 const char *propname,
874 AVDictionary **metadata = (AVDictionary **)
data;
875 av_dict_set(metadata, propname, propvalue, 0);
878 static int start_ffmpeg_impl(FFMpegContext *
context,
887 const AVOutputFormat *fmt;
906 ffmpeg_filepath_get(
context, name, rd,
context->ffmpeg_preview, suffix);
908 "Starting output to %s(ffmpeg)...\n"
909 " Using type=%d, codec=%d, audio_codec=%d,\n"
910 " video_bitrate=%d, audio_bitrate=%d,\n"
911 " gop_size=%d, autosplit=%d\n"
912 " render width=%d, render height=%d\n",
925 exts = get_file_extensions(
context->ffmpeg_type);
931 fmt = av_guess_format(
NULL, exts[0],
NULL);
937 of = avformat_alloc_context();
943 enum AVCodecID audio_codec =
context->ffmpeg_audio_codec;
944 enum AVCodecID video_codec =
context->ffmpeg_codec;
946 of->url = av_strdup(name);
948 switch (
context->ffmpeg_type) {
950 video_codec = AV_CODEC_ID_THEORA;
953 video_codec = AV_CODEC_ID_DVVIDEO;
956 video_codec = AV_CODEC_ID_MPEG1VIDEO;
959 video_codec = AV_CODEC_ID_MPEG2VIDEO;
962 video_codec = AV_CODEC_ID_H264;
965 video_codec = AV_CODEC_ID_MPEG4;
968 video_codec = AV_CODEC_ID_FLV1;
974 video_codec =
context->ffmpeg_codec;
980 # if LIBAVFORMAT_VERSION_MAJOR >= 59
984 of->oformat = (AVOutputFormat *)fmt;
987 if (video_codec == AV_CODEC_ID_DVVIDEO) {
992 if (rd->
frs_sec != 25 && recty != 480) {
996 if (rd->
frs_sec == 25 && recty != 576) {
1002 if (
context->ffmpeg_type == FFMPEG_DV) {
1003 audio_codec = AV_CODEC_ID_PCM_S16LE;
1004 if (
context->ffmpeg_audio_codec != AV_CODEC_ID_NONE &&
1011 if (video_codec != AV_CODEC_ID_NONE) {
1012 context->video_stream = alloc_video_stream(
1014 PRINT(
"alloc video stream %p\n",
context->video_stream);
1022 PRINT(
"Error initializing video stream");
1028 if (
context->ffmpeg_audio_codec != AV_CODEC_ID_NONE) {
1037 PRINT(
"Error initializing audio stream");
1042 if (!(fmt->flags & AVFMT_NOFILE)) {
1043 if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
1045 PRINT(
"Could not open file for writing\n");
1052 &of->metadata,
context->stamp_data, ffmpeg_add_metadata_callback,
false);
1055 int ret = avformat_write_header(of,
NULL);
1059 "Could not initialize streams, probably unsupported codec combination");
1060 PRINT(
"Could not write media header: %s\n", av_err2str(
ret));
1065 av_dump_format(of, 0, name, 1);
1082 avformat_free_context(of);
1103 static void flush_ffmpeg(AVCodecContext *
c, AVStream *stream, AVFormatContext *outfile)
1105 AVPacket *packet = av_packet_alloc();
1107 avcodec_send_frame(
c,
NULL);
1112 ret = avcodec_receive_packet(
c, packet);
1114 if (
ret == AVERROR(EAGAIN) ||
ret == AVERROR_EOF) {
1119 fprintf(stderr,
"Error encoding delayed frame: %s\n", av_err2str(
ret));
1123 packet->stream_index = stream->index;
1124 av_packet_rescale_ts(packet,
c->time_base, stream->time_base);
1125 # ifdef FFMPEG_USE_DURATION_WORKAROUND
1129 int write_ret = av_interleaved_write_frame(outfile, packet);
1130 if (write_ret != 0) {
1131 fprintf(stderr,
"Error writing delayed frame: %s\n", av_err2str(write_ret));
1136 av_packet_free(&packet);
1144 static void ffmpeg_filepath_get(
1150 const char **fe = exts;
1153 if (!
string || !exts) {
1166 strcpy(
string, rd->
pic);
1171 autosplit[0] =
'\0';
1175 sprintf(autosplit,
"_%03d",
context->ffmpeg_autosplit_count);
1181 if (
BLI_strcasecmp(
string + strlen(
string) - strlen(*fe), *fe) == 0) {
1188 strcat(
string, autosplit);
1191 strcat(
string, *exts);
1194 *(
string + strlen(
string) - strlen(*fe)) =
'\0';
1195 strcat(
string, autosplit);
1196 strcat(
string, *fe);
1204 strcat(
string, autosplit);
1210 void BKE_ffmpeg_filepath_get(
char *
string,
const RenderData *rd,
bool preview,
const char *suffix)
1212 ffmpeg_filepath_get(
NULL,
string, rd,
preview, suffix);
1215 int BKE_ffmpeg_start(
void *context_v,
1225 FFMpegContext *
context = context_v;
1227 context->ffmpeg_autosplit_count = 0;
1231 success = start_ffmpeg_impl(
context, rd, rectx, recty, suffix, reports);
1232 # ifdef WITH_AUDASPACE
1234 AVCodecContext *
c =
context->audio_codec;
1236 AUD_DeviceSpecs specs;
1237 # ifdef FFMPEG_USE_OLD_CHANNEL_VARS
1238 specs.channels =
c->channels;
1240 specs.channels =
c->ch_layout.nb_channels;
1243 switch (av_get_packed_sample_fmt(
c->sample_fmt)) {
1244 case AV_SAMPLE_FMT_U8:
1245 specs.format = AUD_FORMAT_U8;
1247 case AV_SAMPLE_FMT_S16:
1248 specs.format = AUD_FORMAT_S16;
1250 case AV_SAMPLE_FMT_S32:
1251 specs.format = AUD_FORMAT_S32;
1253 case AV_SAMPLE_FMT_FLT:
1254 specs.format = AUD_FORMAT_FLOAT32;
1256 case AV_SAMPLE_FMT_DBL:
1257 specs.format = AUD_FORMAT_FLOAT64;
1264 context->audio_mixdown_device = BKE_sound_mixdown(
1271 static void end_ffmpeg_impl(FFMpegContext *
context,
int is_autosplit);
1273 # ifdef WITH_AUDASPACE
1274 static void write_audio_frames(FFMpegContext *
context,
double to_pts)
1276 AVCodecContext *
c =
context->audio_codec;
1278 while (
context->audio_stream) {
1279 if ((
context->audio_time_total >= to_pts) || !write_audio_frame(
context)) {
1288 int BKE_ffmpeg_append(
void *context_v,
1298 FFMpegContext *
context = context_v;
1302 PRINT(
"Writing frame %i, render width=%d, render height=%d\n",
frame, rectx, recty);
1305 avframe = generate_video_frame(
context, (
unsigned char *)pixels);
1306 success = (avframe && write_video_frame(
context, avframe, reports));
1307 # ifdef WITH_AUDASPACE
1315 if (
context->ffmpeg_autosplit) {
1316 if (avio_tell(
context->outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) {
1317 end_ffmpeg_impl(
context,
true);
1318 context->ffmpeg_autosplit_count++;
1320 success &= start_ffmpeg_impl(
context, rd, rectx, recty, suffix, reports);
1328 static void end_ffmpeg_impl(FFMpegContext *
context,
int is_autosplit)
1330 PRINT(
"Closing ffmpeg...\n");
1332 # ifdef WITH_AUDASPACE
1333 if (is_autosplit ==
false) {
1334 if (
context->audio_mixdown_device) {
1335 AUD_Device_free(
context->audio_mixdown_device);
1344 PRINT(
"Flushing delayed video frames...\n");
1349 PRINT(
"Flushing delayed audio frames...\n");
1354 av_write_trailer(
context->outfile);
1360 PRINT(
"zero video stream %p\n",
context->video_stream);
1370 delete_picture(
context->current_frame);
1374 delete_picture(
context->img_convert_frame);
1379 if (!(
context->outfile->oformat->flags & AVFMT_NOFILE)) {
1380 avio_close(
context->outfile->pb);
1385 avcodec_free_context(&
context->video_codec);
1389 avcodec_free_context(&
context->audio_codec);
1394 avformat_free_context(
context->outfile);
1398 av_free(
context->audio_input_buffer);
1403 av_free(
context->audio_deinterleave_buffer);
1408 sws_freeContext(
context->img_convert_ctx);
1413 void BKE_ffmpeg_end(
void *context_v)
1415 FFMpegContext *
context = context_v;
1416 end_ffmpeg_impl(
context,
false);
1419 void BKE_ffmpeg_preset_set(
RenderData *rd,
int preset)
1421 bool is_ntsc = (rd->
frs_sec != 25);
1424 case FFMPEG_PRESET_VCD:
1428 rd->
ysch = is_ntsc ? 240 : 288;
1437 case FFMPEG_PRESET_SVCD:
1441 rd->
ysch = is_ntsc ? 480 : 576;
1450 case FFMPEG_PRESET_DVD:
1456 rd->
ysch = isntsc ? 480 : 576;
1467 case FFMPEG_PRESET_DV:
1470 rd->
ysch = is_ntsc ? 480 : 576;
1473 case FFMPEG_PRESET_H264:
1486 case FFMPEG_PRESET_THEORA:
1487 case FFMPEG_PRESET_XVID:
1488 if (preset == FFMPEG_PRESET_XVID) {
1492 else if (preset == FFMPEG_PRESET_THEORA) {
1515 BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264);
1528 BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264);
1534 BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_XVID);
1540 BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_THEORA);
1551 bool BKE_ffmpeg_alpha_channel_is_supported(
const RenderData *rd)
1560 AV_CODEC_ID_HUFFYUV);
1563 void *BKE_ffmpeg_context_create(
void)
1570 context->ffmpeg_codec = AV_CODEC_ID_MPEG4;
1571 context->ffmpeg_audio_codec = AV_CODEC_ID_NONE;
1572 context->ffmpeg_video_bitrate = 1150;
1573 context->ffmpeg_audio_bitrate = 128;
1574 context->ffmpeg_gop_size = 12;
1575 context->ffmpeg_autosplit = 0;
1576 context->ffmpeg_autosplit_count = 0;
1577 context->ffmpeg_preview =
false;
1579 context->audio_time_total = 0.0;
1584 void BKE_ffmpeg_context_free(
void *context_v)
1586 FFMpegContext *
context = context_v;
typedef float(TangentPoint)[2]
struct StampData * BKE_stamp_info_from_scene_static(const struct Scene *scene)
void BKE_stamp_info_callback(void *data, struct StampData *stamp_data, StampCallback callback, bool noskip)
const char * BKE_main_blendfile_path_from_global(void)
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BLI_kdtree_nd_() free(KDTree *tree)
MINLINE int min_ii(int a, int b)
MINLINE unsigned int log2_floor_u(unsigned int x)
bool BLI_make_existing_file(const char *name)
bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL()
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char *sep) ATTR_NONNULL()
int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
int BLI_system_thread_count(void)
typedef double(DMatrix)[4][4]
#define R_IMF_IMTYPE_FFMPEG
#define R_IMF_IMTYPE_H264
#define R_IMF_IMTYPE_THEORA
@ FFMPEG_AUTOSPLIT_OUTPUT
@ FFMPEG_USE_MAX_B_FRAMES
#define R_IMF_IMTYPE_XVID
#define R_IMF_PLANES_RGBA
@ FFM_CHANNELS_SURROUND51
@ FFM_CHANNELS_SURROUND71
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
const char * IMB_ffmpeg_last_error(void)
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SyclQueue void void * src
FFMPEG_INLINE void my_guess_pkt_duration(AVFormatContext *s, AVStream *st, AVPacket *pkt)
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
ccl_device_inline float2 fabs(const float2 &a)
static void error(const char *str)
#define PRINT(format,...)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
static const pxr::TfToken preview("preview", pxr::TfToken::Immortal)
struct ImageFormatData im_format
struct FFMpegCodecData ffcodecdata