Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nickorzha committed Dec 31, 2016
0 parents commit a2b54be
Show file tree
Hide file tree
Showing 7 changed files with 1,758 additions and 0 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions cmd/remux_example/Makefile
Original file line number Diff line number Diff line change
@@ -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 changes: 49 additions & 0 deletions cmd/remux_example/remux_example.c
Original file line number Diff line number Diff line change
@@ -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;
}
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Now playing</title>

<meta name="viewport" content="width=device-width, user-scalable=no">

<style>
video {
max-width: 100%;
}
</style>

<h1>Now playing</h1>

<!--src="http://127.0.0.1:8081/stream" -->
<!-- src="out.mp4" -->
<video
src="http://127.0.0.1:8081/stream"
autoplay
controls
></video>
Loading

0 comments on commit a2b54be

Please sign in to comment.