-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwrite_file.c
More file actions
executable file
·38 lines (27 loc) · 803 Bytes
/
write_file.c
File metadata and controls
executable file
·38 lines (27 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <libavutil/log.h>
#include <libavformat/avio.h>
int main(int argc, char *argv[])
{
int err_code;
char *src_filename = NULL;
AVIOContext *avio_ctx = NULL;
unsigned char buf[] = "hello world!";
av_log_set_level(AV_LOG_DEBUG);
if(argc < 2){
av_log(NULL, AV_LOG_DEBUG, "The count of pamameter should be more than two!\n");
exit(1);
}
src_filename = argv[1];
if(!src_filename){
av_log(NULL, AV_LOG_DEBUG, "Invalid src filename\n");
exit(1);
}
if((err_code=avio_open(&avio_ctx, src_filename, AVIO_FLAG_WRITE)) < 0){
av_log(NULL, AV_LOG_DEBUG, "Could not open file %s\n", src_filename);
exit(1);
}
avio_write(avio_ctx, buf, 12);
avio_close(avio_ctx);
return 0;
}