#!/bin/sh
# /media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/video production/capture video  - DrumLib.sh
# www.BillHowell.ca   23Sep2017 based on :  0_vidExtrn - common data, operators.ndf
# For instructions, see /media/bill/VIDEO_PRODN/video capture/0_Howell - video capture instructions.odt

# enter measure in "/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/video production/0_video capture - dimensions.ods"
# Type Ctrl-C to termninate recording

# 24Oct2017 - recordmydesktop DOESN'T capture YouTube videos


# directory where temporary output is written
d_temp="/media/bill/ramdisk/vidTemp/"
mkdir "$d_temp"
#pname_PID_recMyDsk=""
sleep_recrdMyDskTop=4


recrd_start()
{  
echo "Type Ctrl-C to terminate recording"
recordmydesktop -x $xPosn  -y $yPosn  --width $width  --height $height  \
       --v_quality 63  --v_bitrate 2000000 --fps 18  --device pulse  --buffer-size 264620032   \
       -o "$pName"  
}  

# 21Oct2017 I can't capture the audio with recordmydesktop, so I changed from :
#      -v_quality 63  --v_bitrate 2000000 --fps 24  --buffer-size 264620032  \
# 21Oct2017 I added :  -s_quality 8   --device pulse  
# 23Oct2017 I added --channels 2, see https://wiki.archlinux.org/index.php/RecordMyDesktop
# 23Oct2017 I reverted back removing --s_quality 8  
# 24Oct2017 slow playback - since yesterday!!  can't seem to find the problem!
#		go from --fps 24 back to original --fps 24 -> resulted in bad video quality (chunky) probably due to internet
#		BUT audio is still Slow!!  - go back to --fps 18


recrd_start_nosound()
{  
echo "Type Ctrl-C to terminate recording"
recordmydesktop  --no-sound  -x $xPosn  -y $yPosn  --width $width  --height $height  \
       --v_quality 63  --v_bitrate 2000000 --fps 24  --buffer-size 264620032  \
       -o "$pName"  
}  


#        --device pulse   --freq 48000  -o "$pName" 


#********************************
# Neal_Adams specifications on HDMI screen, using half-window
# I can't capture YouTube audio - hence the separate audio play

Neal_Adams()
{
# xPosn		 2.8 cm 
xPosn=110
# yPosn		 6.2
yPosn=232
# width		16.9
width=633
# height 	12.7
height=476
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_Neal_Adams_vid/"
cd "$dir_video_out"
fname="ExpandEarth - Neal Adams video"
pName="$dir_video_out""$fname"
recrd_start
}


# $ aplay "/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_Neal_Adams_vid/z_Old/ExpanEarth - Neal Adams audio.wav"

#********************************
# Neal_Adams blend audio & video via recordmydesktop
# I can't capture YouTube audio - hence the separate audio record&play process

Neal_Adams_blend_av()
{
# xPosn		 0.2 cm 
xPosn=7
# yPosn		 2.2
yPosn=83
# width		17.6
width=659
# height 	12.9
height=487
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_Neal_Adams_vid/"
cd "$dir_video_out"
fname="ExpandEarth - Neal Adams blend av"
pName="$dir_video_out""$fname"
#manually startup & run video "21 ExpanEarth - Neal Adams video 10m04s.ogv"
recrd_start   & 
aplay "$dir_video_out""z_Old/20 ExpanEarth - Neal Adams video - audio 10m04s.wav" 
}

# to terminate - in separate terminal :
# use System Monitor to get ID_recordmydesktop
# $ kill  -SIGTERM  ID_recordmydesktop  

# eg   $ kill -SIGTERM  7563

# test  $ aplay "/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_Neal_Adams_vid/z_Old/20 ExpanEarth - Neal Adams video - audio 10m04s.wav" & 
# Ctrl-C to end

#********************************
# Neal_Adams_pics images [ComiCons, Batman, Green Lantern


Neal_Adams_pics()
{
# xPosn		 0   cm
xPosn=0
# yPosn		 4   cm
yPosn=122
# width		23.0 cm
width=745
# height		37.6 cm
height=892
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_Neal_Adams_vid/"
cd "$dir_video_out"
fname="ExpandEarth - Neal Adams comic conferences 2017"
pName="$dir_video_out""$fname"
recrd_start
}


#********************************
# Confabulation specifications on HDMI screen, using half-window


Confabulation_next_sentence()
{
# xPosn  -> 1920 pixels/ 60   cm *  2.8 = 108 
xPosn=75
# yPosn  -> 1080 pixels/ 34.5 cm *  4.3 = 135
yPosn=140
# width  -> 1920 pixels/ 60   cm * 24.2 = 929
width=750
# height -> 1080 pixels/ 34.5 cm * 11.5 = 360
#height=355
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/Confabulation theory/"
cd "$dir_video_out"
fname="Confabulation next sentence"
pName="$dir_video_out""$fname"
recrd_start
}


#********************************
# Hearing_aids specifications on HDMI screen, using half-window
# enter measure in "/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/video production/0_video capture - dimensions.ods"



Hearing_aids()
{
# Second recording : 4 images over 02:04 =  31 seconds/image
#  @ 31s/image ->  0, 31, 62 (01:02), 93(01:33), stop @ 124 (02:04)  
# xPosn    0.2 cm
xPosn=7
# yPosn    1.8 cm
yPosn=45
# width   20.2 cm
width=756
# height  19.2 cm
height=691
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/Hearing_aids/"
cd "$dir_video_out"
fname="Hearing_aids images"
pName="$dir_video_out""$fname"
recrd_start_nosound
}


# Second recording : 4 images over 02:04 =  31 seconds/image
#  @ 31s/image ->  0, 31, 62 (01:02), 93(01:33), stop @ 124 (02:04)  


Hearing_aids_easy()
{
# xPosn    0.5 cm
xPosn=23
# yPosn    6.4 cm
yPosn=245
# width   23.8 cm
width=893
# height  18.2 cm
height=665
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/Hearing_aids/"
cd "$dir_video_out"
fname="Wang demos easy"
pName="$dir_video_out""$fname"
recrd_start_nosound
}


#********************************
# Continental_drift specifications on HDMI screen, using half-window
#Full YouTube window!


Continental_drift()
{
# xPosn  		 1.5 cm 
xPosn=50
# yPosn  		 6.3 cm
yPosn=200
# width  		23.7 cm
width=839
# height 		15.0 cm
height=475
dir_video_out="/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/Scenes/ExpandEarth_description/"
cd "$dir_video_out"
fname="Continental drift - Michael Sammartano video"
pName="$dir_video_out""$fname"
arecord -t wav -r 19200 "$fname"".wav"
recrd_start
}


#********************************
# list of video captures 

#Confabulation_next_sentence
#Continental_drift
#Hearing_aids
#Hearing_aids_easy
#Neal_Adams
Neal_Adams_blend_av
#Neal_Adams_pics



# to run  $ bash "/media/bill/ATA_WDC_500G/Video production/170930 DrumLibrary - kids science/video production/capture video  - DrumLib.sh"




# enddoc