From 989daae8e81f40f4bc27d224a468444a5ed2ab52 Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 15 Sep 2024 06:00:18 +0300 Subject: [PATCH] Removed dependency on yt-dlp, changed some behav-s --- convert-video.sh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/convert-video.sh b/convert-video.sh index 92e9737..64e96cb 100755 --- a/convert-video.sh +++ b/convert-video.sh @@ -10,8 +10,8 @@ cleanup() { trap cleanup EXIT -export URL="$1"; -export NAME="$2"; +export INPUT="$1"; +export OUTPUT="$(realpath "$2")"; export BASE_URL="$3" if [ -z "${BASE_URL}" ]; then @@ -19,24 +19,21 @@ if [ -z "${BASE_URL}" ]; then fi -mkdir -p "${NAME}" +mkdir -p "${OUTPUT}" export ORIG="$(pwd)"; cd "${TMP_DIR}" -yt-dlp "${URL}" -o "${NAME}" +ffmpeg -i "${INPUT}" -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" -map '[left]' -f s8 -ac 1 -ar 48k "${OUTPUT}/left.s8" -map '[right]' -f s8 -ac 1 -ar 48k "${OUTPUT}/right.s8" +ffmpeg -i "${INPUT}" -vf fps=20 frame%04d.png -ffmpeg -i $2.* -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" -map '[left]' -f s8 -ac 1 -ar 48k "${ORIG}/${NAME}/left.s8" -map '[right]' -f s8 -ac 1 -ar 48k "${ORIG}/${NAME}/right.s8" - -ffmpeg -i $2.* -vf fps=20 frame%04d.png -rm $2.* -ls frame*.png | parallel 'echo {}; python3 ${ORIG}/cc-pic.py -W 164 -H 81 -p cover {} ${ORIG}/${NAME}/{.}.cpi' +ls frame*.png | parallel 'echo {}; python3 ${ORIG}/cc-pic.py -W 164 -H 81 -p cover {} ${OUTPUT}/{.}.cpi' rm frame*.png cd "${ORIG}" -export FRAME_COUNT="$(ls ${NAME}/*.cpi | wc -l)"; +export FRAME_COUNT="$(ls ${OUTPUT}/*.cpi | wc -l)"; + +printf '{"frame_time": 0.05, "frame_count": %d, "video": "%s", "audio": {"l": "%s", "r": "%s"}}\n' "${FRAME_COUNT}" "${BASE_URL}/frame%04d.cpi" "${BASE_URL}/left.s8" "${BASE_URL}/right.s8" > "${OUTPUT}/info.json" -#'{"frame_time": 0.05,"frame_count": ${FRAME_COUNT},"video": "${BASE_URL}/${NAME}/frame%04d.cpi","audio": {"l": "${BASE_URL}/${NAME}/left.s8", "r": "${BASE_URL}/${NAME}/right.s8"}}' > "${NAME}/${NAME}.json" -printf '{"frame_time": 0.05, "frame_count": %d, "video": "%s", "audio": {"l": "%s", "r": "%s"}}\n' "${FRAME_COUNT}" "${BASE_URL}/${NAME}/frame%04d.cpi" "${BASE_URL}/${NAME}/left.s8" "${BASE_URL}/${NAME}/right.s8" > "${NAME}/${NAME}.json" \ No newline at end of file