screen recording per command line, i.e. bash-script

macOS specific usage questions
rohuezo
Blank Cone
Blank Cone
Posts: 29
Joined: 18 Jul 2013 08:50
VLC version: 2.0.8 Win/2.2.2 Mac
Operating System: Windows / Mac OS X
Location: Fürth, Germany

screen recording per command line, i.e. bash-script

Postby rohuezo » 21 Feb 2016 20:41

Hi guys,

I'm trying to start the screen recording feature of VLC media player using the command line under MacOS X (10.11.3, El Capitan) using a bash-script. I have accomplished this using the Windows version of VLC media player (2.0.8) and I'm now trying with VLC media player (2.2.2) under MacOSX. I'm using the following bash-script and it works, but not as I wanted/intend to do. Here is my script:

Code: Select all

#!/bin/bash #Filename parameters TIMESTAMP=$(date +%Y%m%d-%H%M%S) EXT="mp4" # Screen parameters #screen 1 1280 800 #screen 2 1600x1200 SCREENINDEX="1" SCREENWIDTH="1280" SCREENHEIGHT="800" SCREENTOP="0" SCREENLEFT="0" # Transcode parameters TRANSCODEVENC="x264" TRANSCODEVCODEC="h264" TRANSCODESCALE="1" TRANSCODEFPS="25" TRANSCODEVB="1024" # Standard parameters STANDARDACCESS="file" STANDARDMUX="mp4" STANDARDFILENAME="vlc-record-$TIMESTAMP-screen__""$SCREENWIDTH""x""$SCREENHEIGHT""_$TRANSCODEFPS""fps_$TRANSCODEVB""kb.$EXT" STANDARDPATH="/Users/rohuezo/Movies/vlc-output/$STANDARDFILENAME" # Command parameters VLCEXE="/Applications/VLC.app/Contents/MacOS/VLC" VLCDEVICE="screen://" #VLCINTF="-I dummy $@" VLCINTF="-I rc $@ --telnet-host 127.0.0.1 --telnet-port 81" VLCDEFAULTS="" VLCSCREEN="--screen-index $SCREENINDEX --screen-width $SCREENWIDTH --screen-height $SCREENHEIGHT --screen-top $SCREENTOP --screen-left $SCREENLEFT" VLCSTANDARD=":standard{mux=$STANDARDMUX,access=$STANDARDACCESS{no-overwrite},dst=$STANDARDPATH}" VLCTRANSCODE=":sout=#transcode{vcodec=$TRANSCODEVCODEC,vb=$TRANSCODEVB,scale=$TRANSCODESCALE,fps=$TRANSCODEFPS,acodec=none}" VLCCOMMAND="$VLCEXE $VLCDEVICE $VLCINTF $VLCDEFAULTS $VLCSCREEN $VLCTRANSCODE$VLCSTANDARD" echo "Calling: $VLCCOMMAND" exec $VLCCOMMAND
The variable

Code: Select all

#VLCINTF="-I dummy $@" VLCINTF="-I rc $@ --telnet-host 127.0.0.1 --telnet-port 81"

, doesn't matter which one, above is the line I believe is not working as I expect it. As in the Windows version I would expect that the remote control interface under MacOSX would start listening on host 127.0.0.1 port 81 and if I telnet to that host and port I could send the

Code: Select all

quit
command which will stop the screen recording. Here is the command line output after executing my script:

Code: Select all

MacBookPro13:ScreenRecordingScripts rohuezo$ ./ScreenRecording.sh Calling: /Applications/VLC.app/Contents/MacOS/VLC screen:// -I rc --telnet-host 127.0.0.1 --telnet-port 81 --screen-index 1 --screen-width 1280 --screen-height 800 --screen-top 0 --screen-left 0 :sout=#transcode{vcodec=h264,vb=1024,scale=1,fps=25,acodec=none}:standard{mux=mp4,access=file{no-overwrite},dst=/Users/rohuezo/Movies/vlc-output/vlc-record-20160221-203010-screen__1280x800_25fps_1024kb.mp4} VLC media player 2.2.2 Weatherwax (revision 2.2.2-3-gf8c9253) [0000000100604218] core interface error: no suitable interface module [000000010022cf78] core libvlc error: interface "oldrc,none" initialization failed [00000001006041e8] core interface error: no suitable interface module [000000010022cf78] core libvlc error: interface "(null),none" initialization failed [0000000100708ca8] [cli] lua interface: Listening on host "*console". VLC media player 2.2.2 Weatherwax Command Line Interface initialized. Type `help' for help. > [00000001008758b8] x264 encoder: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [00000001008758b8] x264 encoder: profile High, level 3.2 [00000001008758b8] x264 encoder: final ratefactor: 28,61 [00000001006051e8] stream_out_transcode stream out: input interval 100000 (base 1) [00000001006051e8] stream_out_transcode stream out: output interval 40000 (base 1) [00000001008758b8] x264 encoder: using SAR=1/1 [00000001008758b8] x264 encoder: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [00000001008758b8] x264 encoder: profile High, level 3.2
The output file is created and the screen recording begins. But the only way to stop it is by pressing

Code: Select all

Ctrl-C
When I do that I get the following output added to the one above:

Code: Select all

^C[0000000100708ca8] [cli] lua interface error: Error loading script /Applications/VLC.app/Contents/MacOS/share/lua/intf/cli.luac: ...kage/macosx/../../../share/lua/intf/modules/host.lua:279: Interrupted. [00000001008758b8] x264 encoder: frame I:3 Avg QP:16,31 size:253710 [00000001008758b8] x264 encoder: frame P:162 Avg QP:16,61 size: 6617 [00000001008758b8] x264 encoder: frame B:453 Avg QP:15,10 size: 216 [00000001008758b8] x264 encoder: consecutive B-frames: 1,8% 1,3% 0,5% 96,4% [00000001008758b8] x264 encoder: mb I I16..4: 35,0% 10,8% 54,2% [00000001008758b8] x264 encoder: mb P I16..4: 0,7% 0,4% 0,8% P16..4: 6,6% 0,6% 0,5% 0,0% 0,0% skip:90,4% [00000001008758b8] x264 encoder: mb B I16..4: 0,1% 0,1% 0,0% B16..8: 3,6% 0,0% 0,0% direct: 0,0% skip:96,2% L0:31,7% L1:68,2% BI: 0,1% [00000001008758b8] x264 encoder: final ratefactor: 16,94 [00000001008758b8] x264 encoder: 8x8 transform intra:17,8% inter:48,7% [00000001008758b8] x264 encoder: coded y,uvDC,uvAC intra: 35,6% 46,5% 41,2% inter: 0,7% 1,3% 0,8% [00000001008758b8] x264 encoder: i16 v,h,dc,p: 48% 47% 4% 0% [00000001008758b8] x264 encoder: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 18% 46% 1% 1% 1% 2% 0% 2% [00000001008758b8] x264 encoder: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 30% 12% 2% 5% 4% 7% 3% 5% [00000001008758b8] x264 encoder: i8c dc,h,v,p: 49% 37% 12% 2% [00000001008758b8] x264 encoder: Weighted P-Frames: Y:0,0% UV:0,0% [00000001008758b8] x264 encoder: ref P L0: 87,9% 3,5% 7,1% 1,5% [00000001008758b8] x264 encoder: ref B L0: 44,9% 54,3% 0,8% [00000001008758b8] x264 encoder: ref B L1: 96,8% 3,2% [00000001008758b8] x264 encoder: kb/s:624,85 MacBookPro13:ScreenRecordingScripts rohuezo$
The output file is a correct recording of the screen. My problem is that this way I cannot use scripts to stop the recording when unattended, e.g. overnight integrated tests, etc.

Does anyone know how to set up the remote control under MacOSX for the command line so I can telnet to it to control it? Any help will be greatly appreciated.

Best regards,
--
Roberto Huezo, M.A.
Computational Linguist
Software Developer

rohuezo
Blank Cone
Blank Cone
Posts: 29
Joined: 18 Jul 2013 08:50
VLC version: 2.0.8 Win/2.2.2 Mac
Operating System: Windows / Mac OS X
Location: Fürth, Germany

Re: screen recording per command line, i.e. bash-script

Postby rohuezo » 22 Feb 2016 21:25

Ok, found the answer/solution to my problem. Here is my bash script which will start a screen recording and will create a unix socket instead of a telnet connection:

Code: Select all

#!/bin/bash # Filename parameters TIMESTAMP=$(date +%Y%m%d-%H%M%S) EXT="mp4" # Screen parameters #screen 1 1280 800 #screen 2 1600x1200 SCREENINDEX="1" SCREENWIDTH="1280" SCREENHEIGHT="800" SCREENTOP="0" SCREENLEFT="0" # Transcode parameters TRANSCODEVENC="x264" TRANSCODEVCODEC="h264" TRANSCODESCALE="1" TRANSCODEFPS="25" TRANSCODEVB="1024" # Standard parameters STANDARDACCESS="file" STANDARDMUX="mp4" STANDARDFILENAME="vlc-record-$TIMESTAMP-screen__""$SCREENWIDTH""x""$SCREENHEIGHT""_$TRANSCODEFPS""fps_$TRANSCODEVB""kb.$EXT" STANDARDPATH="/Users/rohuezo/Movies/vlc-output/$STANDARDFILENAME" # Command parameters VLCEXE="/Applications/VLC.app/Contents/MacOS/VLC" VLCDEVICE="screen://" VLCINTF="-I rc --rc-unix /Users/rohuezo/vlc.sock" VLCSCREEN="--screen-index $SCREENINDEX --screen-width $SCREENWIDTH --screen-height $SCREENHEIGHT --screen-top $SCREENTOP --screen-left $SCREENLEFT" VLCSTANDARD=":standard{mux=$STANDARDMUX,access=$STANDARDACCESS{no-overwrite},dst=$STANDARDPATH}" VLCTRANSCODE=":sout=#transcode{vcodec=$TRANSCODEVCODEC,vb=$TRANSCODEVB,scale=$TRANSCODESCALE,fps=$TRANSCODEFPS,acodec=none}" VLCCOMMAND="$VLCEXE $VLCDEVICE $VLCINTF $VLCSCREEN $VLCTRANSCODE$VLCSTANDARD" echo "Calling: $VLCCOMMAND" exec $VLCCOMMAND
then I have another bash script that sends the quit signal with a pipe command:

Code: Select all

echo quit | nc -U /Users/rohuezo/vlc.sock
ending the recording per script and saving the file specified in the command line.

Important was the line:

Code: Select all

VLCINTF="-I rc --rc-unix /Users/rohuezo/vlc.sock"
For some reason the sockets work instead of telnet. I read on another thread here in the forum that telnet in MacOS X is very "buggy"!
--
Roberto Huezo, M.A.
Computational Linguist
Software Developer

ajmas
Big Cone-huna
Big Cone-huna
Posts: 935
Joined: 04 Feb 2006 07:33
VLC version: 3.0.x
Operating System: MacOS X
Location: Montreal, Canada

Re: screen recording per command line, i.e. bash-script

Postby ajmas » 25 Feb 2016 21:52

You may even want to look at ssh instead of telnet, if you are executing from a command line. For example, you can do:

Code: Select all

ssh user@host 'remote command to execute'
I can't comment on the health level of the MacOS implementation of telnet, since I haven't used it in a while and instead prefer ssh for remote execution, since it is more secure for credentials.
Providing logs, messages, configuration info (VLC, OS, Hardware) and a clear explanation of the issue always helps the problem solvers help you, even if they don't end up solving the issue. Just think what you would need if you were solving someone else's problem. Additional: Always looking for eager and capable MacOS X developers to join the VLC team - for more information see here.

rohuezo
Blank Cone
Blank Cone
Posts: 29
Joined: 18 Jul 2013 08:50
VLC version: 2.0.8 Win/2.2.2 Mac
Operating System: Windows / Mac OS X
Location: Fürth, Germany

Re: screen recording per command line, i.e. bash-script

Postby rohuezo » 25 Feb 2016 22:57

Hi ajmas,

do you mean ssh as -I interface? I will try to find out the ssh way of connecting. I always thought telnet was not to secure... Thanks for the tip!

Regards,
--
Roberto Huezo, M.A.
Computational Linguist
Software Developer

ajmas
Big Cone-huna
Big Cone-huna
Posts: 935
Joined: 04 Feb 2006 07:33
VLC version: 3.0.x
Operating System: MacOS X
Location: Montreal, Canada

Re: screen recording per command line, i.e. bash-script

Postby ajmas » 26 Feb 2016 21:58

What I meant is to 'ssh'ing into the host machines and then run your scripts there. Running ssh as indicated will ssh into the host run the command and then exit. An example, which leverages Applescript (I specified the absolute path, since I have multiple VLC installs and it was getting confused about which instance to use).

Code: Select all

ssh localhost "osascript -e 'tell application \"/Applications/VLC.app\" to quit'"
BTW I don't have enough experience with VLC's telnet interface to provide help there, which is the other reason, beyond security, for suggesting an alternative approach.

Edit: Just played around with the telnet interface and it would appear to be 'shutdown' is the command to send to quit VLC, whereas 'quit' will simply quit the telnet connection. You can see the available commands by typing 'help' in the telnet interface.
Providing logs, messages, configuration info (VLC, OS, Hardware) and a clear explanation of the issue always helps the problem solvers help you, even if they don't end up solving the issue. Just think what you would need if you were solving someone else's problem. Additional: Always looking for eager and capable MacOS X developers to join the VLC team - for more information see here.

rohuezo
Blank Cone
Blank Cone
Posts: 29
Joined: 18 Jul 2013 08:50
VLC version: 2.0.8 Win/2.2.2 Mac
Operating System: Windows / Mac OS X
Location: Fürth, Germany

Re: screen recording per command line, i.e. bash-script

Postby rohuezo » 27 Feb 2016 19:21

Now I understand what you mean ajmas! Thanks for the tip and the example! I will give it a try.

Concerning telnet, I can't really tell you why the command 'quit' works for me (under Windows!). Here is the little VBScript I use to telnet to VLC listening on 127.0.0.1:81

Code: Select all

<job> <script language="VBScript"> Option Explicit On Error Resume Next Dim WshShell set WshShell=CreateObject("WScript.Shell") WshShell.run "cmd.exe" WScript.Sleep 1000 'Send commands to the window as needed - IP and commands need to be customized 'Step 1 - Telnet to remote IP WshShell.SendKeys "telnet 127.0.0.1 81" WshShell.SendKeys ("{Enter}") WScript.Sleep 1000 'Step 2 - Stop VLC Recording WshShell.SendKeys "quit" WshShell.SendKeys ("{Enter}") WScript.Sleep 3000 'Step 3 - Exit Command Window WshShell.SendKeys " exit" '' <-- Important, empty space before exit! WshShell.SendKeys ("{Enter}") WScript.Sleep 1000 WScript.Quit </script> </job>
Here is the output after the telnet command:

Image

Step 1: connects to telnet

Step 2: send 'quit' to stop VLC from recording and terminate the file correctly

Step 3: send ' exit' to exit telnet

Regards,
--
Roberto Huezo, M.A.
Computational Linguist
Software Developer


Return to “VLC media player for macOS Troubleshooting”

Who is online

Users browsing this forum: No registered users and 11 guests