masayoshi
(masayoshi)
1
I can not download bbc.mp3.
Could you tell me how to modify my code?
package main
import
(
"fmt"
"os/exec"
)
func main () {
cmd := exec.Command("ffmpeg","-i http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_world_service/bbc_world_service.isml/bbc_world_service-audio%3d48000.norewind.m3u8 -t 300 -b:a 64k bbc.mp3")
err := cmd.Run()
if err != nil {
fmt.Println(err)
}
}
The solution is to use the Stderr property of the Command object.
I’ll be something like
package main
import (
"bytes"
"fmt"
"os/exec"
)
func main() {
cmd := exec.Command("ffmpeg", "-i http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_world_service/bbc_world_service.isml/bbc_world_service-audio%3d48000.norewind.m3u8 -t 300 -b:a 64k bbc.mp3")
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
return
}
}
2 Likes
system
(system)
Closed
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.