轉到內容

FFMPEG 進階指南/連線

來自 Wikibooks,面向開放世界的開放書籍

利用此指令碼可以將多個影片組合成一個檔案。該過程使用 -c copy 引數,這意味著影片檔案構建自已有的影片流,並且不需要處理器密集型重新編碼。

ffmpeg_concat() {

 timestamp=$(date "+%Y%m%d%H%M%S")
  # Unlike in JavaScript, no spaces may surround the "=" equals sign to set a variable.

# generate file list
 for path in $@; do
  echo "file '$path' " >>ffmpeg_concat.$timestamp.txt
   # ffmpeg only supports apostrophes, no quotation marks.
 done

# ask user for output file extension to specify which container format should be used by FFmpeg
printf "Output file extension: " 
read output_extension

# put it together
ffmpeg -f concat -safe 0 -i ffmpeg_concat.$timestamp.txt -c copy ffmpeg_concat.$timestamp.$output_extension
 # -safe 0  allows concatinating files outside the current working directory
 # -c copy  passes through the existing video and audio streams without re-encoding it and only multiplexes it, making the process take only a fraction of the time since disk reading/writing speeds are the only limitation.

}
華夏公益教科書