gpt4 book ai didi

python - FFmpeg 仅在某些运行时返回 'invalid argument',即使它是相同的代码

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

我在 Python 中有代码,我需要使用 FFmpeg 将使用 pytube 下载的音频和视频合并在一起:

for video in p.videos:
video.streams.filter(file_extension='mp4',resolution='480p')[0].download(parent_dir+'/mp4/processing/video')
print(video.streams.filter(only_audio=True)[1].download(parent_dir+'/mp4/processing/audio'))

subprocess.run([

r'c:\FFmpeg\bin\ffmpeg', '-i',
os.path.join(parent_dir+'/mp4/processing/video',video.streams.filter(file_extension='mp4',resolution='480p')[0].default_filename)
,'-i',
os.path.join(parent_dir+'/mp4/processing/audio',video.streams.filter(only_audio=True)[1].default_filename),
'-c:v','copy','-c:a','copy',
os.path.join(parent_dir+'/mp4',video.streams.filter(file_extension='mp4',resolution='480p')[0].title+'.mp4')

])
我认为代码运行良好,但在某些情况下,FFmpeg 返回“无效参数”,如下例所示:
ffmpeg version 4.4-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev6, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:/videos/mp4/processing/video\Dropkick Murphys - Rose Tattoo (Video).mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6avc1mp41
creation_time : 2020-04-04T10:16:52.000000Z
Duration: 00:05:26.08, start: 0.000000, bitrate: 557 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 854x480 [SAR 1:1 DAR 427:240], 7 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2020-04-04T10:16:52.000000Z
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0]
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'D:/videos/mp4/processing/audio\Dropkick Murphys - Rose Tattoo (Video).mp4':
Metadata:
major_brand : dash
minor_version : 0
compatible_brands: iso6mp41
creation_time : 2020-04-04T10:16:00.000000Z
Duration: 00:05:26.12, start: 0.000000, bitrate: 129 kb/s
Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 3 kb/s (default)
Metadata:
creation_time : 2020-04-04T10:16:00.000000Z
handler_name : ISO Media file produced by Google Inc.
vendor_id : [0][0][0][0]
D:/videos/mp4\Dropkick Murphys - "Rose Tattoo" (Video).mp4: Invalid argument
出于某种原因,FFmpeg 说我的输出名称无效,但我不明白为什么,因为我之前多次运行代码并且它运行良好。

最佳答案

我发现是什么弄乱了我的代码,它是 ""围绕视频标题的名称。我通过添加 .replace('"','') 快速解决了它在视频标题之前,效果很好!

关于python - FFmpeg 仅在某些运行时返回 'invalid argument',即使它是相同的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69248686/

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