我通过在我的 mp4 上使用 concat 创建了一个新的 mp4 文件:
ffmpeg -protocol_whitelist file,tcp,http,pipe -f concat -i - -c copy ${videoName%/}.mp4
然后,我想通过以下方式减小新创建的文件的文件大小:
ffmpeg -i "$file" -s 1280x720 -c:a copy "$videoName"
但我看到了
hutber@hutber:/mnt/googledrive/Winchmore Hill/1920/Week_14_6-2_W/Clips$ sd
Gtk-Message: 12:18:37.761: GtkDialog mapped without a transient parent. This is discouraged.
/mnt/googledrive/Winchmore Hill/1920/Week_14_6-2_W/Clips/vlc-record-2020-01-25-20h28m06s-S3510003.MP4-.mp4
/mnt/googledrive/Winchmore Hill/1920/Week_14_6-2_W/Clips/01.26.2020/vlc-record-2020-01-25-20h28m06s-S3510003.MP4-_01.26.2020_12.18_SD.mp4
ffmpeg version N-49161-g50e194e6e1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 30.100 / 56. 30.100
libavcodec 58. 53.101 / 58. 53.101
libavformat 58. 28.101 / 58. 28.101
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x6844880] st: 1 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x6844880] st: 1 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/googledrive/Winchmore Hill/1920/Week_14_6-2_W/Clips/vlc-record-2020-01-25-20h28m06s-S3510003.MP4-.mp4':
Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2020-01-25T20:28:19.000000Z
playback_requirements: QuickTime 6.0 or greater
playback_requirements-eng: QuickTime 6.0 or greater
encoder : vlc 3.0.8 stream output
encoder-eng : vlc 3.0.8 stream output
Duration: 00:00:12.60, start: 0.000000, bitrate: 61318 kb/s
Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 253 kb/s (default)
Metadata:
creation_time : 2020-01-25T20:28:19.000000Z
handler_name : SoundHandler
Stream #0:1(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 61056 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2020-01-25T20:28:19.000000Z
handler_name : VideoHandler
/mnt/googledrive/Winchmore Hill/1920/Week_14_6-2_W/Clips/01.26.2020/vlc-record-2020-01-25-20h28m06s-S3510003.MP4-_01.26.2020_12.18_SD.mp4: No such file or directory
以防万一这有帮助,这是我的 sh 脚本(我有一个 JS 开发人员:p)
#!/bin/bash
file=$(zenity --file-selection)
currentDateTime=$(date +'%m.%d.%Y_%H.%M')
currentDate=$(date +'%m.%d.%Y')
safeVideoName="${file/ /_}"
safeVideoName="${file/.mp4/}"
safeVideoName="${file/.mp4/}"
filename=${safeVideoName##*/}
fullpath="${safeVideoName%/*}/$currentDate"
videoName="${fullpath}/${filename}_${currentDateTime}_SD.mp4"
echo $file
echo $videoName
mkdir -p $fullpath
ffmpeg -i "$file" -s 1280x720 -c:a copy "$videoName"
答案1
mkdir
在您的脚本中,未引用参数替换:
mkdir -p $fullpath
应该
mkdir -p "$fullpath"
“缺少关键帧”消息应该不是问题。
从 ffmpeg 的最后一行可以看到:
...: No such file or directory
这就是问题所在——因为 bash 分割了不带引号的参数替换,所以mkdir
脚本中的命令尝试创建两个目录,而不是您想要的目录。结果是您告诉ffmpeg
在不存在的目录中输出文件。
由于只有一个空格 - 现在应该有两个目录:
/mnt/googledrive/Winchmore
- 并在脚本执行的任意目录中 – 名为的新目录
Hill
您可能希望删除它们。