VLC command to stop recording a stream - command-line

First of all, thanks everyone who is even reading this.
I'm able to save a stream from my IP CAM into a file using the given command (although I'm getting no audio recorded to the file, if anyone can help with that would be great too)
cvlc "http://***.***.*.***:****/videostream.asf?user=admin&pwd=**&rate=12&resolution=32" --run-time=10 --sout="#std{access=file,mux=asf,dst=path\test.asf}" vlc://quit --qt-start-minimized --no-qt-notification
This gives me a 7~8 seconds long recording, but the lenght of the video I want to make will be determined by an external factor (the camera's motion detection alarm). If I remove the "--run-time" it starts recording undefinatelly, so how can I tell VLC that it's time to stop saving the stream?
ps: I want to make this automatic, so I'm only using command line.
ps2: I'm using Ubuntu OS.
Thank you all very much!

I'm by no means and expert on this subject but I am also capturing a live stream to start and stop at specific times. I don't know about the audio issue but here is my code maybe it will help you out somewhat.
at 2014-05-23 10:00
cvlc "http://*My url to video stream*" --sout file/mp4:*THEFILENAMEYOUCHOOSE*.mp4 --run-time=300 --stop-time=300 vlc://quit
Essentially I use the runtime and stop time switches to make sure it stops when I need it to, 300 seconds works out to almost an hour and a half of video so that's plenty for my needs, I'm having some trouble with being able to automatically script this so at this point I'm having to type the commands in by hand to set up the recording which is less than ideal.
Hope this helps you out even a little.

Later but if anyone is looking for the script, this my service in Debian/Ubuntu based compact recorder:
First, I create a bash script in /bin/usr/rec.sh
Put this script there whith sudo nano /usr/bin/rec.sh:
#!/bin/bash
while :
do
raiz=$(date +'/logger/%Y/%m/%d/')
saida=$(date +'/logger/%Y/%m/%d/%H%M%S.opus')
read min sec <<<$(date +'%M %S')
duracao=$((3600 - 10#$min*60 - 10#$sec))
duracao=60
echo "Starting new hour loging..."
echo "$saida"
echo "$duracao"
mkdir -p "$raiz"
vlc **your url here** --no-repeat --no-loop -I dummy --run-time="$duracao" --sout "#transcode{vcodec=none,acodec=opus,ab=64,channels=2,samplerate=48000,afilter=normvol,scodec=none}:std{access=file{no-overwrite},mux=ogg,dst='$saida'}" vlc://quit
echo "Done a hour logged!"
done
Make executable: sudo chmod +x /usr/bin/rec.sh
So, you need create a service Systemd for the script.
sudo nano /lib/systemd/system/rec.service
This sample help you:
[Unit]
Description=URL logger service
[Service]
ExecStart=/usr/bin/rec.sh
[Install]
WantedBy=multi-user.target
Reload systemd:
sudo systemctl daemon-reload
Enable and the service:
sudo systemctl enable shellscript.service
sudo systemctl start shellscript.service
check status:
sudo systemctl status shellscript.service
REMINDER: cvlc don't run as root by default. Here is the trick to do this:
sudo sed -i 's/geteuid/getppid/' /usr/bin/vlc
This service will record the url and transcode audio to OPUS in /logger directory, separated by YEAR / MONTH / DAY / HMS.opus (since record beggining). Each new file is started every hour o'clock.
I hope that help someone.
References:
https://tecadmin.net/run-shell-script-as-systemd-service/
and https://www.tecmint.com/run-vlc-media-player-as-root-in-linux/
Sorry my bad English.

Related

Linux-wget command for certain time

I am using wget command for download in terminal
Is there an option in the wget command that the download starts at a certain date and time?
Thanks
Is there an option in the wget command that the download starts at a certain date and time?
So far I know no, you might use at to launch any command at predefined time. Simple example usage: download https://www.example.com at 12:00
echo "wget https://www.example.com" | at 12:00
Note that you need to activate atd (daemon, see linked article) before using at. If you want to know more about possible ways of specifying time read man page of at.

Importance of the place of CMD in Dockerfile

I have this Dockerfile that works fine, but I was told that maybe it wasn't the best way to do what I wanted :
FROM debian:jessie
RUN apt-get update && apt-get install -y lighttpd php5-cgi php5-common php5 php5-mysql php5-gd
RUN echo server.modules += \(\"mod_rewrite\"\) >> /etc/lighttpd/lighttpd.conf
CMD ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
RUN lighty-enable-mod fastcgi-php
RUN service lighttpd restart
RUN chown -R www-data:www-data /var/www/html
As you can see, I am creating an image for a container with lighttpd and php.
My question is about the place of the CMD part in my Dockerfile. I was told that it was better to put it at the end of the file, but as you can see, I did it in the middle of mine and it worked just fine.
It does not stop the creation nor does it interfere with the service lighttpd restart in the run part below it.
Is there any best practice regarding this or is this normal? Could I create a Dockerfile with my CMD just after the apt-get install?
Thanks for your answers regarding my question and sorry for my english if there is any big mistakes.
I believe it's more of a logical preference, no need to define the command when the image isn't ready yet. There is an added convenience that debugging with the CMD or ENTRYPOINT set to a shell may make debugging a failed build a little easier. But otherwise, the last ENTRYPOINT and/or CMD modifies the config of the image and gets inherited to all child images (each line of your Dockerfile).
It shouldn't matter where you put the CMD entry in terms of Docker using that as the default command (plus Docker will use the last one if there is more than one). Where it might make a difference is if you were trying to structure your build in order to optimize caching the layers. I.e., you want to put anything that is likely to change lower down in the Dockerfile.
I think it's more convention to put it last and makes it easier to read. Is there a specific reason in your case you don't want to put it last?

OSX launchd with su

I have the following script I want to run every hour. I've set up the launchd to run every hour, on the following simple bash script:
sudo perl /Library/WebServer/CGI-Executables/awstats.pl -config=alpha -update
It doesn't run with sudo nor without sudo. I need sudo for the script to work. Not really sure how to get around this.
Any advice appreciated.
Cron jobs in /etc/crontab can run as root, and thus they don't need sudo to run, you just need sudo to edit the file initially.
Try adding your job to /etc/crontab, and if it doesn't work, provide the syntax you used to run it, and the output from attempting to run it from there, showing why it doesn't work.
sudo runs a command as root; Launch Daemons run as root by default, so sudo is unnecessary and irrelevant. If the script is not running as a Launch Daemon, something else is wrong. Check /var/log/system.log for any errors launchd encountered trying to run the script, and maybe capture the script's output by adding something like this to the .plist file:
<key>StandardOutPath</key>
<string>/var/root/awstats.out</string>
<key>StandardErrorPath</key>
<string>/var/root/awstats.err</string>
Also, make sure you're running the script properly. A launchd .plist file doesn't parse commands like a shell command line, it expects you to hand it pre-parsed elements e.g. each command argument as a separate string:
<key>ProgramArguments</key>
<array>
<string>/usr/bin/perl</string>
<string>/Library/WebServer/CGI-Executables/awstats.pl</string>
<string>-config=alpha</string>
<string>-update</string>
</array>

Setting up mongoDB raspberry pi

i just installed mongopi from https://github.com/RickP/mongopi and it working correctly after doing a few adjustments mainly $ sudo chown $USER /data/db. However my mongo and mongod calls arent persistent i do PATH=$PATH:/opt/mongo/bin/ &
export PATH however this does not last on next ssh session. Also how can I make mongo initialize at startup? I did all the steps from the github repo.
For the path part of the question:
To get the path working you should put it in a script that runs every time you log in. Generally there is a rc-file for you shell in your home directory. Type
echo $SHELL
to see what shell you are running. Go to your home directory:
cd
and then open the file that is called .(your shell)rc - that is, if you are running bash, open .bashrc
nano .bashrc
add the path at the end of this file:
PATH=$PATH:/opt/mongo/bin
export PATH
For the initialization part of the question:
Download and edit this script: Mongo init.d at github
You'll need to change the value of the DEAMON at line 50. I had some other troubles, but you should probably be ok if you create a configuration file (that probably could be empty) and refer to it from line 57. Also, you need to add a mongodb user that the server should run as. You can edit this on line 95, but the default is probably a good idea.
When all this editing is done, you move the file to /etc/init.d/mongodb, like so:
sudo mv init.d /etc/init.d/mongodb
and then add it to the systems start-up routine
sudo update-rc.d mongodb defaults
(This is presuming you run debian. Other distros may have other commands to do this.)
Now, see to that you are not running mongod some other place, and control the service by
sudo service mongodb start
service mongodb status
sudo service mongodb stop
... and so on. This will also run automatically on start-up and shutdown.

OpenSuse - Command for Beep Sound (System Bell)

I have a source code that runs perfectly fine on Ubuntu, it does some copumtations, and at some points it beeps like this
system("beep -f 400 -l 500");
On Ubuntu I had to do
apt-get install beep
However, I migrated to OpenSuse (not my choice) and now I get this message "sh: beep: command not found", as the command and package are obviously different.
Does anybody know hot to trigger the system beep sound and define the duration and frequency? I have been able to find only one way to change the parameters
setterm -bfreq 500 -blength 500
, but no way to actually trigger the system bell (beep). The following things don't work
echo ^G
echo -e "\a"
PS - the system Bell is enabled at
Configure Desktop -> Application and System Notifications -> System Bell
and you can actually play with this
So, I did what #fvu proposed.
However, one needs to have sudo rights, to do so, otherwise (e.g. at my work-place we don't have sudo rights) there is this output message
Could not open /dev/tty0 or /dev/vc/0 for writing open: No such file or directory
In this case, you should:
sudo chmod 4755 /usr/bin/beep
as proposed here
I noticed that on my OpenSuse 12.3 system, the bell is working in xterm or gnome-terminal, but not in konsole or xfce4-terminal.
If the same applies to your system, then maybe a work-around could be creating a shell script called "beep" which calls xterm and rings the bell:
#!/bin/sh
xterm -e "echo -e '\a'; sleep 1"