Last active
July 8, 2024 06:17
-
-
Save xtetsuji/73e1acb5b18b9d87573d9ecd79968807 to your computer and use it in GitHub Desktop.
Revisions
-
xtetsuji revised this gist
Jul 8, 2024 . No changes.There are no files selected for viewing
-
xtetsuji revised this gist
Jul 8, 2024 . No changes.There are no files selected for viewing
-
xtetsuji revised this gist
Jul 8, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ trap handle_error EXIT # main 関数 function main { local argv=("$@") local input=${argv[0]:-} echo "入力ファイル: $input" # コマンド例(ここでエラーが発生する) # ls /tmp/notfounddir -
xtetsuji created this gist
Jul 7, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/bin/bash set -eu PRESET="PresetAppleM4V1080pHD" function usage { # local error_code=${1:-0} cat <<EOF Usage: mov2mp4.sh input.mov EOF # exit "$error_code" } function handle_error { local error_code=$? if [ "$error_code" -ne 0 ] ; then echo "エラーが発生しました: コマンド '$BASH_COMMAND' で error_code=$error_code エラーが発生 (行番号: $LINENO)" usage "$error_code" fi } trap handle_error EXIT # main 関数 function main { local argv=("$@") local input=${argv[0]} echo "入力ファイル: $input" # コマンド例(ここでエラーが発生する) # ls /tmp/notfounddir if ! [[ $input =~ \.mov$ ]] ; then echo "入力ファイルの拡張子は .mov である必要があります" # usage 1 usage exit fi # M4V 入りのプリセットは m4v 拡張子のみ受け付ける local output_m4v=${input%.mov}.m4v echo "avconvert start" avconvert --preset "$PRESET" --source "$input" --output "$output_m4v" # GitHub 添付は m4v ではなく mp4 拡張子である必要がある local output_mp4=${input%.mov}.mp4 mv -v "$output_m4v" "$output_mp4" } main "$@" exit