Projects
home:jnweiger
dvswitch-git
dvsource-command.diff
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File dvsource-command.diff of Package dvswitch-git
--- doc/CMakeLists.txt | 1 doc/README | 1 doc/dvsource-dvgrab.1 | 12 +++++++++++ src/CMakeLists.txt | 1 src/dvsource-dvgrab.c | 54 +++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 64 insertions(+), 5 deletions(-) Index: dvswitch-0.9-1-da15ba4/doc/dvsource-dvgrab.1 =================================================================== --- dvswitch-0.9-1-da15ba4.orig/doc/dvsource-dvgrab.1 +++ dvswitch-0.9-1-da15ba4/doc/dvsource-dvgrab.1 @@ -9,18 +9,30 @@ dvsource-dvgrab \- Firewire and Video4Li .RB [ \-c .IR CARD-NUMBER " | " DEVICE ] .HP .B dvsource-v4l2-dv .RI [ OPTIONS "] [" DEVICE ] +.HP +.B dvsource-command +.RI "[ '" FFMPEG_COMMAND "' ]" .SH DESCRIPTION .LP \fBdvsource-firewire\fR uses \fBdvgrab\fR(1) to stream from a DV device (camera or VCR) connected by Firewire. .LP \fBdvsource-v4l2-dv\fR uses \fBdvgrab\fR(1) to stream from a DV device that has a Video4Linux2 driver. This includes most USB DV cameras if you have the uvcvideo driver installed. +.LP +\fBdvsource-command\fR uses a user provided command to create a virtual DV stream +from any device. The command may consist of multiple arguments, if so it must be quoted +as a single shell argument. The default command takes audio from the first +soundcard (builtin microphone) and video from the first video device. +If your webcam is \fB/dev/video0\fR and has its own mono microphone, this +command might work: +.br +\fB'ffmpeg -v quiet -f alsa -ac 1 -i hw:1 -f v4l2 -i /dev/video0 -target pal-dv pipe:1'\fR .SH OPTIONS \fB\-t\fR, \fB\-\-tally\fR .RS Print notices of activation and deactivation in the mixer, for use with a tally light. These will take the form "TALLY: on" or "TALLY: Index: dvswitch-0.9-1-da15ba4/doc/README =================================================================== --- dvswitch-0.9-1-da15ba4.orig/doc/README +++ dvswitch-0.9-1-da15ba4/doc/README @@ -20,10 +20,11 @@ limited length, DVswitch is divided into that can run on different computers on a TCP/IP network: - dvswitch: the mixer GUI and network server - dvsource-firewire: source that connects to a DV camera via Firewire - dvsource-v4l2-dv: source that connect to a DV camera via V4L2, useful for USB +- dvsource-command: source from any V4L2 device, via e.g. ffmpeg -target pal-dv. - dvsource-file: source that reads a raw DV (DIF) file - dvsource-alsa: source that captures audio through ALSA - dvsink-files: sink that writes the mixed stream to raw DV files - dvsink-command: sink that runs a command with the mixed stream as its standard input Index: dvswitch-0.9-1-da15ba4/doc/CMakeLists.txt =================================================================== --- dvswitch-0.9-1-da15ba4.orig/doc/CMakeLists.txt +++ dvswitch-0.9-1-da15ba4/doc/CMakeLists.txt @@ -6,5 +6,6 @@ install(FILES README DESTINATION ${docdir}/dvswitch) install(FILES ${manpages} DESTINATION ${mandir}/man1) install_symlink(dvsource-dvgrab.1 "${mandir}/man1/dvsource-firewire.1") install_symlink(dvsource-dvgrab.1 "${mandir}/man1/dvsource-v4l2-dv.1") +install_symlink(dvsource-dvgrab.1 "${mandir}/man1/dvsource-command.1") Index: dvswitch-0.9-1-da15ba4/src/dvsource-dvgrab.c =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/dvsource-dvgrab.c +++ dvswitch-0.9-1-da15ba4/src/dvsource-dvgrab.c @@ -21,10 +21,11 @@ static struct option options[] = { {"card", 1, NULL, 'c'}, {"guid", 1, NULL, 'g'}, {"firewire", 0, NULL, 'F'}, {"v4l2", 0, NULL, 'V'}, + {"command", 0, NULL, 'C'}, {"host", 1, NULL, 'h'}, {"port", 1, NULL, 'p'}, {"tally", 0, NULL, 't'}, {"verbose", 0, NULL, 'v'}, {"help", 0, NULL, 'H'}, @@ -33,10 +34,11 @@ static struct option options[] = { enum mode { mode_unknown, mode_firewire, mode_v4l2, + mode_command, }; static enum mode mode = mode_unknown; static char * device_name = NULL; static char * firewire_card = NULL; @@ -55,10 +57,12 @@ static enum mode program_mode(const char if (strcmp(progname, "dvsource-firewire") == 0) return mode_firewire; if (strcmp(progname, "dvsource-v4l2-dv") == 0) return mode_v4l2; + if (strcmp(progname, "dvsource-command") == 0) + return mode_command; return mode_unknown; } static void handle_config(const char * name, const char * value) { @@ -92,23 +96,27 @@ static void handle_config(const char * n static void usage(const char * progname) { static const char firewire_args[] = "[-c CARD-NUMBER | DEVICE] [-g GUID]"; static const char v4l2_args[] = "[DEVICE]"; + static const char cmd_args[] = "['ffmpeg -v quiet -f alsa -ac 1 -i hw:1 -f v4l2 -i /dev/video0 -target pal-dv pipe:1']"; static const char other_args[] = "[-t] [-v] [-h HOST] [-p PORT]"; switch (program_mode(progname)) { case mode_unknown: fprintf(stderr, "Usage: %s %s \\\n" " --firewire %s\n" " %s %s \\\n" - " --v4l2 %s\n", + " --v4l2 %s\n" + " %s %s \\\n" + " --command %s\n", progname, other_args, firewire_args, - progname, other_args, v4l2_args); + progname, other_args, v4l2_args, + progname, other_args, cmd_args); break; case mode_firewire: fprintf(stderr, "Usage: %s %s \\\n" " %s\n", @@ -118,10 +126,16 @@ static void usage(const char * progname) fprintf(stderr, "Usage: %s %s \\\n" " %s\n", progname, other_args, v4l2_args); break; + case mode_command: + fprintf(stderr, + "Usage: %s %s \\\n" + " %s\n", + progname, other_args, cmd_args); + break; } } static ssize_t read_retry(int fd, void * buf, size_t count) { @@ -177,11 +191,11 @@ int main(int argc, char ** argv) dvswitch_read_config(handle_config); /* Parse arguments. */ int opt; - while ((opt = getopt_long(argc, argv, "c:g:h:p:tv", options, NULL)) != -1) + while ((opt = getopt_long(argc, argv, "c:g:h:p:tvFVC", options, NULL)) != -1) { switch (opt) { case 'c': free(firewire_card); @@ -195,10 +209,13 @@ int main(int argc, char ** argv) mode = mode_firewire; break; case 'V': mode = mode_v4l2; break; + case 'C': + mode = mode_command; + break; case 'h': free(mixer_host); mixer_host = strdup(optarg); break; case 'p': @@ -252,15 +269,22 @@ int main(int argc, char ** argv) } else if (mode == mode_v4l2) { if (!device_name) device_name = "/dev/video"; - printf("INFO: Reading from V4L2 device %s\n", device_name); + printf("INFO: Reading from V4L2 device %s (DV mode)\n", device_name); + } + else if (mode == mode_command) + { + // FIXME: would it work without audio? + if (!device_name) + device_name = "ffmpeg -v quiet -f alsa -ac 2 -i hw:0 -f v4l2 -i /dev/video0 -target pal-dv pipe:1"; + printf("INFO: Running command: %s\n", device_name); } else { - fprintf(stderr, "%s: mode not defined (Firewire or V4L2)\n", argv[0]); + fprintf(stderr, "%s: mode not defined (Firewire, V4L2, or Command)\n", argv[0]); return 2; } /* Connect to the mixer. */ @@ -290,10 +314,30 @@ int main(int argc, char ** argv) tally(sock); _exit(0); } } + if (mode == mode_command) + { + // run a command, e.g. ffmpeg + if (verbose) + { + printf("INFO: Running %s\n", device_name); + } + + if (dup2(sock, STDOUT_FILENO) < 0) + { + perror("ERROR: dup2"); + return 1; + } + close(sock); + + execlp("/bin/sh", "/bin/sh", "-c", device_name, NULL); + perror("ERROR: execlp"); + return 1; + } + /* Run dvgrab with the socket as stdout. */ char * dvgrab_argv[9]; char ** argp = dvgrab_argv; *argp++ = "dvgrab"; Index: dvswitch-0.9-1-da15ba4/src/CMakeLists.txt =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/CMakeLists.txt +++ dvswitch-0.9-1-da15ba4/src/CMakeLists.txt @@ -50,5 +50,6 @@ install(TARGETS dvsink-command dvsink-fi if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") install(TARGETS dvsource-alsa DESTINATION ${bindir}) endif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") install_symlink(dvsource-dvgrab "${bindir}/dvsource-firewire") install_symlink(dvsource-dvgrab "${bindir}/dvsource-v4l2-dv") +install_symlink(dvsource-dvgrab "${bindir}/dvsource-command")
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.