fix-file.sh 592 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. set -e
  3. if [ $# -ne 2 ]; then
  4. echo "usage: $0 in.mp4 out.mp4"
  5. exit 1
  6. fi
  7. if [ ! -f "$1" ]; then
  8. echo "$1 doesn't exist"
  9. exit 1
  10. fi
  11. if [ -f "$2" ]; then
  12. echo "$2 exists"
  13. exit 1
  14. fi
  15. audiofile=$(mktemp).aac
  16. videofile=$(mktemp).mp4
  17. function finish {
  18. rm -f $audiofile
  19. rm -f $videofile
  20. }
  21. trap finish EXIT
  22. ffmpeg -hide_banner -analyzeduration 16M -i "$1" -c:v copy -an -f mp4 -y $videofile
  23. ffmpeg -hide_banner -analyzeduration 16M -i "$1" -c:a copy -vn -bsf:a aac_adtstoasc -y $audiofile
  24. ffmpeg -hide_banner -i $audiofile -i $videofile -c copy -bsf:a aac_adtstoasc -y "$2"