Blender V5.3
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/mastering_display_metadata.h>
29# include <libavutil/opt.h>
30# include <libavutil/rational.h>
31# include <libavutil/samplefmt.h>
32# include <libavutil/spherical.h>
33# include <libavutil/stereo3d.h>
34
35# include "ffmpeg_compat.h"
36}
37
38# ifdef WITH_AUDASPACE
39# include "BKE_sound_types.hh"
40# endif
41
42namespace blender {
43
44struct Scene;
45struct ReportList;
46struct StampData;
47
48struct MovieWriter {
49 int ffmpeg_type = 0;
50 AVCodecID ffmpeg_codec = {};
51 AVCodecID ffmpeg_audio_codec = {};
52 int ffmpeg_video_bitrate = 0;
53 int ffmpeg_audio_bitrate = 0;
54 int ffmpeg_gop_size = 0;
55 int ffmpeg_max_b_frames = 0;
56 int ffmpeg_autosplit_count = 0;
57 bool ffmpeg_autosplit = false;
58 bool ffmpeg_preview = false;
59
60 int ffmpeg_crf = 0; /* set to 0 to not use CRF mode; we have another flag for lossless anyway. */
61 bool custom_crf = false;
62 int ffmpeg_preset = 0; /* see eFFMpegPreset */
63 int ffmpeg_profile = 0;
64
65 AVFormatContext *outfile = nullptr;
66 AVCodecContext *video_codec = nullptr;
67 AVCodecContext *audio_codec = nullptr;
68 AVStream *video_stream = nullptr;
69 AVStream *audio_stream = nullptr;
70 AVFrame *current_frame = nullptr; /* Image frame in output pixel format. */
71 int video_time = 0;
72
73 /* Image frame in Blender's own pixel format, may need conversion to the output pixel format. */
74 AVFrame *img_convert_frame = nullptr;
75 SwsContext *sws_ctx = nullptr;
76
77 uint8_t *audio_input_buffer = nullptr;
78 uint8_t *audio_deinterleave_buffer = nullptr;
79 int audio_input_samples = 0;
80 double audio_time = 0.0;
81 double audio_time_total = 0.0;
82 bool audio_deinterleave = false;
83 int audio_sample_size = 0;
84
85 StampData *stamp_data = nullptr;
86
87# ifdef WITH_AUDASPACE
88 AUD_Device audio_mixdown_device;
89# endif
90};
91
92bool movie_audio_open(MovieWriter *context,
93 const Scene *scene,
94 int start_frame,
95 int mixrate,
96 float volume,
97 ReportList *reports);
98void movie_audio_close(MovieWriter *context, bool is_autosplit);
99
100AVStream *alloc_audio_stream(MovieWriter *context,
101 int audio_mixrate,
102 int audio_channels,
103 AVCodecID codec_id,
104 AVFormatContext *of,
105 char *error,
106 int error_maxncpy,
107 ReportList *reports);
108void write_audio_frames(MovieWriter *context, double to_pts);
109
110} // namespace blender
111
112#endif /* WITH_FFMPEG */
std::shared_ptr< void > AUD_Device
BMesh Iterators.
unsigned char uint8_t
Definition BKE_text.h:79