mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
- Refactor frame converter implementation - Update mp4 track to use ICodex - General refactoring and code improvements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
35 lines
491 B
Go
35 lines
491 B
Go
package hls
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
type TsInFile struct {
|
|
TsInMemory
|
|
file *os.File
|
|
path string
|
|
closed bool
|
|
}
|
|
|
|
func (ts *TsInFile) Open(path string) (err error) {
|
|
dir := filepath.Dir(path)
|
|
if err = os.MkdirAll(dir, 0755); err != nil {
|
|
return
|
|
}
|
|
ts.file, err = os.Create(path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
ts.path = path
|
|
return
|
|
}
|
|
|
|
func (ts *TsInFile) Close() error {
|
|
if ts.closed || ts.file == nil {
|
|
return nil
|
|
}
|
|
ts.closed = true
|
|
return ts.file.Close()
|
|
}
|