Compare commits
No commits in common. "master" and "v1.0.4" have entirely different histories.
|
|
@ -102,14 +102,12 @@ var (
|
|||
"deadline": "realtime",
|
||||
}
|
||||
PresetMP4 = ffmpeg_go.KwArgs{
|
||||
"c:v": "libx264",
|
||||
"f": "mp4",
|
||||
"vcodec": "libx264",
|
||||
"format": "mp4",
|
||||
"pix_fmt": "yuv420p",
|
||||
"movflags": "frag_keyframe+empty_moov",
|
||||
"preset": "ultrafast",
|
||||
"tune": "zerolatency",
|
||||
"c:a": "aac",
|
||||
"shortest": "",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -145,35 +143,19 @@ func (t tgsConverterImpl) processVideo(ctx context.Context, anim rlottie.Lottie_
|
|||
w.Close()
|
||||
}()
|
||||
|
||||
inputVideo := ffmpeg_go.Input("pipe:0", ffmpeg_go.KwArgs{
|
||||
"format": "rawvideo",
|
||||
"pix_fmt": "bgra",
|
||||
"s": fmt.Sprintf("%dx%d", opts.ResizeWidth, opts.ResizeHeight),
|
||||
"r": frameRate,
|
||||
})
|
||||
|
||||
var output *ffmpeg_go.Stream
|
||||
|
||||
switch opts.Format {
|
||||
case converter.FormatMP4:
|
||||
inputAudio := ffmpeg_go.Input("anullsrc=channel_layout=stereo:sample_rate=44100",
|
||||
ffmpeg_go.KwArgs{"f": "lavfi"})
|
||||
|
||||
output = ffmpeg_go.Output(
|
||||
[]*ffmpeg_go.Stream{inputVideo, inputAudio},
|
||||
"pipe:1",
|
||||
preset,
|
||||
)
|
||||
|
||||
default:
|
||||
output = inputVideo.Output("pipe:1", preset)
|
||||
}
|
||||
|
||||
err := output.
|
||||
err := ffmpeg_go.
|
||||
Input("pipe:0", ffmpeg_go.KwArgs{
|
||||
"format": "rawvideo",
|
||||
"pix_fmt": "bgra",
|
||||
"s": fmt.Sprintf("%dx%d", opts.ResizeWidth, opts.ResizeHeight),
|
||||
"r": frameRate,
|
||||
}).
|
||||
Silent(true).
|
||||
Output("pipe:1", preset).
|
||||
WithInput(r).
|
||||
WithOutput(out).
|
||||
Silent(true).
|
||||
Run()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ var (
|
|||
"movflags": "frag_keyframe+empty_moov",
|
||||
"preset": "ultrafast",
|
||||
"tune": "zerolatency",
|
||||
"c:a": "aac",
|
||||
"shortest": "",
|
||||
}
|
||||
|
||||
PresetPNG = ffmpeg_go.KwArgs{
|
||||
|
|
|
|||
|
|
@ -31,39 +31,21 @@ func (ws webmConverter) Transform(ctx context.Context, in io.Reader, out io.Writ
|
|||
return err
|
||||
}
|
||||
|
||||
inputVideo := ffmpeg_go.
|
||||
Input("pipe:0").
|
||||
Silent(true)
|
||||
|
||||
var output *ffmpeg_go.Stream
|
||||
|
||||
switch opts.Format {
|
||||
case converter.FormatMP4:
|
||||
inputAudio := ffmpeg_go.Input(
|
||||
"anullsrc=channel_layout=stereo:sample_rate=44100",
|
||||
ffmpeg_go.KwArgs{"f": "lavfi"},
|
||||
)
|
||||
|
||||
output = ffmpeg_go.Output(
|
||||
[]*ffmpeg_go.Stream{inputVideo, inputAudio},
|
||||
"pipe:1",
|
||||
preset,
|
||||
)
|
||||
|
||||
default:
|
||||
output = inputVideo.Output("pipe:1", preset)
|
||||
}
|
||||
|
||||
output = output.Silent(true).WithInput(rIn).WithOutput(wOut)
|
||||
stream := ffmpeg_go.
|
||||
Input("pipe:0", ffmpeg_go.KwArgs{
|
||||
"f": "webm",
|
||||
}).
|
||||
Silent(true).
|
||||
Output("pipe:1", preset).
|
||||
WithInput(rIn).
|
||||
WithOutput(wOut)
|
||||
|
||||
if (opts.Frame == converter.FrameAll || opts.Frame == converter.FrameRange) &&
|
||||
(opts.Format == converter.FormatWEBP || opts.Format == converter.FormatJPEG || opts.Format == converter.FormatPNG) {
|
||||
|
||||
output = output.Silent(true).WithInput(rIn).WithOutput(wOut)
|
||||
|
||||
go func() {
|
||||
defer wOut.Close()
|
||||
_ = output.Run()
|
||||
_ = stream.Run()
|
||||
}()
|
||||
|
||||
zw := zip.NewWriter(out)
|
||||
|
|
@ -95,7 +77,8 @@ func (ws webmConverter) Transform(ctx context.Context, in io.Reader, out io.Writ
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := output.WithInput(rIn).WithOutput(out).Run(); err != nil {
|
||||
defer wOut.Close()
|
||||
if err := stream.WithOutput(out).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue