Skip to content

Instantly share code, notes, and snippets.

@Janet-Baker
Last active November 9, 2023 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Janet-Baker/861b5606f9c73e4004dd53a35196e428 to your computer and use it in GitHub Desktop.
Save Janet-Baker/861b5606f9c73e4004dd53a35196e428 to your computer and use it in GitHub Desktop.
some programs use ffmpeg to copy video that we do not want, removeing ffmpeg.exe will cause some unintended error, so we use this fake ffmpeg to avoid that.
#include <stdio.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("!!!DDTV DO NOT copy my files!!!\nUsage: \nMove this program to plugins/ffmpeg/ffmpeg.exe\n");
return 1;
}
char *input = NULL;
for (int i = 0; i < argc - 1; ++i) {
if (argv[i][0] == '-') {
if (argv[i][1] == 'i') {
input = argv[i + 1];
break;
}
}
}
if (NULL == input) {
printf("Can not find input file\n");
return 2;
}
char *output = argv[argc - 1];
return rename(input, output);
}
@Janet-Baker
Copy link
Author

Janet-Baker commented Nov 9, 2023

Here is a Golang version, which will get a too large product.

package main

import (
	"flag"
	"fmt"
	"os"
)

var InFile string
var OutFile string

func main() {
	flag.StringVar(&InFile, "i", "", "Input file")
	flag.StringVar(&OutFile, "o", "", "output file")
	flag.Parse()
	file := flag.Args()
	if InFile == "" {
		fmt.Println(`!!!DDTV Do NOT copy my files!!!`)
		fmt.Println(`Can not find input arguments`)
		fmt.Println(file)
		fmt.Println(`Usage: ./ffmpeg.exe -i input.mp4 -o output.mp4`)
		return
	}
	if OutFile == "" {
		a := len(file)
		if a > 0 {
			OutFile = file[a-1]
		}
	}
	if OutFile == "" {
		os.Exit(1)
	}
	err := os.Rename(InFile, OutFile)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(2)
	}
	return
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment