Skip to content

Instantly share code, notes, and snippets.

@sepfy
Created February 17, 2021 02:56
Show Gist options
  • Save sepfy/7c5b61307260af5ec886999a27c78b4b to your computer and use it in GitHub Desktop.
Save sepfy/7c5b61307260af5ec886999a27c78b4b to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
int main(int argc, char **argv) {
uint8_t buf[512];
char fifo_path[] = "test.264";
int fd = -1;
mkfifo(fifo_path, 0666);
fd = open(fifo_path, O_WRONLY);
if(fd < 0) {
fprintf(stderr, "Open fifo failed\n");
return 1;
}
FILE *fp = NULL;
fp = fopen("test2.264", "rb");
if(fp == NULL) {
fprintf(stderr, "Open h264 raw data failed\n");
return 1;
}
while(1) {
fread(buf, sizeof(buf), 1, fp);
write(fd, buf, sizeof(buf));
if(feof(fp)) {
fprintf(stdout, "End of stream\n");
break;
}
}
close(fd);
fclose(fp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment