You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -13,14 +13,14 @@ The data format is modified for playback.
13
13
14
14
15
15
## Overview
16
-
This application plays [gcf file](#gcf-file-format)(original format) that are combined [JPEG](https://en.wikipedia.org/wiki/JPEG) files splited from video file, along with Wave file.
17
-
This application works like a video playback by playing back the combined images in SD with sound.
18
-
It uses multi-cores to perform rendering with DMA and audio playback.
16
+
This application streams video files converted to the dedicated format gmv from SD.
17
+
It uses multi-cores to perform rendering with DMA and audio playback.
18
+
Old format (gcf + wav) can be played back (however, audio playback is restricted on machines without PSRAM).
19
19
20
20
21
21
## Target devices
22
22
It must be able to run the libraries it depends on and have an SD card.
23
-
* M5Stack Basic 2.6
23
+
* M5Stack Basic 2.6 or later
24
24
* M5Stack Gray
25
25
* M5Stack Core2
26
26
* M5Stack CoreS3
@@ -43,18 +43,18 @@ However, Basic and Gray, which do not have PSRAM, have significant limitations o
43
43
|Env|Description|
44
44
|---|---|
45
45
|release|Basic Settings|
46
-
|release\_DisplayModule| Support [HDMI Module](https://shop.m5stack.com/products/display-module-13-2)|
46
+
|release\_DisplayModule| Support [DisplayModule](https://shop.m5stack.com/products/display-module-13-2)|
47
47
|release\_SdUpdater| Support SD-Updater |
48
-
|release\_SdUpdater\_DisplayModule| Support HDMI Module and SD-Updater |
48
+
|release\_SdUpdater\_DisplayModule| Support DisplayModule and SD-Updater |
49
49
50
50
### For CoreS3
51
51
|Env|Description|
52
52
|---|---|
53
53
|S3\_release|Basic Settings|
54
-
|S3\_release_DisplayModule| Support SD-Updater|
54
+
|S3\_release_DisplayModule| Support DisplayModule|
55
55
56
56
### Sample data for playback
57
-
Download [sample_data.zip](https://github.com/GOB52/M5Stack_FlipBookSD/files/11523705/sample_data.zip) and copy it to **/gcf** on your SD card.
57
+
Download [sample_003.zip](https://github.com/GOB52/M5Stack_FlipBookSD/files/11746898/sample_003.zip) and copy it to **/gcf** on your SD card.
58
58
59
59
60
60
## How to make data
@@ -71,55 +71,93 @@ Making data on terminal.
71
71
Video data can be in any format that can be processed by FFmpeg.
72
72
73
73
1. Copy video data to an arbitrarily created directory.
74
-
1. Copy [conv.sh](conv.sh) and [gcf.py](gcf.py) to the same directory.
75
-
1. Execute the shell script as follows
76
-
**bash conv.sh videofilename framerate(number)**
77
-
1. The files that named "videofilename.framerate.gcf" and "videofilename.wav" output to same directory.
78
-
1. Copy the above two files to **/gcf** on the SD card.
74
+
1. Copy [conv.sh](script/conv.sh) and [gmv.py](script/gmv.py) to the same directory.
75
+
1. Execute the shell script as follows
76
+
**bash conv.sh move_file_name frame_rate [ jpeg_maxumu,_size (Default if not specified is 7168) ]**
77
+
78
+
| Argument | Required?| Description |
79
+
|---|---|---|
80
+
|move_file_path|YES|Source movie|
81
+
|frame_rate|YES|Output frame rate (1 - 30)|
82
+
|jpeg_maximum_size|NO|Maximum file size of one image to output (1024 - 10240)<BR>Larger size helps maintain quality but increases the likelihood of crashes (see Known Issues)|
83
+
84
+
4. The files that named "videofilename.gmv" output to same directory.
85
+
5. Copy the above files to **/gcf** on the SD card.
79
86
80
87
e.g.)
81
-
```
88
+
```sh
82
89
mkdir foo
83
90
cp bar.mp4 foo
84
-
cp conv.sh foo
85
-
cp gcf.py foo
91
+
cp script/conv.sh foo
92
+
cp script/gcf.py foo
86
93
cd foo
87
94
bash conv.sh bar.mp4 24
88
-
cp bar.24.gcf your_sd_card_path/gcf
89
-
cp bar.wav your_sd_card_path/gcf
95
+
cp bar.gmv your_sd_card_path/gcf
90
96
```
91
97
92
-
####Processes performed by shell scripts
93
-
* Output JPEG images from video at the specified frame rate.(Create output directory . /jpg is created)
94
-
* Adjust the size of the output JPEG file so that it does not exceed the internal buffer. (10KiB)
95
-
*Combine JPEG files to create a gcf file.
98
+
### Processes performed by shell scripts
99
+
* Output JPEG images from video at the specified frame rate.
100
+
Create an output directory of . /jpg+PID as the output directory. This allows multiple terminals to convert in parallel.
101
+
*If the size of the output JPEG file exceeds the specified size, reconvert it to fit.
96
102
* Output audio data from the video and normalize it out.
103
+
* gmv.py creates a dedicated file containing images and audio.
You can change the output quality, filters, etc. to your liking. The best parameters depend on the source video, so please refer to FFmpeg's information.
97
110
98
111
### Data restrictions
99
-
* Wav data is output in 8KHz, unsigned 8bit, mono format.
100
-
If there is not enough memory, no sound will be played. For device without PSRAM, it would have to be a short one to make it sound.
101
-
On Core2, PSRAM normally has a usable size of 4 MiB, so approximately about 8 minutes and 30 seconds seems to be the maximum playback length.
102
-
On Core3 that can use 8MB,approximately 16 minutes is considered the maximum playback length.
112
+
* wav data quality (8KHz unsigned 8bit mono)
113
+
The quality of the audio data is lowered to reduce the processing load.
114
+
It is possible to edit the script to improve the quality, but the processing load may cause crashes. (See Known Issues).
103
115
104
116
* Image size and frame rate
105
117
When converting a video to JPEG, the width is 320px and the height is a value that maintains the aspect ratio.
106
-
Currently, 320 x 240 can be played back at about 24 FPS, and 320 x 180 at about 30 FPS.
107
-
To change the image size, edit the "scale=.... in conv.sh.
108
-
```sh
109
-
ffmpeg -i $1 -r $2 -vf scale=320:-1 jpg/%05d.jpg
110
-
```
118
+
<ins>Currently, 320 x 240 can be played back at about 24 FPS, and 320 x 180 at about 30 FPS.</ins>
119
+
To change the image size, edit the parameter for FFmpeg in conv.sh. **(scale=)**
111
120
112
121
## Known issues
113
122
### Reset during playback
114
123
If a reset occurs during execution, the Serial monitor should display a message that the assertion was caught.
115
-
The cause is that drawing did not finish within the specified time, and the SD and Lcd buses collided.
124
+
The cause is that drawing did not finish within the specified time, and the SD and Lcd buses collided.
125
+
If this occurs at a specific point in the video, it can be avoided by modifying the data side.
116
126
117
127
Also, in rare cases, it may take a long time to read from SD, which may cause a reset as described above.
118
-
The cause of this is not known.
128
+
The cause of this is not known.There may be SD card compatibility issues.
119
129
120
-
#### Workaround by the program
121
-
How to deal with it in the program
122
-
Switch multi-core playback to single-core playback.
>OS utilities should not be used for formatting SD cards. FAT16/FAT32 has lots of options for file system layout. In addition to the cluster size there are options for aligning file structures.
133
+
>The SD Association has a standard layout for each size SD card. Cards are designed to optimize performance for the standard layout. For example, flash chip boundaries are aligned with file system structures.
134
+
>My SdFormatter example produces the standard layout. On a PC use the [SD Association Formatter](https://www.sdcard.org/downloads/).
135
+
>You should not be getting errors due to the format. The correct format will only enhance performance, not reduce errors.
136
+
>I rarely see the type errors you are having. Most users either have solid errors or no errors.
137
+
>I have seen this type error when another SPI device interferes with the SD or when there are noisy or poor SPI signals.
138
+
139
+
#### Workaround by the data
140
+
* Reduce playback frame rate
141
+
```sh
142
+
bash conv.sh video.mp4 30 # 30 FPS
143
+
bash conv.sh video.mp4 24 # Reduce to 24
144
+
```
145
+
* Reduce JPEG file size
146
+
```sh
147
+
bash conv.sh video.mp4 30 # 7168 as default
148
+
bash conv.sh video.mp4 30 5120 # Reduce to 5120
149
+
```
150
+
* Reduce image size
151
+
```sh
152
+
conv.sh
153
+
# ...
154
+
#ffmpeg -i $1 -r $2 -vf scale=320:-1,dejudder -qmin 1 -q 1 jpg$$/%06d.jpg # 320 x n pixel
155
+
ffmpeg -i $1 -r $2 -vf scale=240:-1,dejudder -qmin 1 -q 1 jpg$$/%06d.jpg # 240 x n pixel
156
+
# ...
157
+
```
158
+
159
+
#### Workaround by the program (deprecated)
160
+
* Switch multi-core playback to single-core playback.
123
161
Switch the corresponding section of main.cpp to the one using a single core.
124
162
Playback speed will be reduced, but bus contention will be reliably avoided.
125
163
@@ -130,29 +168,13 @@ static void loopRender()
130
168
// ...
131
169
{
132
170
ScopedProfile(drawCycle);
133
-
//mainClass.drawJpg(buffer, JPG_BUFFER_SIZE); // Process on multiple cores
134
-
mainClass.drawJpg(buffer, JPG_BUFFER_SIZE, false); // Process on single core.
171
+
//mainClass.drawJpg(buffers[(bufferIndex - 1 + NUMBER_OF_BUFFERS) % NUMBER_OF_BUFFERS], JPG_BUFFER_SIZE); // Process on multiple cores
172
+
mainClass.drawJpg(buffers[(bufferIndex - 1 + NUMBER_OF_BUFFERS) % NUMBER_OF_BUFFERS], JPG_BUFFER_SIZE, false); // Process on single core. Try it, if If assert occurs on xQueueSend call. (However, FPS will be reduced)
135
173
}
136
174
// ...
137
175
}
138
176
```
139
177
140
-
#### Workaround by the data
141
-
Try reducing the playback frame rate. You can adjust this with the arguments you give to conv.sh.
142
-
Or you can reduce the image size.
143
-
144
-
```
145
-
bash conv.sh video.mp4 30 # If reset during playback
Currently, the old format (gcf + wav) can be played,
198
+
Pyhton script for conversion [gcf\_to\_gmv.py](script/gcf_to_gmv.py) and shell script for conversion of files in the current directory [convert\_gcf\_to\_gmv.sh](script/convert_gcf_to_gmv.sh) for converting files in the current directory.
199
+
200
+
```sh
201
+
# gcf_dir has gcf + wav files
202
+
cp script/gcf_to_gmv.py gcf_dir
203
+
cp script/convert_gcf_to_gmv.sh gcf_dir
204
+
cd gcf_dir
205
+
bash convert_gcf_to_gmv.sh
206
+
cp *.gmv your_sd_card_path/gcf
192
207
```
193
208
194
209
## Digression
@@ -205,6 +220,9 @@ The read processing time per image has gone from tens of ms for each file opened
205
220
I was experimenting with unzipLIB because I wanted to handle ZIP files. I wanted to learn how to use it, and I wanted to play back a collection of image files like a flip book.
206
221
(In the end, I ended up not using unzipLIB (´・ω・`) )
207
222
223
+
### Is this different from [MotionJPEG](https://en.wikipedia.org/wiki/Motion_JPEG)?
224
+
According to the definition, this can be called MJPEG. However, MJPEG is not a unified file format, so this application is only a gmv format player.
0 commit comments