From cd27431a6a4d8b8d035a2a70b90e4b47a50eec91 Mon Sep 17 00:00:00 2001 From: eshrh Date: Tue, 8 Jun 2021 01:38:04 -0400 Subject: [PATCH] fix ffmpeg corrupt files --- ames.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ames.sh b/ames.sh index 21cee74..b85ca40 100755 --- a/ames.sh +++ b/ames.sh @@ -244,6 +244,7 @@ record() { -af 'silenceremove=1:0:-50dB' \ -ab $AUDIO_BITRATE \ "$audioFile" 1>/dev/null & + echo "$!" >> "$recordingToggle" if [[ "$LANG" == en* ]]; then notify-send --hint=int:transient:1 -t 500 -u normal "Recording started..." @@ -251,12 +252,16 @@ record() { if [[ "$LANG" == ja* ]]; then notify-send --hint=int:transient:1 -t 500 -u normal "録音しています..." fi - - echo "Started recording." else - local -r audioFile="$(cat "$recordingToggle")" + local audioFile="$(sed -n "1p" "$recordingToggle")" + local pid="$(sed -n "2p" "$recordingToggle")" + rm "$recordingToggle" - killall ffmpeg + kill -15 "$pid" + + while [ $(du $audioFile | awk '{ print $1 }') -eq 0 ]; do + true + done store_file "${audioFile}" update_sound "$(basename -- "$audioFile")"