NodeJS のように HTTP 応答をパイプするにはどうすればよいですか。NodeJS で使用しているスニペットは次のとおりです。
request({
url: audio_file_url,
}).pipe(ffmpeg_process.stdin);
Goで同じ結果を得るにはどうすればよいですか?
オーディオ ストリームを HTTP から FFmpeg プロセスにパイプして、その場で変換し、変換されたファイルをクライアントに返すようにしようとしています。
これまでのところ、ここにいるすべての人に明らかなように、私のソースコードは次のとおりです。
func encodeAudio(w http.ResponseWriter, req *http.Request) {
path, err := exec.LookPath("youtube-dl")
if err != nil {
log.Fatal("LookPath: ", err)
}
path_ff, err_ff := exec.LookPath("ffmpeg")
if err != nil {
log.Fatal("LookPath: ", err_ff)
}
streamLink := exec.Command(path,"-f", "140", "-g", "https://www.youtube.com/watch?v=VIDEOID")
var out bytes.Buffer
streamLink.Stdout = &out
cmdFF := exec.Command(path_ff, "-i", "pipe:0", "-acodec", "libmp3lame", "-f", "mp3", "-")
resp, err := http.Get(out.String())
if err != nil {
log.Fatal(err)
}
// pr, pw := io.Pipe()
defer resp.Body.Close()
cmdFF.Stdin = resp.Body
cmdFF.Stdout = w
streamLink.Run()
//get ffmpeg running in another goroutine to receive data
errCh := make(chan error, 1)
go func() {
errCh <- cmdFF.Run()
}()
// close the pipeline to signal the end of the stream
// pw.Close()
// pr.Close()
// check for an error from ffmpeg
if err := <-errCh; err != nil {
// ff error
}
}
エラー: 2014/07/29 23:04:02 取得: サポートされていないプロトコル スキーム ""