Created
September 21, 2018 13:10
-
-
Save davit312/87e2a6194640b9e3314fba4973f83663 to your computer and use it in GitHub Desktop.
Սա օգտագործում եմ films-hy.blogspot.com կայքի ֆիլմերը ավելորդ մասերից մաքրելու համար
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"strconv" | |
) | |
func main() { | |
println("[Info] 'avconv' required if not installed type 'sudo apt install libav-tools' \n") | |
argc := len(os.Args) | |
if argc < 3 { | |
println("Wrong arguments!!") | |
return | |
} | |
list, err := os.Create("0.txt") | |
if err != nil { | |
println("Can't open file " + os.Args[1]) | |
return | |
} | |
part := 0 | |
for i := 2; i < argc; i += 2 { | |
part++ | |
number := strconv.Itoa(part) | |
var cmd = []string{ | |
"-i", os.Args[1], | |
"-c", "copy", | |
"-ss", os.Args[i], | |
} | |
name := "pt" + number + ".wmv" | |
if i+1 < argc { | |
cmd = append(cmd, "-to") | |
cmd = append(cmd, os.Args[i+1]) | |
} | |
cmd = append(cmd, name) | |
println("Processing part " + number) | |
exec.Command("avconv", cmd...).Run() | |
list.WriteString("file " + "pt" + number + ".wmv" + "\n") | |
} | |
var enter string | |
print("\n" + "Press enter to concat... ") | |
fmt.Scanln(&enter) | |
list.Close() | |
exec.Command("avconv", "-f", "concat", "-i", "0.txt", "-c", "copy", "result.wmv").Run() | |
part++ | |
os.Remove("0.txt") | |
for i := 1; i < part; i++ { | |
os.Remove("pt" + strconv.Itoa(i) + ".wmv") | |
} | |
println("\n" + "DONE") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment