Skip to content

Commit

Permalink
#3 Added config file
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Dec 22, 2015
1 parent 980749b commit 45c294c
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,6 +7,6 @@ before_script:
- gem install mdl

script:
- shellcheck --shell=bash ffscreencast
- shellcheck --shell=bash bin/ffscreencast
- mdl -c .mdlrc README.md

3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,8 @@ CHANGELOG
Version 0.7 (unreleased)
-----------

- none yet
- [Enh] Added config file in ~/.config/ffscreencast/ffscreencastrc
- [Enh] Faster bootstrap with cache variables


Version 0.6
Expand Down
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -19,7 +19,7 @@

Besides that `ffscreencast` can act as an ffmpeg command generator. Every available option can also just show the corresponding ffmpeg command instead of executing it. Non-ffmpeg commands, such as how the camera resolution is pulled and others can also be shown instead of being executed.

![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/img/ffscreencast.png)
![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/doc/img/ffscreencast.png)

**Supported platforms**

Expand All @@ -40,6 +40,7 @@ Besides that `ffscreencast` can act as an ffmpeg command generator. Every availa

## 1. Features

* Config file for default configuration
* Screen recording
* Camera overlay
* Audio support
Expand Down Expand Up @@ -189,8 +190,8 @@ ffmpeg -hide_banner -loglevel info -f avfoundation -i "1" -f avfoundation -i
Showing screen recording with and without camera overlay.
![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/img/ffscreencast.png)
![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/img/ffscreencast2.png)
![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/doc/img/ffscreencast.png)
![Screencast](https://raw.githubusercontent.com/cytopia/ffscreencast/master/doc/img/ffscreencast2.png)
## 4. Todo
Expand Down
139 changes: 113 additions & 26 deletions ffscreencast → bin/ffscreencast
Expand Up @@ -17,9 +17,9 @@

INFO_AUTHOR="Patrick Plocke <patrick@plocke.de>"
INFO_GPGKEY="0x28BF179F"
INFO_DATE="2015-12-21"
INFO_DATE="2015-12-22"
INFO_LICENSE="MIT"
INFO_VERSION="0.6"
INFO_VERSION="0.7-beta"
INFO_NAME="ffscreencast"


Expand Down Expand Up @@ -137,6 +137,73 @@ isint() {
printf '%d' "$1" >/dev/null 2>&1 && return 0 || return 1;
}

################################################################################
# Config
################################################################################

write_config() {

local dir
local conf
dir="${HOME}/.config/ffscreencast"
conf="${dir}/ffscreencastrc"

if [ ! -f "${conf}" ]; then
if [ ! -d "${dir}" ]; then
$(which mkdir) -p "${dir}"
fi

echo "# ~/.config/ffscreencast/ffscreencastrc" > "${conf}"
echo >> "${conf}"

echo "# Default video container extension" >> "${conf}"
echo "# Alternatively: 'mp4' or 'avi'" >> "${conf}"
echo "OUTPUT_EXT=\"mkv\"" >> "${conf}"
echo >> "${conf}"

echo "# Default audio output codec" >> "${conf}"
echo "# Alternatively: 'pcm_s16le'" >> "${conf}"
echo "OUTPUT_ACODEC=\"libfaac\"" >> "${conf}"
echo >> "${conf}"

echo "# Default video output codec" >> "${conf}"
echo "# Alternatively: 'libx265'" >> "${conf}"
echo "OUTPUT_VCODEC=\"libx264\"" >> "${conf}"
echo >> "${conf}"


echo "# Default Screen recording arguments" >> "${conf}"
echo "S_ARGS=\"\"" >> "${conf}"
echo >> "${conf}"

echo "# Default audio recording arguments" >> "${conf}"
echo "A_ARGS=\"-ac 2\"" >> "${conf}"
echo >> "${conf}"

echo "# Default camera recording arguments" >> "${conf}"
echo "C_ARGS=\"\"" >> "${conf}"
echo >> "${conf}"

echo "# Default misc output arguments" >> "${conf}"
echo "O_ARGS=\"-crf 0 -preset ultrafast\"" >> "${conf}"
echo >> "${conf}"

echo "# Default recording behavior" >> "${conf}"
echo "RECORD_S=\"yes\"" >> "${conf}"
echo "RECORD_A=\"no\"" >> "${conf}"
echo "RECORD_C=\"no\"" >> "${conf}"
echo >> "${conf}"

echo "# What listed device number has been chosen to record?" >> "${conf}"
echo "CHOSEN_S_NUM=\"\"" >> "${conf}"
echo "CHOSEN_A_NUM=\"\"" >> "${conf}"
echo "CHOSEN_C_NUM=\"\"" >> "${conf}"
echo >> "${conf}"
fi

}



################################################################################
# Info Function
Expand Down Expand Up @@ -323,38 +390,50 @@ print_requirements() {
################################################################################
# Requirements
################################################################################

_CACHE_CAN_USE_OS="no"
can_run_on_os() {
if [ "${UNAME}" != "Linux" ] && [ "${UNAME}" != "Darwin" ]; then
# Nope
return "${EXIT_ERR}"
else
# Good :-)
if [ "${_CACHE_CAN_USE_OS}" = "yes" ]; then
return "${EXIT_OK}"
fi
}

can_use_ffmpeg() {
if [ "${UNAME}" = "Darwin" ]; then
if ! ${FFMPEG} -f avfoundation -list_devices true -i "" 2>&1 | $GREP 'AVFoundation input device' > /dev/null 2>&1; then
# Nope, no AVFoundation found in ffmpeg
return "${EXIT_ERR}"
else
# All good :-)
return "${EXIT_OK}"
fi
elif [ "${UNAME}" = "Linux" ]; then
if ! ${FFMPEG} -version 2>&1 | $GREP '\-\-enable-x11grab' > /dev/null 2>&1; then
# Nope, no x11grab found in ffmpeg
else
if [ "${UNAME}" != "Linux" ] && [ "${UNAME}" != "Darwin" ]; then
# Nope
return "${EXIT_ERR}"
else
# All good :-)
# Good :-)
_CACHE_CAN_USE_OS="yes"
return "${EXIT_OK}"
fi
fi
}

# Hmm, no supported OS found, not good!
return "${EXIT_ERR}"
_CACHE_CAN_USE_FFMPEG="no"
can_use_ffmpeg() {
if [ "${_CACHE_CAN_USE_FFMPEG}" = "yes" ]; then
return "${EXIT_OK}"
else
if [ "${UNAME}" = "Darwin" ]; then
if ! ${FFMPEG} -f avfoundation -list_devices true -i "" 2>&1 | $GREP 'AVFoundation input device' > /dev/null 2>&1; then
# Nope, no AVFoundation found in ffmpeg
return "${EXIT_ERR}"
else
# All good :-)
_CACHE_CAN_USE_FFMPEG="yes"
return "${EXIT_OK}"
fi
elif [ "${UNAME}" = "Linux" ]; then
if ! ${FFMPEG} -version 2>&1 | $GREP '\-\-enable-x11grab' > /dev/null 2>&1; then
# Nope, no x11grab found in ffmpeg
return "${EXIT_ERR}"
else
# All good :-)
_CACHE_CAN_USE_FFMPEG="yes"
return "${EXIT_OK}"
fi
fi

# Hmm, no supported OS found, not good!
return "${EXIT_ERR}"
fi
}

can_screen_record() {
Expand Down Expand Up @@ -696,6 +775,14 @@ get_camera_framerate() {
################################################################################


if [ ! -f "${HOME}/.config/ffscreencast/ffscreencastrc" ]; then
# Write default config if it does not exist
write_config
else
# If there is a config, source it as default
. "${HOME}/.config/ffscreencast/ffscreencastrc"
fi

############################################################
# 1.) Evaluate cmd arguments
############################################################
Expand Down
36 changes: 36 additions & 0 deletions config/ffscreencastrc
@@ -0,0 +1,36 @@
# ~/.config/ffscreencast/ffscreencastrc

# Default video container extension
# Alternatively: 'mp4' or 'avi'
OUTPUT_EXT="mp4"

# Default audio output codec
# Alternatively: 'pcm_s16le'
OUTPUT_ACODEC="libfaac"

# Default video output codec
# Alternatively: 'libx265'
OUTPUT_VCODEC="libx264"

# Default Screen recording arguments
S_ARGS=""

# Default audio recording arguments
A_ARGS="-ac 2"

# Default camera recording arguments
C_ARGS=""

# Default misc output arguments
O_ARGS="-crf 0 -preset ultrafast"

# Default recording behavior
RECORD_S="yes"
RECORD_A="no"
RECORD_C="no"

# What listed device number has been chosen to record?
CHOSEN_S_NUM=""
CHOSEN_A_NUM=""
CHOSEN_C_NUM=""

File renamed without changes
File renamed without changes

0 comments on commit 45c294c

Please sign in to comment.