Tôi muốn hợp nhất các tệp mp4 thông qua bộ giải mã concat và không thể làm cho nó hoạt động với một tập lệnh.
Tôi đang sử dụng tập lệnh từ một câu trả lời khác của AskUbfox, được gọi là concatmp4
đây:
#!/usr/bin/env bash
nếu [ $# -lt 1 ]; sau đó
echo "Cách sử dụng: `basename $0` input_1.mp4 input_2.mp4 ... output.mp4"
thoát 0
fi
ARGS=("$@") # xác định tất cả các đối số
output=${ARGS[${#ARGS[@]}-1]} # lấy đối số cuối cùng (tệp đầu ra)
bỏ đặt ARGS[${#ARGS[@]}-1] # bỏ nó khỏi mảng
(đối với f trong "${ARGS[@]}"; do echo "file '$f'"; xong) | ffmpeg -protocol_whitelist file,pipe -f concat -safe 0 -i pipe: -vcodec copy -acodec copy $output
Tuy nhiên, khi tôi chạy nó trên các tệp mp4, tôi luôn nhận được
$ concatmp4 Itazuraguma_no_Gloomy_01.mp4 Itazuraguma_no_Gloomy_02.mp4 test.mp4
ffmpeg phiên bản 4.4-6ubuntu5 Bản quyền (c) 2000-2021 các nhà phát triển FFmpeg
được xây dựng với gcc 11 (Ubuntu 11.2.0-7ubuntu1)
cấu hình: --prefix=/usr --extra-version=6ubuntu5 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu -- arch=AMD64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca -- enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme -- enable-libgsm -- enable-libjack -- enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse -- enable-librabbitmq -- enable-librubberband -- enable-libshine -- enable-libsnappy -- enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame -- enable-libvidstab -- enable-libvorbis -- enable-libvpx -- enable-libwebp -- enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx -- enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx -- enable-libdc1394 -- enable-libdrm -- enable-libiec61883 -- enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100/58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100/7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f2ed650200] Định dạng mov,mp4,m4a,3gp,3g2,mj2 chỉ được phát hiện với điểm thấp là 1, có thể phát hiện sai!
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55f2ed650200] nguyên tử moov không tìm thấy
[concat @ 0x55f2ed63e440] Không thể mở 'pipe:Itazuraguma_no_Gloomy_01.mp4'
pipe :: Tìm thấy dữ liệu không hợp lệ khi xử lý đầu vào
Khi tôi sửa đổi dòng cuối cùng của tập lệnh thành (đối với f trong "${ARGS[@]}"; do echo "file '$f'"; xong) > input.text
, rồi chạy ffmpeg -f concat -i input.text -c copy output.mp4
từ dòng lệnh, nó hoạt động (!). Chỉ cần làm rõ, khi tôi sử dụng -c bản sao
trong kịch bản, lỗi là như nhau.
Nó cũng hoạt động khi tập lệnh đi qua tệp tạm thời:
... # dòng sau dòng 'unset' trong bản gốc:
tmpfile="${output%.mp4}.tmp"
(đối với f trong "${ARGS[@]}"; do echo "file '$f'"; xong) > "$tmpfile"
ffmpeg -f concat -safe 0 -i "$tmpfile" -c copy "$output"
rm "$tmpfile"
Điều gì là cần thiết để làm cho kịch bản hoạt động?