Help:Mpeg2dv.sh
Jump to navigation
Jump to search
Jeśli twoje oprogramowanie do edycji filmów nie importuje plików mpeg z kamery cyfrowej, być może musisz przekonwertować je do formatu dv, aby zaimportować np. do iMovie.
Instrukcje
- Zapisz kod na Pulpicie. Upewnij się, że rozszerzenie to naprawdę .sh, a nie .sh.txt.
- Przenieś plik w odpowiednie miejsce (jak /usr/local/bin/mpeg2dv.sh w systemie Mac OS X lub na przykład ~/bin/mpeg2dv.sh pod linuksem), które jest w zmiennej środowiskowej $PATH i w razie potrzeby ustaw plik jako wykonalny.
- Otwórz terminal (Terminal.app w Mac OS X – w Applications w folderze Utilities) i wpisz:
mpeg2dv.sh anMpgFile.mpg anotherMpgFile.mpg
Wynikiem powinny być pliki .dv w odpowiednim podfolderze.
Skrypt
#!/bin/sh # This script converts mpeg files from a digital camera # into the DV format using the ffmpeg tool. # # Eric Kow # Public domain - do whatever you want with this FFMPEG_FLAGS="-ac 2 -ar 48000 -hq -s 720x480" TYPE_1= TYPE_2='-map 0:1 -map 0:0' TYPE_3='-map 0:2 -map 0:1' try_ffmpeg() { IN_FILE=${1} OUT_FILE=${2} while [ "$#" -gt "2" ] do TYPE=${3} ffmpeg -i "${IN_FILE}" ${TYPE} ${FFMPEG_FLAGS} "${OUT_FILE}" || : if [ -s ${OUT_FILE} ]; then return 0 else rm ${OUT_FILE} fi shift done } # for each file... while [ "$#" -gt "0" ] do # what file are we working on now? in_file=$1 in_file_uscore=`echo ${in_file} | sed -e 's/ /_/g'` out_file_stem=`basename ${in_file_uscore} .mpg` out_file=${out_file_stem}.dv shift try_ffmpeg "${in_file}" "${out_file}"\ "${TYPE_1}" "${TYPE_2}" "${TYPE_3}" done