gpt4 book ai didi

bash - ffmpeg 命令在 python 中使用时出错

转载 作者:行者123 更新时间:2023-12-04 23:25:08 25 4
gpt4 key购买 nike

当我从 shell 运行这个命令时,它工作得很好。

ffmpeg -nostdin -i /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/tmp/merged.avi -ss 00:00:00 -vcodec h264 -vf fps=25 -to 00:6:43 /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/1/1.avi

但是当我在 python 中做同样的事情时,它会给出错误:
import sys
import os

INPUT_DIR = sys.argv[1]
INPUT_VIDEO = sys.argv[2]
OUTPUT_PATH = sys.argv[3]
SOURCE = sys.argv[4]
DATE = sys.argv[5]

INPUT = INPUT_DIR+"sorted_result.txt"
COUNT=1
initial="00:00:00"

with open(INPUT,"r") as f:
for line in f.readlines():
OUT_DIR = OUTPUT_PATH+str(COUNT)
directory = os.path.abspath(OUT_DIR)
print('OUT DIR',OUT_DIR)
print('directory',directory)
try:
os.mkdir(directory)
except:
pass
cmd_1 = "ffmpeg -nostdin -i "+INPUT_VIDEO+" -ss " +initial+ " -vcodec h264 -vf fps=25 -to " +line+ " " +OUT_DIR+"/"+str(COUNT)+".avi"
os.system(cmd_1)
COUNT += 1
initial=line

我无法理解问题:

错误如下:
ffmpeg version 4.0-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2018 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-libxml2 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Trailing options were found on the commandline.
Input #0, avi, from '/data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/tmp/merged.avi':
Metadata:
encoder : Lavf58.12.100
Duration: 01:00:50.23, start: 0.000000, bitrate: 1334 kb/s
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 512x288 [SAR 1:1 DAR 16:9], 1001 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp, 639 kb/s
At least one output file must be specified
sh: line 1: /data/binil/v2t_final/output/cnbctv18/2018_07_02_14_38_30/1/1.avi: Permission denied

请帮忙。
这是我正在写的一些虚拟文本,因为看起来堆栈溢出不接受更少的描述和更多的代码。请不要介意这些句子。我不敢相信我还在写这篇文章,它仍然要求我添加更多描述。我还在做。不知道要写到什么程度。我希望这么多就足够了。

最佳答案

得到错误。
输入文件在新行中包含每个时间戳,因此它使用 '\n' 字符以及 ffmpeg 命令中的时间戳。因此它将 -vcodec 视为新命令并导致错误。

关于bash - ffmpeg 命令在 python 中使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51148823/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com