Hi all,
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
+ Reply to Thread
Results 1 to 7 of 7
-
-
overwrite "argc" and "argv" with the values you want at the beginning of the main in fftools/ffmpeg.c seems simpleso do u know a simple way to do that ?users currently on my ignore list: deadrats, Stears555, marcorocchini
-
i 've tried this, but the programm does not start with these fixed arguments (i do not have enough knowledges in C):
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/axis-media/media.amp " );
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.1.114/live " ) + 1 );
strcpy(argv[9],"rtmp://192.168.1.114/hls/axis " );
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;
} -
^^^This is never going to work, malloc is used to allocate memory, and in this case is being used with strlen which gets the length of a string argument, that argument can either be a variable or a constant. Your modification is a variable but you haven't defined the variable anywhere, in other words you are attempting to treat an undefined variable as a constant.argv[2] =(char *) malloc( strlen("rtsp://192.168.1.38/live " ) + 1 );
argv[9] =(char *) malloc( strlen("rtmp://192.168.1.114/live " ) + 1 );
I won't even begin to dissect everything else wrong with your approach.
As for Selur's "overwrite "argc" and "argv" with the values you want at the beginning of the main in fftools/ffmpeg.c seems simple", I would take anything he tells you about programming with some salt, and possibly some pepper also; if you have ever used that buggy mess of a program he created, Hybrid, you would know that he is not the bastion of competent programming. -
@netlink1987: haven't written C code for ages, but I guess it should be something more like:
the main function in ffmpeg,c starts with:Code:char* name = argv[0]; // grab first argument from original argv // overwrite existing *argv[] = { name, // 0 '-i', // 1 'rtsp://192.168.1.38/axis-media/media.am', //2 '-vcodec', // 3 'copy', // 4 '-acodec', //5 'copy', // 6 '-f', // 7 'flv', //8 'rtmp://192.168.1.114/hls/axis', // 9 }; argc = 10; // argument count
inserting the above code between 'BenchmarkTimeStamps ti;' and 'init_dynload();' should overwrite arc and argv.Code:int main(int argc, char **argv) { int i, ret; BenchmarkTimeStamps ti; init_dynload();
@sophiscticles: my condolences, being you must suckusers currently on my ignore list: deadrats, Stears555, marcorocchini -
Here's a correction to C / C++11 syntax (not sure which ffmpeg uses atm.)
in case ffmpeg does use c++11, you will have to use something like:Code:argc = 10; // argument count argv = new char *[argc]; argv[0] = name; argv[1] = "-i"; argv[2] = "rtsp://192.168.1.38/axis-media/media.am"; argv[3] = "-vcodec"; argv[4] = "copy"; argv[5] = "-acodec"; argv[6] = "copy"; argv[7] = "-f"; argv[8] = "flv"; argv[9] = "rtmp://192.168.1.114/hls/axis";
Cu SelurCode:char* name = argv[0]; // grab first argument from original argv // overwrite existing argc = 10; // argument count argv = new char *[argc]; argv[0] = name; char tmp1[] = "-i"; strcpy_s(tmp1, argv[1]); char tmp2[] = "rtsp://192.168.1.38/axis-media/media.am"; strcpy_s(tmp2, argv[2]); char tmp3[] = "-vcodec"; strcpy_s(tmp3, argv[3]); char tmp4[] = "copy"; strcpy_s(tmp4, argv[4]); char tmp5[] = "-acodec"; strcpy_s(tmp5, argv[5]); char tmp6[] = "copy"; strcpy_s(tmp6, argv[6]); char tmp7[] = "-f"; strcpy_s(tmp7, argv[7]); char tmp8[] = "flv"; strcpy_s(tmp8, argv[8]); char tmp9[] = "rtmp://192.168.1.114/hls/axis"; strcpy_s(tmp9, argv[9]);
users currently on my ignore list: deadrats, Stears555, marcorocchini
Similar Threads
-
Can a avi video file that's to small be fixed ?
By videonewbie in forum Newbie / General discussionsReplies: 14Last Post: 20th May 2019, 10:36 -
can I set fixed size to video window
By mla in forum Video ConversionReplies: 2Last Post: 20th Oct 2018, 09:34 -
what is the option for a veriable bit rate, instead of a fixed one for mp3?
By sommers in forum Newbie / General discussionsReplies: 5Last Post: 6th Jun 2017, 08:25 -
Encode for Target Size Fixed!!
By Cauptain in forum Video ConversionReplies: 13Last Post: 21st Oct 2016, 16:32 -
Compiling images and video
By krohm in forum EditingReplies: 20Last Post: 30th Mar 2016, 22:05


Quote