Add: support video (still in test), change ogg to webm
This commit is contained in:
17
config.json
17
config.json
@@ -6,14 +6,15 @@
|
|||||||
"token": "!! config your very strong token here !!",
|
"token": "!! config your very strong token here !!",
|
||||||
"ffmpeg_threads": 1,
|
"ffmpeg_threads": 1,
|
||||||
"ffmpeg_config_list": [
|
"ffmpeg_config_list": [
|
||||||
{"name": "OPUS 128k", "args": "-c:a libopus -ab 128k"},
|
{"name": "OPUS 128k", "args": "-c:a libopus -ab 128k -vn"},
|
||||||
{"name": "OPUS 96k", "args": "-c:a libopus -ab 96k"},
|
{"name": "OPUS 96k", "args": "-c:a libopus -ab 96k -vn"},
|
||||||
{"name": "OPUS 256k", "args": "-c:a libopus -ab 256k"},
|
{"name": "OPUS 256k", "args": "-c:a libopus -ab 256k -vn"},
|
||||||
{"name": "OPUS 320k", "args": "-c:a libopus -ab 320k"},
|
{"name": "OPUS 320k", "args": "-c:a libopus -ab 320k -vn"},
|
||||||
{"name": "OPUS 512k", "args": "-c:a libopus -ab 512k"},
|
{"name": "OPUS 512k", "args": "-c:a libopus -ab 512k -vn"},
|
||||||
{"name": "AAC 128k", "args": "-c:a aac -ab 128k"},
|
{"name": "AAC 128k", "args": "-c:a aac -ab 128k -vn"},
|
||||||
{"name": "AAC 256k", "args": "-c:a aac -ab 256k"},
|
{"name": "AAC 256k", "args": "-c:a aac -ab 256k -vn"},
|
||||||
{"name": "全损音质 32k", "args": "-c:a libopus -ab 32k"}
|
{"name": "全损音质 32k", "args": "-c:a libopus -ab 32k -vn"},
|
||||||
|
{"name": "video test", "args": "-c:a libopus -ab 128k -filter:v scale='min(640,iw)':min'(360,ih)':force_original_aspect_ratio=decrease -c:v libvpx -r 5"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"tmpfs": {
|
"tmpfs": {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (api *API) HandleGetFileStream(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
args := strings.Split(ffmpegConfig.Args, " ")
|
args := strings.Split(ffmpegConfig.Args, " ")
|
||||||
startArgs := []string{"-threads", strconv.FormatInt(api.APIConfig.FfmpegThreads, 10), "-i", path}
|
startArgs := []string{"-threads", strconv.FormatInt(api.APIConfig.FfmpegThreads, 10), "-i", path}
|
||||||
endArgs := []string{"-vn", "-f", "ogg", "-"}
|
endArgs := []string{"-f", "webm", "-"}
|
||||||
ffmpegArgs := append(startArgs, args...)
|
ffmpegArgs := append(startArgs, args...)
|
||||||
ffmpegArgs = append(ffmpegArgs, endArgs...)
|
ffmpegArgs = append(ffmpegArgs, endArgs...)
|
||||||
cmd := exec.Command("ffmpeg", ffmpegArgs...)
|
cmd := exec.Command("ffmpeg", ffmpegArgs...)
|
||||||
@@ -137,7 +137,7 @@ func (api *API) HandlePrepareFileStreamDirect(w http.ResponseWriter, r *http.Req
|
|||||||
|
|
||||||
args := strings.Split(ffmpegConfig.Args, " ")
|
args := strings.Split(ffmpegConfig.Args, " ")
|
||||||
startArgs := []string{"-threads", strconv.FormatInt(api.APIConfig.FfmpegThreads, 10), "-i", srcPath}
|
startArgs := []string{"-threads", strconv.FormatInt(api.APIConfig.FfmpegThreads, 10), "-i", srcPath}
|
||||||
endArgs := []string{"-vn", "-y", objPath}
|
endArgs := []string{"-y", objPath}
|
||||||
ffmpegArgs := append(startArgs, args...)
|
ffmpegArgs := append(startArgs, args...)
|
||||||
ffmpegArgs = append(ffmpegArgs, endArgs...)
|
ffmpegArgs = append(ffmpegArgs, endArgs...)
|
||||||
cmd := exec.Command("ffmpeg", ffmpegArgs...)
|
cmd := exec.Command("ffmpeg", ffmpegArgs...)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type Tmpfs struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tmpfs *Tmpfs) GetObjFilePath(id int64, configName string) (string) {
|
func (tmpfs *Tmpfs) GetObjFilePath(id int64, configName string) (string) {
|
||||||
return filepath.Join(tmpfs.Config.Root, strconv.FormatInt(id, 10) + "." + configName + ".ogg")
|
return filepath.Join(tmpfs.Config.Root, strconv.FormatInt(id, 10) + "." + configName + ".webm")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tmpfs *Tmpfs) GetLock(filename string) *sync.Mutex {
|
func (tmpfs *Tmpfs) GetLock(filename string) *sync.Mutex {
|
||||||
|
|||||||
@@ -100,3 +100,11 @@ dialog {
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
.vertical {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.warp-word {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|||||||
@@ -83,14 +83,8 @@ function App() {
|
|||||||
path="/manage/register"
|
path="/manage/register"
|
||||||
element={<Register user={user} setUser={setUser} />}
|
element={<Register user={user} setUser={setUser} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route path="/manage/tags" element={<Tags user={user} />} />
|
||||||
path="/manage/tags"
|
<Route path="/manage/tags/:id" element={<EditTag user={user} />} />
|
||||||
element={<Tags user={user} />}
|
|
||||||
/>
|
|
||||||
<Route
|
|
||||||
path="/manage/tags/:id"
|
|
||||||
element={<EditTag user={user} />}
|
|
||||||
/>
|
|
||||||
<Route
|
<Route
|
||||||
path="/manage/reviews/:id"
|
path="/manage/reviews/:id"
|
||||||
element={<EditReview user={user} />}
|
element={<EditReview user={user} />}
|
||||||
@@ -113,16 +107,16 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/files/:id/review"
|
path="/files/:id/review"
|
||||||
element={<ReviewPage user={user} setPlayingFile={setPlayingFile} />}
|
element={
|
||||||
|
<ReviewPage user={user} setPlayingFile={setPlayingFile} />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<AudioPlayer
|
||||||
<AudioPlayer
|
playingFile={playingFile}
|
||||||
playingFile={playingFile}
|
setPlayingFile={setPlayingFile}
|
||||||
setPlayingFile={setPlayingFile}
|
/>
|
||||||
/>
|
|
||||||
</footer>
|
|
||||||
</Router>
|
</Router>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ function AudioPlayer(props) {
|
|||||||
let navigate = useNavigate();
|
let navigate = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<footer className="vertical">
|
||||||
<h5>Player status</h5>
|
<h5>Player status</h5>
|
||||||
{props.playingFile.id && (
|
{props.playingFile.id && (
|
||||||
<span>
|
<span>
|
||||||
@@ -111,46 +111,65 @@ function AudioPlayer(props) {
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<input
|
<span>
|
||||||
checked={loop}
|
<input
|
||||||
onChange={(event) => setLoop(event.target.checked)}
|
checked={loop}
|
||||||
type="checkbox"
|
onChange={(event) => setLoop(event.target.checked)}
|
||||||
/>
|
type="checkbox"
|
||||||
<label>Loop</label>
|
/>
|
||||||
|
<label>Loop</label>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
checked={raw}
|
checked={raw}
|
||||||
onChange={(event) => setRaw(event.target.checked)}
|
onChange={(event) => setRaw(event.target.checked)}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
/>
|
/>
|
||||||
<label>Raw</label>
|
<label>Raw</label>
|
||||||
|
|
||||||
{!raw && (
|
{!raw && (
|
||||||
<span>
|
<span>
|
||||||
<input
|
<input
|
||||||
checked={prepare}
|
checked={prepare}
|
||||||
onChange={(event) => setPrepare(event.target.checked)}
|
onChange={(event) => setPrepare(event.target.checked)}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
/>
|
/>
|
||||||
<label>Prepare</label>
|
<label>Prepare</label>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
onClick={(e) => {
|
||||||
|
const domVideoPlayer = document.getElementById("dom-video-player");
|
||||||
|
if (domVideoPlayer === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.target.checked) {
|
||||||
|
domVideoPlayer.style.height = "auto";
|
||||||
|
} else {
|
||||||
|
domVideoPlayer.style.height = "39px";
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<label>Video</label>
|
||||||
|
</span>
|
||||||
|
|
||||||
{playingURL !== "" && (
|
{playingURL !== "" && (
|
||||||
<audio
|
<video
|
||||||
|
id="dom-video-player"
|
||||||
controls
|
controls
|
||||||
autoPlay
|
autoPlay
|
||||||
loop={loop}
|
loop={loop}
|
||||||
className="audio-player"
|
className="audio-player"
|
||||||
src={playingURL}
|
src={playingURL}
|
||||||
></audio>
|
></video>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<FfmpegConfig
|
<FfmpegConfig
|
||||||
selectedFfmpegConfig={selectedFfmpegConfig}
|
selectedFfmpegConfig={selectedFfmpegConfig}
|
||||||
setSelectedFfmpegConfig={setSelectedFfmpegConfig}
|
setSelectedFfmpegConfig={setSelectedFfmpegConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</footer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function FfmpegConfig(props) {
|
|||||||
<option key={ffmpegConfig.name}>{ffmpegConfig.name}</option>
|
<option key={ffmpegConfig.name}>{ffmpegConfig.name}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<span>{props.selectedFfmpegConfig.args}</span>
|
<span className="warp-word">{props.selectedFfmpegConfig.args}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user