Mbonea commited on
Commit
b2fa231
1 Parent(s): 345a783

Faster renders?

Browse files
Remotion-app/src/HelloWorld/AudioStream.jsx CHANGED
@@ -1,10 +1,24 @@
1
  import {Series} from 'remotion';
2
- import React from 'react';
3
  import {staticFile, useVideoConfig, Audio} from 'remotion';
4
  import audioSequences from './Assets/AudioSequences.json';
5
  import {TransitionSeries} from '@remotion/transitions';
 
6
  const AudioStream = React.memo(() => {
7
  const {fps} = useVideoConfig();
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  return (
9
  <TransitionSeries
10
  style={{
@@ -13,31 +27,13 @@ const AudioStream = React.memo(() => {
13
  zIndex: 0,
14
  }}
15
  >
16
- {audioSequences.map((entry, index) => {
17
- return (
18
- <TransitionSeries.Sequence
19
- key={index}
20
- from={fps * entry.start}
21
- durationInFrames={fps * (entry.end - entry.start)}
22
- >
23
- <AudioX entry={entry} />
24
- </TransitionSeries.Sequence>
25
- );
26
- })}
27
  </TransitionSeries>
28
  );
29
  });
30
 
31
  const AudioX = React.memo(({entry}) => {
32
- return (
33
- <Audio
34
- {...entry.props}
35
- // startFrom={entry.props.startFrom}
36
- // endAt={entry.props.endAt}
37
- // volume={entry.props.volume}
38
- src={staticFile(entry.name)}
39
- />
40
- );
41
  });
42
 
43
  export default AudioStream;
 
1
  import {Series} from 'remotion';
2
+ import React, {useMemo} from 'react';
3
  import {staticFile, useVideoConfig, Audio} from 'remotion';
4
  import audioSequences from './Assets/AudioSequences.json';
5
  import {TransitionSeries} from '@remotion/transitions';
6
+
7
  const AudioStream = React.memo(() => {
8
  const {fps} = useVideoConfig();
9
+
10
+ const audioComponents = useMemo(() => {
11
+ return audioSequences.map((entry, index) => (
12
+ <TransitionSeries.Sequence
13
+ key={index}
14
+ from={fps * entry.start}
15
+ durationInFrames={fps * (entry.end - entry.start)}
16
+ >
17
+ <AudioX entry={entry} />
18
+ </TransitionSeries.Sequence>
19
+ ));
20
+ }, [fps]);
21
+
22
  return (
23
  <TransitionSeries
24
  style={{
 
27
  zIndex: 0,
28
  }}
29
  >
30
+ {audioComponents}
 
 
 
 
 
 
 
 
 
 
31
  </TransitionSeries>
32
  );
33
  });
34
 
35
  const AudioX = React.memo(({entry}) => {
36
+ return <Audio {...entry.props} src={staticFile(entry.name)} />;
 
 
 
 
 
 
 
 
37
  });
38
 
39
  export default AudioStream;
Remotion-app/src/HelloWorld/ImageStream.jsx CHANGED
@@ -1,21 +1,30 @@
1
  import {AbsoluteFill} from 'remotion';
2
-
3
  import React, {useMemo} from 'react';
4
  import {
5
  staticFile,
6
  useVideoConfig,
7
  Img,
8
  Easing,
9
- Audio,
10
  useCurrentFrame,
11
  interpolate,
12
  } from 'remotion';
13
  import imageSequences from './Assets/ImageSequences.json';
14
- import {TransitionSeries, linearTiming} from '@remotion/transitions';
15
- import {slide} from '@remotion/transitions/slide';
16
 
17
  const ImageStream = React.memo(() => {
18
  const {fps} = useVideoConfig();
 
 
 
 
 
 
 
 
 
 
 
 
19
  return (
20
  <AbsoluteFill
21
  style={{
@@ -30,57 +39,42 @@ const ImageStream = React.memo(() => {
30
  objectFit: 'cover',
31
  }}
32
  >
33
- <TransitionSeries>
34
- {imageSequences.map((entry, index) => {
35
- return (
36
- <>
37
- <TransitionSeries.Sequence
38
- key={entry.start}
39
- durationInFrames={fps * (entry.end - entry.start)}
40
- >
41
- <Images key={index} index={index} entry={entry} />;
42
- </TransitionSeries.Sequence>
43
- </>
44
- );
45
- })}
46
- </TransitionSeries>
47
  </AbsoluteFill>
48
  );
49
  });
50
 
51
- const Images = React.memo(({entry, index}) => {
52
  const frame = useCurrentFrame();
53
  const {fps} = useVideoConfig();
54
 
55
- const duration = fps * 2.5;
56
- const ImgScale = interpolate(frame, [1, duration], [1, 1.2], {
57
- easing: Easing.bezier(0.65, 0, 0.35, 1),
58
- extrapolateRight: 'clamp',
59
- extrapolateLeft: 'clamp',
60
- });
 
 
 
 
61
 
62
  return (
63
  <AbsoluteFill
64
  style={{
65
- BackgroundColor: 'black',
66
  }}
67
- className="bg-black"
68
  >
69
- {/* <Audio src={staticFile('sfx_1.mp3')} volume={0.5} /> */}
70
  <Img
71
  id="imagex"
72
  style={{
73
- scale: 2,
74
- filter: `url(#blur)`,
75
- objectPosition: 'center',
76
- objectFit: 'cover',
77
-
78
- position: 'absolute',
79
- top: '50%', // Center vertically
80
- left: '50%', // Center horizontally
81
  transform: `translate(-50%, -50%) scale(${ImgScale})`,
 
 
 
82
  width: 1080,
83
  height: 1920,
 
84
  }}
85
  src={staticFile(entry.name)}
86
  />
 
1
  import {AbsoluteFill} from 'remotion';
 
2
  import React, {useMemo} from 'react';
3
  import {
4
  staticFile,
5
  useVideoConfig,
6
  Img,
7
  Easing,
 
8
  useCurrentFrame,
9
  interpolate,
10
  } from 'remotion';
11
  import imageSequences from './Assets/ImageSequences.json';
12
+ import {TransitionSeries} from '@remotion/transitions';
 
13
 
14
  const ImageStream = React.memo(() => {
15
  const {fps} = useVideoConfig();
16
+
17
+ const imageComponents = useMemo(() => {
18
+ return imageSequences.map((entry, index) => (
19
+ <TransitionSeries.Sequence
20
+ key={index}
21
+ durationInFrames={fps * (entry.end - entry.start)}
22
+ >
23
+ <Images key={index} entry={entry} />
24
+ </TransitionSeries.Sequence>
25
+ ));
26
+ }, [fps]);
27
+
28
  return (
29
  <AbsoluteFill
30
  style={{
 
39
  objectFit: 'cover',
40
  }}
41
  >
42
+ <TransitionSeries>{imageComponents}</TransitionSeries>
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  </AbsoluteFill>
44
  );
45
  });
46
 
47
+ const Images = React.memo(({entry}) => {
48
  const frame = useCurrentFrame();
49
  const {fps} = useVideoConfig();
50
 
51
+ const duration = useMemo(() => fps * 2.5, [fps]);
52
+ const ImgScale = useMemo(
53
+ () =>
54
+ interpolate(frame, [0, duration], [1, 1.2], {
55
+ easing: Easing.bezier(0.65, 0, 0.35, 1),
56
+ extrapolateRight: 'clamp',
57
+ extrapolateLeft: 'clamp',
58
+ }),
59
+ [frame, duration]
60
+ );
61
 
62
  return (
63
  <AbsoluteFill
64
  style={{
65
+ backgroundColor: 'black',
66
  }}
 
67
  >
 
68
  <Img
69
  id="imagex"
70
  style={{
 
 
 
 
 
 
 
 
71
  transform: `translate(-50%, -50%) scale(${ImgScale})`,
72
+ position: 'absolute',
73
+ top: '50%',
74
+ left: '50%',
75
  width: 1080,
76
  height: 1920,
77
+ objectFit: 'cover',
78
  }}
79
  src={staticFile(entry.name)}
80
  />