gemer 4 年之前
父節點
當前提交
78405055ae
共有 3 個文件被更改,包括 49 次插入34 次删除
  1. 49 34
      4dage/4dage-ffmpeg-cam8
  2. 0 0
      backup/4dage-ffmpeg
  3. 0 0
      backup/4dage-ffmpeg-v1

+ 49 - 34
4dage/4dage-ffmpeg-cam8

@@ -1,8 +1,8 @@
 #!/bin/bash
 
-version="1.0.4"
+version="0.1.6"
 videoFile=''
-rectspec=''
+audioFile=''
 outputName=''
 outputFolder=''
 allowCacheStay=0
@@ -22,14 +22,14 @@ command_exists() {
     return 0
 }
 print_usage() {
-    echo -e "\033[43;34m $package - 4dage-ffmpeg-cam8 custom version for ffmpeg: \033[0m"
+    echo -e "\033[43;34m $package - 4dage custom version for ffmpeg: \033[0m"
     echo "${green}If have problem with this, please contact with gemer AKA: 张宇鹏<zhangyupeng@cgaii.com>"
     echo "$package [options] application [arguments]"
     echo " "
     echo "${red}options:"
     echo "-h, --help                show brief help"
     echo "-s, --source=source file path       input the video source path"
-    echo "-r, --rect=rectange size      rectange size"
+    echo "-a, --audio=audio file path       audio file path"
     echo "-n, --name=output file name       output file name"
     echo "-o, --output=DIR      specify a directory to store output in"
     echo "-v, --version      output verison"
@@ -92,19 +92,19 @@ while test $# -gt 0; do
         echo $1
         shift
         ;;
-    -r)
+    -a)
         shift
         if test $# -gt 0; then
-            export rectspec=$1
+            export audioFile=$1
         else
 
-            echo "{$red}no rectangle format specified"
+            echo "{$red}no audioFile specified"
             exit 1
         fi
         shift
         ;;
-    --rect*)
-        export rectspec=$(echo $1 | sed -e 's/^[^=]*=//g')
+    --audio*)
+        export audioFile=$(echo $1 | sed -e 's/^[^=]*=//g')
         shift
         ;;
     -o)
@@ -154,50 +154,65 @@ while test $# -gt 0; do
 done
 
 mkVerison() {
-
-    touch "$outputFolder/4dage-ffmpeg-v2-$version.version"
+    touch "$outputFolder/$version.version"
 }
 takeVideoCap() {
-    FFREPORT=file="$outputFolder/$outputName.cap.txt":level=48 ffmpeg -hide_banner -loglevel error -y -i "$outputFolder/$outputName.mp4" -r 1 -ss 00:00:01 -vframes 1 -vf "transpose=1,scale=iw/5:ih/5,setsar=1:1" -f image2 "$outputFolder/$outputName.jpg"
+    FFREPORT=file="$outputFolder/$outputName.cap.txt":level=32 ffmpeg -hide_banner -loglevel error -y -i $tempVideo -r 1 -ss 00:00:01 -vframes 1 -vf "transpose=1,scale=iw/5:ih/5,setsar=1:1" -f image2 "$outputFolder/$outputName.jpg"
 }
 covertVideoTask() {
     videoFileType=${videoFile##*.}
-
-    FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 ffmpeg -hide_banner -y -i $videoFile \
-        -filter_complex "[0:v]crop=$rectspec,scale=iw/2:ih/2,pad=ceil(iw/2)*2:ceil(ih/2)*2,split=2[out1][out2]" \
-        -preset superfast -threads 2 -b 1.8M -minrate 1.8M -maxrate 1.8M -bufsize 2M \
-        -map '[out1]' -map 0:a? -profile:v high -vcodec libx264 -ab 128k "$outputFolder/$outputName.mp4" \
-        -map '[out2]' -map 0:a? -profile:v high -vcodec libx264 -ab 128k "$outputFolder/$outputName.flv"
-
+    audioFileType=${audioFile##*.}
+    tempbaseAudio="$tempFolder/$tempFilePrefix-base.$audioFileType"
+    tempAudio="$tempFolder/$tempFilePrefix.$audioFileType"
+    tempVideo="$tempFolder/$tempFilePrefix.$videoFileType"
+    # FFREPORT=file="$outputFolder/audio.log":level=32 ffmpeg -i $tempAudio -filter_complex 'lv2=plugin=https\\://github.com/lucianodato/speech-denoiser' $tempAudio -y
+    FFREPORT=file="$outputFolder/$outputName.audio.txt":level=32 ffmpeg -i $audioFile -af "lv2=p=https\\\\://github.com/lucianodato/speech-denoiser" -ac 1 $tempAudio -y
+    RC=$?
+    if [ "${RC}" -ne "0" ]; then
+        FFREPORT=file="$outputFolder/$outputName.audio.txt":level=32 ffmpeg -i $audioFile -af "highpass=f=200, lowpass=f=3000" $tempAudio -y
+    fi
+    # -vf "scale=iw/2:ih/2"
+    ffmpeg -i $videoFile -i $tempAudio -c:v copy -c:a aac -strict -2 $tempVideo -y
+    FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=32 ffmpeg -i $tempVideo -s 1056x792 -c:v libx264 -profile:v high -level:v 4.1 -vf "scale=iw/2:ih/2" -pix_fmt yuv420p -movflags +faststart -bf 2 -c:a copy "$outputFolder/$outputName.$videoFileType" -y
+    FFREPORT=file="$outputFolder/$outputName.flv.txt":level=32 ffmpeg -i $tempVideo -s 1056x792 -c:v libx264 -ar 44100 -profile:v high -level:v 4.1 -vf "scale=iw/2:ih/2" -pix_fmt yuv420p -movflags +faststart -bf 2 -c:a copy "$outputFolder/$outputName.flv" -y
     takeVideoCap
     mkVerison
+    # ffmpeg -i $tempVideo -s 1056x792 -c:v libx265 -movflags faststart -bf 2 -c:a copy "$outputFolder/$outputName.265.$videoFileType" -y
+    # export lastOutPutVideo=$outputFolder/$outputName.$videoFileType
+    # export lastOutPutVideoFlv="$outputFolder/$outputName.flv"
+    if test $allowCacheStay -eq 0; then
+        rm $tempAudio $tempVideo
+    fi
 
 }
-clearDist() {
-    rm -f $outputFolder/*.json
-    rm -f $outputFolder/*.version
-}
 
 concatAllLogFile() {
     cat $outputFolder/*.txt >>"$outputFolder/$outputName.full.log"
     rm $outputFolder/*.txt
-
+    # rm "$outputFolder/$outputName.$videoFileType.log" "$outputFolder/$outputName.audio.log" "$outputFolder/$outputName.flv.log"
 }
 
-if [ ! -z $videoFile ] && [ ! -z $rectspec ] && [ ! -z $outputName ] && [ ! -z $outputFolder ]; then
+if [ ! -z $videoFile ] && [ ! -z $audioFile ] && [ ! -z $outputName ] && [ ! -z $outputFolder ]; then
+    # ffmpeg -i $audioFile -af "highpass=f=200, lowpass=f=3000" temp.mp3 -y
+    # ffmpeg -i $audioFile -filter_complex 'lv2=plugin=https\\://github.com/lucianodato/speech-denoiser' $tempAudio -y
+    # ffmpeg -i $videoFile -i $tempAudio -c:v copy -c:a aac $tempVideo -y
+    # ffmpeg -i $tempVideo -s 1056x792 -c:v libx264 -profile:v high -level:v 4.0 -movflags faststart -bf 2 -c:a copy $outputFolder/$outputName.$i -y
+    # for i in "${outputVideoList[@]}"; do
+    # done
+    # ffmpeg -i temp.mp4 -s 1056x792 -c:v libx264 -profile:v high -level:v 4.0 -movflags faststart -bf 2 -c:a copy temp1.mp4 -y
+    # ffmpeg -i temp1.mp4 -pix_fmt rgb24 -color_range 2 $output -y
+    # rm temp.mp4 temp1.mp4 temp.mp3
     if [ ! -d $outputFolder ]; then
         mkdir -p $outputFolder
-    else
-        clearDist
     fi
     covertVideoTask
     concatAllLogFile
     if command_exists "mediainfo"; then
-        mediainfo --fullscan "$outputFolder/$outputName.mp4" --Output=JSON >"$outputFolder/$outputName.json"
+        mediainfo --fullscan "$outputFolder/$outputName.$videoFileType" --Output=JSON >"$outputFolder/$outputName.json"
         mediainfo --fullscan "$outputFolder/$outputName.flv" --Output=JSON >"$outputFolder/$outputName.flv.json"
     fi
 
-    echo -e "\033[0;32m"
+    echo "\033[0;32m"
     cat <<EOF
                                   _oo0oo_
                                  088888880
@@ -222,7 +237,7 @@ if [ ! -z $videoFile ] && [ ! -z $rectspec ] && [ ! -z $outputName ] && [ ! -z $
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                         佛祖保佑    TTT    顺利转换
 EOF
-    echo -e "\033[m"
+    echo "\033[m"
     echo "covert done!"
 else
     if [ ! -n "$1" ]; then
@@ -231,14 +246,14 @@ else
         if [ -z $videoFile ]; then
             echo "${red}miss video file path: 缺视频文件路径"
         fi
-        if [ -z $rectspec ]; then
-            echo "${red}miss rect spec : 缺少rect的技术参数"
+        if [ -z $audioFile ]; then
+            echo "${red}miss audio file path : 缺音频少文件路径"
         fi
         if [ -z $outputName ]; then
-            echo "${red}miss file name : 缺输出文件名称"
+            echo "${red}miss file name : 缺输出文件名称"
         fi
         if [ -z $outputFolder ]; then
-            echo "${red}miss output path : 缺输出路径"
+            echo "${red}miss output path : 缺输出路径"
         fi
     fi
 

4dage-ffmpeg → backup/4dage-ffmpeg


4dage-ffmpeg-v1 → backup/4dage-ffmpeg-v1