0

I would like to compile ffmpeg with fixed arguments, ie: ffmpeg -i rtsp://localhost/live -vcodec copy -acodec copy -f flv rtmp://remotehost/live

I can't for security reasons call it from an external script, this must be included in the ffmpeg binary. Prblem is that the source codes are very big , so do u know a simple way to do that ?

Tx

  • The entry point [main()](https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffmpeg.c#L4834) in fftools/ffmpeg.c receives the input arguments in an array of strings argv. Hard code an array and increment argc and point argv to those. – Gyan Mar 07 '20 at 18:46
  • thanks gyan for your response, i'll do that and win time. – netlink netlink Mar 07 '20 at 18:49
  • See https://stackoverflow.com/q/20878322 – Gyan Mar 09 '20 at 05:43
  • is tried this, but what do i have tu put in place of programName ? int main(int argc,char* argv[]) { argv[0] = "programName"; argv[1] = "para1"; argv[2] = "para2"; argv[3] = "para3"; } – netlink netlink Mar 09 '20 at 14:46
  • Whatever you want. "ffmpeg" is fine. – Gyan Mar 09 '20 at 15:12
  • yes it's fine but i need to securise it so that local users can't use it for something else that we want: one rtsp source, one rtmp destination. – netlink netlink Mar 09 '20 at 15:15

2 Answers2

0

I can't comment yet, but if you are using linux could you use alias?

https://www.tecmint.com/create-alias-in-linux/

  • Thanks for your response. Alias could be a simple solution and yes i use unix/linux but as i said in my post i can't use it for security reason. The full open ffmpeg binary can't exist in the system. So alias can't be used there. – netlink netlink Mar 07 '20 at 18:17
0

my knowledges in C are too light ....this never call the programm with args:

int main(int argc, char **argv) {

  argv=malloc(10 * sizeof(char *));
   argv[1] =(char *) malloc( strlen("-i " ) + 1 );
    strcpy(argv[1],"-i " );
    argv[2] =(char *) malloc( strlen("rtsp://192.168.1.38/live" ) + 1 );
    strcpy(argv[2],"rtsp://192.168.1.38/live" );
    argv[3] =(char *) malloc( strlen("-vcodec" ) + 1 );
    strcpy(argv[3],"-vcodec" );
    argv[4] =(char *) malloc( strlen("copy" ) + 1 );
    strcpy(argv[4],"copy" );
    argv[5] =(char *) malloc( strlen("-acodec" ) + 1 );
    strcpy(argv[5],"-acodec" );
    argv[6] =(char *) malloc( strlen("copy" ) + 1 );
    strcpy(argv[6],"copy" );
    argv[7] =(char *) malloc( strlen("-f" ) + 1 );
    strcpy(argv[7],"-f" );
    argv[8] =(char *) malloc( strlen("flv" ) + 1 );
    strcpy(argv[8],"flv" );
    argv[9] =(char *) malloc( strlen("rtmp://192.168.A.114/live" ) + 1 );
    strcpy(argv[9],"rtmp://192.168.1.114/live" );
    printf("argument  %s\n", argv[1]);
    printf("argument  %s\n", argv[2]);
    printf("argument  %s\n", argv[3]);
    printf("argument  %s\n", argv[4]);
    printf("argument  %s\n", argv[5]);
    printf("argument  %s\n", argv[6]);
    printf("argument  %s\n", argv[7]);
    printf("argument  %s\n", argv[8]);
    printf("argument  %s\n", argv[9]);

    argv[10]=NULL;
    /*for (i=0; i < 9; i++)*/
    free(argv);
    return 0;
}
can anyone help ?