Skip to content

Commit

Permalink
Merge pull request #594 from shiguredo/feature/fix-mp4-media
Browse files Browse the repository at this point in the history
mp4Media 関連のバグ修正
  • Loading branch information
sile authored Oct 28, 2024
2 parents dd02a23 + 43f2665 commit 5c39e21
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- Chrome / Edge のみで利用可能
- B フレームを含んだ H.264 は正常に再生できない
- @sile
- [ADD] @shiguredo/mp4-media-stream (2024.1.2) を依存パッケージに追加する
- @sile
- [CHANGE] audioBitRate と videoBitRate を自由に設定できるようにする
- 自由入力にし、選択肢以外のビットレートでも Sora の接続パラメータとして使用できるようにする
- @tnamao
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@reduxjs/toolkit": "2.3.0",
"@shiguredo/light-adjustment": "2024.1.0",
"@shiguredo/mp4-media-stream": "2024.1.0",
"@shiguredo/mp4-media-stream": "2024.1.2",
"@shiguredo/noise-suppression": "2022.4.2",
"@shiguredo/virtual-background": "2023.2.0",
"bootstrap": "5.3.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,11 @@ async function createMediaStream(
)
return [mediaStream, gainNode]
}
if (state.mediaType === 'mp4Media' && state.mp4MediaStream !== null) {
if (state.mediaType === 'mp4Media') {
if (state.mp4MediaStream === null) {
throw new Error('No MP4 file has been selected')
}

// 指定の MP4 を再生するための MediaStream を返す
// DevTools ではいったん常に繰り返し再生にしておく
return [state.mp4MediaStream.play({ repeat: true }), null]
Expand Down
2 changes: 1 addition & 1 deletion src/app/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export const slice = createSlice({
setMediaStats: (state, action: PayloadAction<boolean>) => {
state.mediaStats = action.payload
},
setMp4MediaStream: (state, action: PayloadAction<Mp4MediaStream>) => {
setMp4MediaStream: (state, action: PayloadAction<Mp4MediaStream | null>) => {
state.mp4MediaStream = action.payload
},
setNoiseSuppression: (state, action: PayloadAction<SoraDevtoolsState['noiseSuppression']>) => {
Expand Down
18 changes: 15 additions & 3 deletions src/components/DevtoolsPane/Mp4FileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,28 @@ export const Mp4FileForm: React.FC = () => {
if (files === null || files.length === 0) {
return
}
const mp4MediaStream = await Mp4MediaStream.load(files[0])
dispatch(setMp4MediaStream(mp4MediaStream))

// MP4 ファイルをロードする
try {
const mp4MediaStream = await Mp4MediaStream.load(files[0])
dispatch(setMp4MediaStream(mp4MediaStream))
} catch (e) {
// ロードに失敗したらファイル選択をクリアする
event.target.value = ''

// 以前の内容が残っていた場合に備えて null を入れておく
dispatch(setMp4MediaStream(null))

throw e
}
}
if (mediaType !== 'mp4Media') {
return null
}
return (
<FormGroup className="form-inline" controlId="mp4File">
<TooltipFormLabel kind="mp4File">mp4File:</TooltipFormLabel>
<Form.Control type="file" disabled={disabled} onChange={onChange} />
<Form.Control type="file" accept="video/mp4" disabled={disabled} onChange={onChange} />
</FormGroup>
)
}

0 comments on commit 5c39e21

Please sign in to comment.