Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试将视频文件数据填充到mysql数据库_Mysql_Bash_Shell_Ffmpeg_Ffprobe - Fatal编程技术网

尝试将视频文件数据填充到mysql数据库

尝试将视频文件数据填充到mysql数据库,mysql,bash,shell,ffmpeg,ffprobe,Mysql,Bash,Shell,Ffmpeg,Ffprobe,我正在mac上尝试循环浏览目录中的所有视频,并将文件的详细信息(持续时间、大小和时间)添加到mysql数据库中。但由于某种原因,每次mysql部分出现故障时 如果我使用脚本生成的mysql查询,并在mysql数据库上运行它,它就可以正常工作。有人能帮忙吗 #!/bin/bash OrDir="/Volumes/Misc/video" find "$OrDir" -type f -exec /bin/bash -c \ 'name=$(basename "$1") name=$

我正在mac上尝试循环浏览目录中的所有视频,并将文件的详细信息(持续时间、大小和时间)添加到mysql数据库中。但由于某种原因,每次mysql部分出现故障时

如果我使用脚本生成的mysql查询,并在mysql数据库上运行它,它就可以正常工作。有人能帮忙吗

#!/bin/bash

OrDir="/Volumes/Misc/video"
find "$OrDir" -type f -exec /bin/bash -c \
    'name=$(basename "$1")
     name=${name%.*}
     duration=$( ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal "$1")
     hash=$( md5 "$1" | cut -f 4 -d " ")
     size=$( stat -f%z "$1")

     QUERY="UPDATE Video SET Duration=\"$duration\", Hash=\"$hash\", Bytes=$size WHERE Name=\"$name\" "
     echo "$QUERY \n"
     mysql --host=**.**.**.** --user=**** --password=****** **** << EOF
     $QUERY;
     EOF

     ' _ {} \;
#/bin/bash
OrDir=“/Volumes/Misc/video”
查找“$ORDR”-类型f-exec/bin/bash-c\
'name=$(basename“$1”)
name=${name%.*}
duration=$(ffprobe-v error-show_entries format=duration-of default=noprint_wrappers=1:nokey=1-sexagesimal“$1”)
哈希=$(md5“$1”| cut-f 4-d”“)
大小=$(统计数据-f%z“$1”)
QUERY=“更新视频集持续时间=\”$Duration\”,哈希=\“$Hash\”,字节=$size,其中Name=\“$Name\”
回显“$QUERY\n”

mysql--host=****.*.*.--user=******--password=*********是否缩进了
EOF
?(如果是,不要缩进!)@gniourf_gniourf它与上面完全一样(缩进到查找位置,但不是缩进到
EOF
的第一行)@gniourf_gniourf去掉了缩进,现在可以正常工作了。谢谢!然后删除缩进:
EOF
必须出现在文件的第一列!