mirror of
https://github.com/horgh/videostreamer.git
synced 2025-09-26 20:41:31 +08:00
Initial import
This works for streaming mp4 from rtsp. But only to the first client as it is unable to recognize discrete frames correctly. It needs further work.
This commit is contained in:
58
cmd/remux_example/Makefile
Normal file
58
cmd/remux_example/Makefile
Normal file
@@ -0,0 +1,58 @@
|
||||
CC=gcc
|
||||
|
||||
# Reviewed warnings for gcc 6.2.1
|
||||
CFLAGS = \
|
||||
-std=c11 -g -ggdb -pedantic -pedantic-errors \
|
||||
-Werror -Wall -Wextra \
|
||||
-Wformat=2 \
|
||||
-Wformat-signedness \
|
||||
-Wnull-dereference \
|
||||
-Winit-self \
|
||||
-Wmissing-include-dirs \
|
||||
-Wshift-overflow=2 \
|
||||
-Wswitch-default \
|
||||
-Wswitch-enum \
|
||||
-Wunused-const-variable=2 \
|
||||
-Wuninitialized \
|
||||
-Wunknown-pragmas \
|
||||
-Wstrict-overflow=5 \
|
||||
-Wsuggest-attribute=pure \
|
||||
-Wsuggest-attribute=const \
|
||||
-Wsuggest-attribute=noreturn \
|
||||
-Wsuggest-attribute=format \
|
||||
-Warray-bounds=2 \
|
||||
-Wduplicated-cond \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wbad-function-cast \
|
||||
-Wcast-qual \
|
||||
-Wcast-align \
|
||||
-Wwrite-strings \
|
||||
-Wconversion \
|
||||
-Wjump-misses-init \
|
||||
-Wlogical-op \
|
||||
-Waggregate-return \
|
||||
-Wcast-align \
|
||||
-Wstrict-prototypes \
|
||||
-Wold-style-definition \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-Wpacked \
|
||||
-Wredundant-decls \
|
||||
-Wnested-externs \
|
||||
-Winline \
|
||||
-Winvalid-pch \
|
||||
-Wstack-protector
|
||||
|
||||
TARGETS=remux_example
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
remux_example: remux_example.c \
|
||||
../../videostreamer.c ../../videostreamer.h
|
||||
$(CC) $(CFLAGS) -I../../ -o $@ $< ../../videostreamer.c -lavformat \
|
||||
-lavdevice -lavcodec -lavutil
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
49
cmd/remux_example/remux_example.c
Normal file
49
cmd/remux_example/remux_example.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <videostreamer.h>
|
||||
|
||||
int main(const int argc, const char * const argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
printf("Usage: %s <rtsp URL>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
vs_setup();
|
||||
|
||||
const char * const input_format = "rtsp";
|
||||
const char * const input_url = argv[1];
|
||||
const char * const output_format = "mp4";
|
||||
const char * const output_url = "file:/tmp/out.mp4";
|
||||
const bool verbose = true;
|
||||
|
||||
struct Videostreamer * const vs = vs_open(input_format, input_url,
|
||||
output_format, output_url, verbose);
|
||||
if (!vs) {
|
||||
printf("unable to open videostreamer\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const int max_frames = 100;
|
||||
int i = 0;
|
||||
|
||||
while (1) {
|
||||
const int frame_size = vs_read_write(vs, verbose);
|
||||
if (frame_size == -1) {
|
||||
printf("read/write failed\n");
|
||||
vs_destroy(vs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("frame size %d\n", frame_size);
|
||||
|
||||
i++;
|
||||
if (i == max_frames) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vs_destroy(vs);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user