gemer 4 лет назад
Родитель
Сommit
5b6f351bd5
6 измененных файлов с 533 добавлено и 24 удалено
  1. 0 0
      4dage/4dage-ffmpeg
  2. 1 1
      4dage/4dage-ffmpeg-cam8
  3. 253 0
      4dage/4dage-ffmpeg-img2video
  4. 254 0
      4dage/4dage-ffmpeg-overlay
  5. 1 1
      4dage/4dage-ffmpeg-rotStereo
  6. 24 22
      install-4dage

+ 0 - 0
4dage/4dage-ffmpeg


+ 1 - 1
4dage/4dage-ffmpeg-cam8

@@ -22,7 +22,7 @@ command_exists() {
     return 0
 }
 print_usage() {
-    echo -e "\033[43;34m $package - 4dage ffmpeg v2 custom version for ffmpeg: \033[0m"
+    echo -e "\033[43;34m $package - 4dage-ffmpeg-cam8 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 " "

+ 253 - 0
4dage/4dage-ffmpeg-img2video

@@ -0,0 +1,253 @@
+#!/bin/bash
+
+version="0.0.1"
+picsFolder=''
+audioFile=''
+outputName=''
+outputFolder=''
+allowCacheStay=0
+tempFolder=/tmp/4dage-ffmpeg
+time=$(date "+%Y%m%d-%H%M%S")
+tempFilePrefix="4dage-source-${time}"
+declare -a outputVideoList=('mp4 flv')
+red=$(tput setaf 1)
+green=$(tput setaf 2)
+reset=$(tput sgr0)
+
+command_exists() {
+    if ! [[ -x $(command -v "$1") ]]; then
+        return 1
+    fi
+
+    return 0
+}
+print_usage() {
+    echo -e "\033[43;34m $package - 4dage-ffmpeg-img2video 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 "-p, --source=pic file folder path       input the picture source path"
+    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"
+    echo " "
+    echo -e "\033[0;33m"
+    cat <<EOF
+                                  _oo0oo_
+                                 088888880
+                                 88" . "88
+                                 (| -_- |)
+                                  0\ = /0
+                               ___/'---'\___
+                             .' \\\\|     |// '.
+                            / \\\\|||  :  |||// \\
+                           /_ ||||| -:- |||||- \\
+                          |   | \\\\\\  -  /// |   |
+                          | \_|  ''\---/''  |_/ |
+                          \  .-\__  '-'  __/-.  /
+                        ___'. .'  /--.--\  '. .'___
+                     ."" '<  '.___\_<|>_/___.' >'  "".
+                    | | : '-  \'.;'\ _ /';.'/ - ' : | |
+                    \  \ '_.   \_ __\ /__ _/   .-' /  /
+                ====='-.____'.___ \_____/___.-'____.-'=====
+                                  '=---='
+   
+   
+              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+                        佛祖保佑    TTT    万无一失
+EOF
+    echo -e "\033[m"
+}
+make_temp_dir() {
+    # # Make a temp folder
+    if [ ! -d $tempFolder ]; then
+        mkdir -p $tempFolder && chmod 776 $tempFolder
+    fi
+}
+make_temp_dir
+
+while test $# -gt 0; do
+    case "$1" in
+    -h | --help)
+        print_usage
+        exit 0
+        ;;
+    -p)
+        shift
+        if test $# -gt 0; then
+
+            export picsFolder=$1
+        else
+            echo "{$red}no video path specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --pic*)
+        export picsFolder=$(echo $1 | sed -e 's/^[^=]*=//g')
+        echo $1
+        shift
+        ;;
+    -a)
+        shift
+        if test $# -gt 0; then
+            export audioFile=$1
+        else
+
+            echo "{$red}no rectangle format specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --audio*)
+        export audioFile=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    -o)
+        shift
+        if test $# -gt 0; then
+            export outputFolder=$1
+        else
+            echo "{$red}no output dir folder specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --output*)
+        export outputFolder=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    -n)
+        shift
+        if test $# -gt 0; then
+            export outputName=$1
+        else
+            echo "no output video name specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --name*)
+        export outputName=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    --cache)
+        shift
+        echo "allow cahche remain"
+        export allowCacheStay=1
+        shift
+        ;;
+    -v)
+        echo "$version"
+        shift
+        ;;
+    *)
+        print_usage
+        # echo "111"
+        break
+        ;;
+    esac
+done
+
+mkVerison() {
+
+    touch "$outputFolder/4dage-ffmpeg-img2video-$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"
+}
+covertVideoTask() {
+    picsFolderType=${picsFolder##*.}
+    allImages="$picsFolder/%d.jpg"
+
+    FFREPORT=file="$outputFolder/$outputName.$picsFolderType.txt":level=48 ffmpeg -hide_banner -y -i $allImages \
+        -r 30 -q:v 2 -pix_fmt yuv420p -c:a copy -shortest "$outputFolder/$outputName.origin.mp4"
+    FFREPORT=file="$outputFolder/$outputName.$picsFolderType.txt":level=48 ffmpeg -hide_banner -y -i "$outputFolder/$outputName.origin.mp4" \
+        -i $audioFile -filter_complex "[0:v]split=2[out1][out2]" \
+        -preset superfast -threads 2 -b 1.8M -minrate 1.8M -maxrate 1.8M -bufsize 2M \
+        -map '[out1]' -map 1:a? -profile:v high -vcodec libx264 -ab 128k "$outputFolder/$outputName.mp4" \
+        -map '[out2]' -map 1:a? -profile:v high -vcodec libx264 -ab 128k "$outputFolder/$outputName.flv"
+    rm "$outputFolder/$outputName.origin.mp4"
+    # FFREPORT=file="$outputFolder/$outputName.$picsFolderType.txt":level=48 ffmpeg -hide_banner -y -i $picsFolder \
+    #     -filter_complex "[0:v]crop=$audioFile,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"
+
+    takeVideoCap
+    mkVerison
+
+}
+clearDist() {
+    rm -f $outputFolder/*.json
+    rm -f $outputFolder/*.version
+}
+
+concatAllLogFile() {
+    cat $outputFolder/*.txt >>"$outputFolder/$outputName.full.log"
+    rm $outputFolder/*.txt
+
+}
+
+if [ ! -z $picsFolder ] && [ ! -z $audioFile ] && [ ! -z $outputName ] && [ ! -z $outputFolder ]; then
+    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.flv" --Output=JSON >"$outputFolder/$outputName.flv.json"
+    fi
+
+    echo -e "\033[0;32m"
+    cat <<EOF
+                                  _oo0oo_
+                                 088888880
+                                 88" . "88
+                                 (| -_- |)
+                                  0\ = /0
+                               ___/'---'\___
+                             .' \\\\|     |// '.
+                            / \\\\|||  :  |||// \\
+                           /_ ||||| -:- |||||- \\
+                          |   | \\\\\\  -  /// |   |
+                          | \_|  ''\---/''  |_/ |
+                          \  .-\__  '-'  __/-.  /
+                        ___'. .'  /--.--\  '. .'___
+                     ."" '<  '.___\_<|>_/___.' >'  "".
+                    | | : '-  \'.;'\ _ /';.'/ - ' : | |
+                    \  \ '_.   \_ __\ /__ _/   .-' /  /
+                ====='-.____'.___ \_____/___.-'____.-'=====
+                                  '=---='
+   
+   
+              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+                        佛祖保佑    TTT    顺利转换
+EOF
+    echo -e "\033[m"
+    echo "covert done!"
+else
+    if [ ! -n "$1" ]; then
+        print_usage
+    else
+        if [ -z $picsFolder ]; then
+            echo "${red}miss pics file folder path: 缺图像文件路径"
+        fi
+        if [ -z $audioFile ]; then
+            echo "${red}miss rect spec : 缺少rect的技术参数"
+        fi
+        if [ -z $outputName ]; then
+            echo "${red}miss file name : 缺少输出文件名称"
+        fi
+        if [ -z $outputFolder ]; then
+            echo "${red}miss output path : 缺少输出路径"
+        fi
+    fi
+
+fi

+ 254 - 0
4dage/4dage-ffmpeg-overlay

@@ -0,0 +1,254 @@
+#!/bin/bash
+
+version="0.1.5.1"
+videoFile=''
+picFile=''
+outputName=''
+outputFolder=''
+allowCacheStay=0
+tempFolder=/tmp/4dage-ffmpeg
+time=$(date "+%Y%m%d-%H%M%S")
+tempFilePrefix="4dage-source-${time}"
+declare -a outputVideoList=('mp4 flv')
+red=$(tput setaf 1)
+green=$(tput setaf 2)
+reset=$(tput sgr0)
+
+command_exists() {
+    if ! [[ -x $(command -v "$1") ]]; then
+        return 1
+    fi
+
+    return 0
+}
+print_usage() {
+    echo -e "\033[43;34m $package - 4dage overlay 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 "-p, --pic=picture file path       picture 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"
+    echo "--cahche   maintain the cahche file for tmp folder"
+    echo " "
+    echo -e "\033[0;33m"
+    cat <<EOF
+                                  _oo0oo_
+                                 088888880
+                                 88" . "88
+                                 (| -_- |)
+                                  0\ = /0
+                               ___/'---'\___
+                             .' \\\\|     |// '.
+                            / \\\\|||  :  |||// \\
+                           /_ ||||| -:- |||||- \\
+                          |   | \\\\\\  -  /// |   |
+                          | \_|  ''\---/''  |_/ |
+                          \  .-\__  '-'  __/-.  /
+                        ___'. .'  /--.--\  '. .'___
+                     ."" '<  '.___\_<|>_/___.' >'  "".
+                    | | : '-  \'.;'\ _ /';.'/ - ' : | |
+                    \  \ '_.   \_ __\ /__ _/   .-' /  /
+                ====='-.____'.___ \_____/___.-'____.-'=====
+                                  '=---='
+   
+   
+              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+                        佛祖保佑    TTT    万无一失
+EOF
+    echo -e "\033[m"
+}
+make_temp_dir() {
+    # # Make a temp folder
+    if [ ! -d $tempFolder ]; then
+        mkdir -p $tempFolder && chmod 776 $tempFolder
+    fi
+}
+make_temp_dir
+
+while test $# -gt 0; do
+    case "$1" in
+    -h | --help)
+        print_usage
+        exit 0
+        ;;
+    -s)
+        shift
+        if test $# -gt 0; then
+
+            export videoFile=$1
+        else
+            echo "{$red}no video path specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --source*)
+        export videoFile=$(echo $1 | sed -e 's/^[^=]*=//g')
+        echo $1
+        shift
+        ;;
+    -p)
+        shift
+        if test $# -gt 0; then
+            export picFile=$1
+        else
+
+            echo "{$red}no picFile specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --pic*)
+        export picFile=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    -o)
+        shift
+        if test $# -gt 0; then
+            export outputFolder=$1
+        else
+            echo "{$red}no output dir folder specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --output*)
+        export outputFolder=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    -n)
+        shift
+        if test $# -gt 0; then
+            export outputName=$1
+        else
+            echo "no output video name specified"
+            exit 1
+        fi
+        shift
+        ;;
+    --name*)
+        export outputName=$(echo $1 | sed -e 's/^[^=]*=//g')
+        shift
+        ;;
+    --cache)
+        shift
+        echo "allow cahche remain"
+        export allowCacheStay=1
+        shift
+        ;;
+    -v)
+        echo "$version"
+        shift
+        ;;
+    *)
+        print_usage
+        # echo "111"
+        break
+        ;;
+    esac
+done
+
+mkVerison() {
+    touch "$outputFolder/overlay-ffmpeg.$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"
+}
+covertVideoTask() {
+    videoFileType=${videoFile##*.}
+    picFileType=${picFile##*.}
+
+    # FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 ffmpeg -hide_banner -i $picFile -c:v libvpx -i $videoFile -filter_complex "overlay=(W-w)/2:(H-h)/2,pad=ceil(iw/2)*2:ceil(ih/2)*2" -vcodec libx264 "$outputFolder/$outputName.mp4" -y
+    # FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 ffmpeg -hide_banner -i $picFile -c:v libvpx -i $videoFile -filter_complex "overlay=(W-w)/2:(H-h)/2,pad=ceil(iw/2)*2:ceil(ih/2)*2" -vcodec libx264 "$outputFolder/$outputName.flv" -y
+
+    FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 \ 
+    ffmpeg -hide_banner -y -i $picFile -c:v libvpx -i $videoFile -filter_complex "[1:v][0:v]scale2ref[image][video];[video][image]overlay=0:0[v];[v]scale='2*trunc(iw/2)':'2*trunc(ih/2)'[v];[v]split=2[out1][out2]" \
+        -preset superfast -threads 2 -b 0.5M -minrate 0.5M -maxrate 0.5M -bufsize 1M \
+        -map '[out1]' -map 1:a? -vcodec libx264 -ab 128k "$outputFolder/$outputName.mp4" -map '[out2]'  -map 1:a?  -vcodec libx264 -ab 128k "$outputFolder/$outputName.flv"
+
+    # FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 \
+    # ffmpeg -hide_banner -i $picFile -c:v libvpx -i $videoFile -filter_complex "[1:v][0:v]scale2ref[image][video];[video][image]overlay[v];[v]scale='2*trunc(iw/2)':'2*trunc(ih/2)'" \
+    #     -movflags +faststart -b 0.5M -minrate 0.5M -maxrate 0.5M -bufsize 1M \
+    #     -vcodec libx264 "$outputFolder/$outputName.flv" -y
+
+    # FFREPORT=file="$outputFolder/$outputName.$videoFileType.txt":level=48 \
+    # ffmpeg -hide_banner -i $picFile -c:v libvpx -i $videoFile \
+    # -filter_complex "[1:v][0:v]scale2ref[image][video];[video][image]overlay[v];[v]scale='2*trunc(iw/2)':'2*trunc(ih/2)'" \
+    #     -movflags +faststart -b 0.5M -minrate 0.5M -maxrate 0.5M -bufsize 1M -vcodec libx264 "$outputFolder/$outputName.flv" -y
+
+    #    ffmpeg -y -i background-2.jpeg -c:v libvpx -i Human_alpha_2.webm \
+    #     -filter_complex "[1:v][0:v]scale2ref[image][video];[video][image]overlay[v];[v]scale='2*trunc(iw/2)':'2*trunc(ih/2)'" \
+    #     -movflags +faststart -b 0.5M -minrate 0.5M -maxrate 0.5M -bufsize 1M  -vcodec libx264 output.mp4
+
+    takeVideoCap
+    mkVerison
+
+}
+
+concatAllLogFile() {
+    cat $outputFolder/*.txt >>"$outputFolder/$outputName.full.log"
+    rm $outputFolder/*.txt
+}
+
+if [ ! -z $videoFile ] && [ ! -z $picFile ] && [ ! -z $outputName ] && [ ! -z $outputFolder ]; then
+    if [ ! -d $outputFolder ]; then
+        mkdir -p $outputFolder
+    fi
+    covertVideoTask
+    concatAllLogFile
+    if command_exists "mediainfo"; then
+        mediainfo --fullscan "$outputFolder/$outputName.mp4" --Output=JSON >"$outputFolder/$outputName.json"
+        mediainfo --fullscan "$outputFolder/$outputName.flv" --Output=JSON >"$outputFolder/$outputName.flv.json"
+    fi
+
+    echo -e "\033[0;32m"
+    cat <<EOF
+                                  _oo0oo_
+                                 088888880
+                                 88" . "88
+                                 (| -_- |)
+                                  0\ = /0
+                               ___/'---'\___
+                             .' \\\\|     |// '.
+                            / \\\\|||  :  |||// \\
+                           /_ ||||| -:- |||||- \\
+                          |   | \\\\\\  -  /// |   |
+                          | \_|  ''\---/''  |_/ |
+                          \  .-\__  '-'  __/-.  /
+                        ___'. .'  /--.--\  '. .'___
+                     ."" '<  '.___\_<|>_/___.' >'  "".
+                    | | : '-  \'.;'\ _ /';.'/ - ' : | |
+                    \  \ '_.   \_ __\ /__ _/   .-' /  /
+                ====='-.____'.___ \_____/___.-'____.-'=====
+                                  '=---='
+   
+   
+              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+                        佛祖保佑    TTT    顺利转换
+EOF
+    echo -e "\033[m"
+    echo "covert done!"
+else
+    if [ ! -n "$1" ]; then
+        print_usage
+    else
+        if [ -z $videoFile ]; then
+            echo "${red}miss video file path: 缺视频文件路径"
+        fi
+        if [ -z $picFile ]; then
+            echo "${red}miss audio file path : 缺少背影图像文件路径"
+        fi
+        if [ -z $outputName ]; then
+            echo "${red}miss file name : 缺少输出文件名称"
+        fi
+        if [ -z $outputFolder ]; then
+            echo "${red}miss output path : 缺少输出路径"
+        fi
+    fi
+
+fi

+ 1 - 1
4dage/4dage-ffmpeg-rotStereo

@@ -22,7 +22,7 @@ command_exists() {
     return 0
 }
 print_usage() {
-    echo -e "\033[43;34m $package - 4dage custom version for ffmpeg: \033[0m"
+    echo -e "\033[43;34m $package - 4dage-ffmpeg-rotStereo 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 " "

+ 24 - 22
install-4dage

@@ -5,7 +5,14 @@ HOMEDIR=/usr/local/4dage-ffmpeg
 scriptURLFolder=http://face3d.4dage.com:7005/zhangyupeng/4dage-ffmpeg/raw/master/4dage
 
 # 对应 4dage文件下的脚本, 批量安装
-declare -a installList=('4dage-ffmpeg 4dage-ffmpeg-cam8 4dage-ffmpeg-img2video 4dage-ffmpeg-rotStereo')
+
+declare -a installList=(
+    4dage-ffmpeg
+    4dage-ffmpeg-cam8
+    4dage-ffmpeg-img2video
+    4dage-ffmpeg-rotStereo
+    4dage-ffmpeg-overlay
+)
 
 mkdir -p $HOMEDIR
 
@@ -17,33 +24,28 @@ command_exists() {
     return 0
 }
 
-# if ! command_exists "curl"; then
-#     echo "curl not installed."
-#     exit 1
-# fi
+if ! command_exists "curl"; then
+    echo "curl not installed."
+    exit 1
+fi
 
 scriptInstall() {
-
-    echo "传数:$1"
+    scriptURL=$scriptURLFolder/$1
+    binURL=$HOMEDIR/$1
+    if ! command_exists "$1"; then
+        curl -s $scriptURL -o $binURL
+        ln -s $binURL /usr/local/bin/$1
+    else
+        curl -s $scriptURL -o $binURL
+    fi
+    echo "install $1,done"
+    chmod a+x $binURL
 
 }
 
 for i in "${installList[@]}"; do
-
-    scriptURL=$scriptURLFolder/$i
-    curl -s $scriptURL -o ./docs
-    echo $scriptURL
+    scriptInstall $i
 
 done
 
-# ## command exsits
-
-# if ! command_exists "4dage-ffmpeg"; then
-#     curl -s $scriptURL -o $HOMEDIR/4dage-ffmpeg
-#     ln -s $HOMEDIR/4dage-ffmpeg /usr/local/bin/4dage-ffmpeg
-# else
-#     curl -s $scriptURL -o $HOMEDIR/4dage-ffmpeg
-# fi
-
-# chmod a+x $HOMEDIR/4dage-ffmpeg
-# exec bash
+exec bash