Blender V4.5
movie_write.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#ifdef WITH_FFMPEG
12
13# include <cstdint>
14/* Note: include cmath before ffmpeg headers, since both of them define
15 * M_PI and other macros. This is to avoid warnings about macro redefinition
16 * if later including cmath (MSVC 2019). */
17# if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
18# define _USE_MATH_DEFINES
19# endif
20# include <cmath> // IWYU pragma: keep
21
22extern "C" {
23# include <libavcodec/codec_id.h>
24# include <libavformat/avformat.h>
25# include <libavutil/buffer.h>
26# include <libavutil/channel_layout.h>
27# include <libavutil/imgutils.h>
28# include <libavutil/opt.h>
29# include <libavutil/rational.h>
30# include <libavutil/samplefmt.h>
31
32# include "ffmpeg_compat.h"
33}
34
35# ifdef WITH_AUDASPACE
36# include <AUD_Types.h>
37# endif
38
39struct Scene;
40struct ReportList;
41struct StampData;
42
43struct MovieWriter {
44 int ffmpeg_type = 0;
45 AVCodecID ffmpeg_codec = {};
46 AVCodecID ffmpeg_audio_codec = {};
47 int ffmpeg_video_bitrate = 0;
48 int ffmpeg_audio_bitrate = 0;
49 int ffmpeg_gop_size = 0;
50 int ffmpeg_max_b_frames = 0;
51 int ffmpeg_autosplit_count = 0;
52 bool ffmpeg_autosplit = false;
53 bool ffmpeg_preview = false;
54
55 int ffmpeg_crf = 0; /* set to 0 to not use CRF mode; we have another flag for lossless anyway. */
56 int ffmpeg_preset = 0; /* see eFFMpegPreset */
57 int ffmpeg_profile = 0;
58
59 AVFormatContext *outfile = nullptr;
60 AVCodecContext *video_codec = nullptr;
61 AVCodecContext *audio_codec = nullptr;
62 AVStream *video_stream = nullptr;
63 AVStream *audio_stream = nullptr;
64 AVFrame *current_frame = nullptr; /* Image frame in output pixel format. */
65 int video_time = 0;
66
67 /* Image frame in Blender's own pixel format, may need conversion to the output pixel format. */
68 AVFrame *img_convert_frame = nullptr;
69 SwsContext *img_convert_ctx = nullptr;
70
71 uint8_t *audio_input_buffer = nullptr;
72 uint8_t *audio_deinterleave_buffer = nullptr;
73 int audio_input_samples = 0;
74 double audio_time = 0.0;
75 double audio_time_total = 0.0;
76 bool audio_deinterleave = false;
77 int audio_sample_size = 0;
78
79 StampData *stamp_data = nullptr;
80
81# ifdef WITH_AUDASPACE
82 AUD_Device *audio_mixdown_device = nullptr;
83# endif
84};
85
86bool movie_audio_open(MovieWriter *context,
87 const Scene *scene,
88 int start_frame,
89 int mixrate,
90 float volume,
92void movie_audio_close(MovieWriter *context, bool is_autosplit);
93
94AVStream *alloc_audio_stream(MovieWriter *context,
95 int audio_mixrate,
96 int audio_channels,
97 AVCodecID codec_id,
98 AVFormatContext *of,
99 char *error,
100 int error_size);
101void write_audio_frames(MovieWriter *context, double to_pts);
102
103#endif /* WITH_FFMPEG */
ReportList * reports
Definition WM_types.hh:1025
static void error(const char *str)