Skip to content

Commit

Permalink
Support for resolution parameters and internationalized file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
GanymedeNil committed Jan 17, 2023
1 parent a2c1c35 commit b15eaac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ $ ./srt2fcpxml
Frame rate is currently supported (帧率目前支持) 23.98、24、25、29.97、30、50、59.94、60 (default 25)
-srt string
srt Subtitle files (字幕文件)
-width int
width resolution default 1920 (分辨率宽 默认 1920)
-height int
high resolution default 1080 (分辨率高 默认 1080)
```

## Execution (执行)
Expand Down
9 changes: 6 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import (
)

func main() {
srtFile := flag.String("srt", "", "srt 字幕文件")
frameDurationPoint := flag.String("fd", "25", "帧率目前支持 23.98、24、25、29.97、30、50、59.94、60")
srtFile := flag.String("srt", "", "srt subtitle file")
frameDurationPoint := flag.String("fd", "25", "frame rate currently supported 23.98、24、25、29.97、30、50、59.94、60")
width := flag.Int("width", 1920, "width resolution default 1920")
height := flag.Int("height", 1080, "high resolution default 1080")

flag.Parse()
var frameDuration interface{}
if len(*frameDurationPoint) > 2 {
Expand All @@ -34,7 +37,7 @@ func main() {
}

project, path := getPath(*srtFile)
result, _ := core.Srt2FcpXmlExport(project, frameDuration, f)
result, _ := core.Srt2FcpXmlExport(project, frameDuration, f, *width, *height)
out += string(result)
targetFile := fmt.Sprintf("%s/%s.fcpxml", path, project)
fd, err := os.Create(targetFile)
Expand Down
2 changes: 1 addition & 1 deletion core/FcpXML/Resources/Effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func NewEffect() *Effect {
return &Effect{
Text: "",
ID: "r2",
Name: "基本字幕",
Name: "Basic Title",
Uid: ".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti",
}
}
12 changes: 6 additions & 6 deletions core/fcpxml.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/asticode/go-astisub"
)

func Srt2FcpXmlExport(projectName string, frameDuration interface{}, subtitles *astisub.Subtitles) ([]byte, error) {
func Srt2FcpXmlExport(projectName string, frameDuration interface{}, subtitles *astisub.Subtitles, width, height int) ([]byte, error) {
fcpxml := FcpXML.New()
res := Resources.NewResources()
res.SetEffect(Resources.NewEffect())
format := Resources.NewFormat().
SetWidth(1920).
SetHeight(1080).
SetWidth(width).
SetHeight(height).
SetFrameRate(frameDuration).Render()
res.SetFormat(format)
fcpxml.SetResources(res)
Expand All @@ -38,9 +38,9 @@ func Srt2FcpXmlExport(projectName string, frameDuration interface{}, subtitles *
return strings.Join(os, "\n")
}(item.Lines))
title := Title.NewTitle(item.String(), item.StartAt.Seconds(), item.EndAt.Seconds()).SetTextStyleDef(textStyleDef).SetText(text)
title.AddParam(Title.NewParams("位置", "9999/999166631/999166633/1/100/101", "0 -450"))
title.AddParam(Title.NewParams("对齐", "9999/999166631/999166633/2/354/999169573/401", "1 (居中)"))
title.AddParam(Title.NewParams("展平", "9999/999166631/999166633/2/351", "1"))
title.AddParam(Title.NewParams("Position", "9999/999166631/999166633/1/100/101", "0 -450"))
title.AddParam(Title.NewParams("Alignment", "9999/999166631/999166633/2/354/999169573/401", "1 (Center)"))
title.AddParam(Title.NewParams("Flatten", "9999/999166631/999166633/2/351", "1"))
gap.AddTitle(title)
}

Expand Down

0 comments on commit b15eaac

Please sign in to comment.