So konvertieren Sie ein Skript mithilfe von Pipelines in Named Pipes

645
Nova deViator

Ich habe ein Bash-Skript, das anonyme Pipes verwendet, um Folgendes zu erreichen:

  • Video von DV-Capture-Gerät
  • in eine Datei schreiben (mit Tee)
  • es an ffmpeg2theora leiten (in ogv / theora-video konvertieren)
  • in eine Datei schreiben (mit Tee)
  • Leiten Sie es an oggfwd, um es an den Icecast Streaming Server zu senden

Wie kann ich das mit Named Pipes (Fifos) erreichen, damit ich separate Prozesse haben kann, die ich separat steuern kann?

Ich habe dieses Skript benutzt:

 #!/bin/bash while (true);  do dvgrab --format dv1 - | \ tee /filename_`date +%y%m%d_%H%M%S`.dv | \ ffmpeg2theora.linux -f dv -x 382 -y 288 -v 3 --speedlevel 2 --no-skeleton -o /dev/stdout - | \ tee /filename_`date +%y%m%d_%H%M%S`_stream_382x288.ogv | \ oggfwd icecastserver.com 8000 password /mountpoint.ogv done 

Einer der Gründe, warum ich dies frage, ist, dass ich saubere DV-Dateien und OVV-Dateien auf der Festplatte haben muss, unabhängig davon, ob das Netzwerk aktiv ist und der Icecast-Streaming-Server erreichbar ist.

2

1 Antwort auf die Frage

1
RedGrittyBrick

You can probably do this with ordinary files if your don't need any concurrency at all. The principle for named pipes is the same

Change

foo | \ bar | \ baz 

To

foo > foo.out bar < foo.out > bar.out baz < bar.out 

If the *.out are named pipes then I suspect the programs writing to them may get blocked waiting for their output buffers to be drained.