我正在尝试使用 moviepy 将 .MOV 文件转换为 .mp4 文件,据我所知,它是 ffmpeg 的包装器。我之前曾成功过,但当 ffmpeg 在 89% 时停止时,我感到很失望。我把它放了一个多小时,但没有任何进展。我很好奇视频中是否有什么东西导致了这个问题。结果发现最后有模拟静态。
我非常确信这就是问题所在,因为我使用其他软件来修剪模拟静态,而 ffmpeg 处理得很好。但是,我尝试自动从带有时间戳的视频中提取场景,而 ffmpeg 却没有任何错误地停止运行,这无济于事!
如果有任何价值的话,我也附加了日志文件!
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
Input #0, rawvideo, from 'pipe:':
Duration: N/A, start: 0.000000, bitrate: 497166 kb/s
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 720x480, 497166 kb/s, 59.94 tbr, 59.94 tbn, 59.94 tbc
Input #1, mp3, from 'convertedTEMP_MPY_wvf_snd.mp3':
Metadata:
encoder : Lavf58.29.100
Duration: 00:07:33.80, start: 0.025057, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (copy)
[libx264 @ 000001aea287cd80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001aea287cd80] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 000001aea287cd80] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'converted.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 720x480, q=-1--1, 59.94 fps, 11988 tbn, 59.94 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54
[rawvideo @ 000001aea287c400] Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)
frame= 111 fps=0.0 q=31.0 size= 512kB time=00:00:00.88 bitrate=4717.2kbits/s speed=1.74x
frame= 196 fps=194 q=31.0 size= 1536kB time=00:00:02.29 bitrate=5471.4kbits/s speed=2.27x
frame= 276 fps=182 q=31.0 size= 2560kB time=00:00:03.62 bitrate=5792.8kbits/s speed=2.39x
frame= 368 fps=182 q=31.0 size= 3584kB time=00:00:05.15 bitrate=5695.3kbits/s speed=2.56x
frame= 451 fps=179 q=31.0 size= 4352kB time=00:00:06.55 bitrate=5436.6kbits/s speed=2.61x
frame= 534 fps=177 q=31.0 size= 5376kB time=00:00:07.94 bitrate=5545.1kbits/s speed=2.63x
frame= 628 fps=178 q=31.0 size= 5888kB time=00:00:09.50 bitrate=5072.2kbits/s speed= 2.7x
frame= 725 fps=180 q=31.0 size= 6656kB time=00:00:11.12 bitrate=4899.4kbits/s speed=2.77x
frame= 817 fps=181 q=31.0 size= 7168kB time=00:00:12.67 bitrate=4634.5kbits/s speed= 2.8x
frame= 910 fps=181 q=31.0 size= 7936kB time=00:00:14.21 bitrate=4574.6kbits/s speed=2.83x
frame= 987 fps=179 q=31.0 size= 8704kB time=00:00:15.49 bitrate=4602.7kbits/s speed= 2.8x
frame= 1076 fps=179 q=31.0 size= 9728kB time=00:00:16.96 bitrate=4696.9kbits/s speed=2.82x
frame= 1159 fps=177 q=31.0 size= 10496kB time=00:00:18.36 bitrate=4681.9kbits/s speed=2.81x
frame= 1240 fps=176 q=31.0 size= 11520kB time=00:00:19.72 bitrate=4784.8kbits/s speed= 2.8x
frame= 1323 fps=175 q=31.0 size= 12544kB time=00:00:21.10 bitrate=4868.3kbits/s speed=2.79x
frame= 1411 fps=175 q=31.0 size= 13312kB time=00:00:22.55 bitrate=4834.7kbits/s speed= 2.8x
frame= 1495 fps=174 q=31.0 size= 14336kB time=00:00:23.98 bitrate=4897.2kbits/s speed= 2.8x
frame= 1583 fps=175 q=31.0 size= 15104kB time=00:00:25.44 bitrate=4862.9kbits/s speed=2.81x
frame= 1682 fps=176 q=31.0 size= 15872kB time=00:00:27.07 bitrate=4802.0kbits/s speed=2.83x
frame= 1777 fps=176 q=31.0 size= 16640kB time=00:00:28.68 bitrate=4752.4kbits/s speed=2.84x
frame= 1862 fps=176 q=31.0 size= 17408kB time=00:00:30.08 bitrate=4740.9kbits/s speed=2.84x
frame= 1943 fps=175 q=31.0 size= 18432kB time=00:00:31.45 bitrate=4800.7kbits/s speed=2.83x
...
frame=19626 fps=168 q=31.0 size= 191488kB time=00:05:26.45 bitrate=4805.2kbits/s speed= 2.8x
frame=19721 fps=168 q=31.0 size= 192000kB time=00:05:28.02 bitrate=4794.9kbits/s speed= 2.8x
frame=19812 fps=168 q=31.0 size= 192768kB time=00:05:29.56 bitrate=4791.7kbits/s speed= 2.8x
frame=19901 fps=168 q=31.0 size= 193280kB time=00:05:31.05 bitrate=4782.8kbits/s speed= 2.8x
frame=19994 fps=168 q=31.0 size= 194048kB time=00:05:32.59 bitrate=4779.6kbits/s speed= 2.8x
frame=20083 fps=168 q=31.0 size= 194816kB time=00:05:34.06 bitrate=4777.3kbits/s speed= 2.8x
frame=20164 fps=168 q=31.0 size= 195584kB time=00:05:35.43 bitrate=4776.5kbits/s speed= 2.8x
frame=20252 fps=168 q=31.0 size= 196352kB time=00:05:36.88 bitrate=4774.6kbits/s speed= 2.8x
frame=20340 fps=168 q=31.0 size= 197120kB time=00:05:38.35 bitrate=4772.5kbits/s speed= 2.8x
frame=20427 fps=168 q=31.0 size= 197888kB time=00:05:39.82 bitrate=4770.4kbits/s speed= 2.8x
frame=20509 fps=168 q=31.0 size= 198656kB time=00:05:41.18 bitrate=4769.8kbits/s speed= 2.8x
frame=20579 fps=168 q=31.0 size= 199680kB time=00:05:42.36 bitrate=4777.9kbits/s speed= 2.8x
frame=20650 fps=168 q=31.0 size= 200448kB time=00:05:43.53 bitrate=4779.9kbits/s speed= 2.8x
frame=20728 fps=168 q=31.0 size= 201472kB time=00:05:44.84 bitrate=4786.1kbits/s speed=2.79x
frame=20814 fps=168 q=31.0 size= 202240kB time=00:05:46.26 bitrate=4784.7kbits/s speed=2.79x
frame=20892 fps=168 q=31.0 size= 202752kB time=00:05:47.58 bitrate=4778.5kbits/s speed=2.79x
frame=20966 fps=168 q=31.0 size= 203520kB time=00:05:48.81 bitrate=4779.7kbits/s speed=2.79x
frame=21035 fps=168 q=31.0 size= 204032kB time=00:05:49.95 bitrate=4776.2kbits/s speed=2.79x
frame=21099 fps=167 q=31.0 size= 204288kB time=00:05:51.01 bitrate=4767.6kbits/s speed=2.79x
frame=21158 fps=167 q=31.0 size= 204800kB time=00:05:52.02 bitrate=4765.9kbits/s speed=2.78x
frame=21226 fps=167 q=31.0 size= 205312kB time=00:05:53.15 bitrate=4762.6kbits/s speed=2.78x
frame=21290 fps=167 q=31.0 size= 205568kB time=00:05:54.22 bitrate=4754.1kbits/s speed=2.78x
frame=21362 fps=167 q=31.0 size= 206336kB time=00:05:55.42 bitrate=4755.8kbits/s speed=2.78x
frame=21428 fps=167 q=31.0 size= 207104kB time=00:05:56.52 bitrate=4758.8kbits/s speed=2.77x
frame=21492 fps=167 q=31.0 size= 207616kB time=00:05:57.59 bitrate=4756.2kbits/s speed=2.77x
frame=21553 fps=166 q=31.0 size= 208128kB time=00:05:58.61 bitrate=4754.4kbits/s speed=2.77x
frame=21625 fps=166 q=31.0 size= 208640kB time=00:05:59.79 bitrate=4750.4kbits/s speed=2.77x
frame=21694 fps=166 q=31.0 size= 209408kB time=00:06:00.94 bitrate=4752.7kbits/s speed=2.76x
frame=21761 fps=166 q=31.0 size= 209920kB time=00:06:02.08 bitrate=4749.3kbits/s speed=2.76x
frame=21835 fps=166 q=31.0 size= 210432kB time=00:06:03.31 bitrate=4744.8kbits/s speed=2.76x
frame=21919 fps=166 q=31.0 size= 210944kB time=00:06:04.72 bitrate=4738.0kbits/s speed=2.76x
frame=22006 fps=166 q=31.0 size= 211712kB time=00:06:06.15 bitrate=4736.6kbits/s speed=2.76x
frame=22151 fps=166 q=31.0 size= 211968kB time=00:06:08.58 bitrate=4711.1kbits/s speed=2.77x
frame=22297 fps=167 q=31.0 size= 212224kB time=00:06:11.01 bitrate=4685.9kbits/s speed=2.78x
frame=22427 fps=167 q=31.0 size= 212736kB time=00:06:13.18 bitrate=4669.9kbits/s speed=2.78x
frame=22565 fps=168 q=31.0 size= 212992kB time=00:06:15.48 bitrate=4646.9kbits/s speed=2.79x
frame=22707 fps=168 q=31.0 size= 213248kB time=00:06:17.86 bitrate=4623.2kbits/s speed= 2.8x
frame=22848 fps=168 q=31.0 size= 213504kB time=00:06:20.19 bitrate=4600.3kbits/s speed= 2.8x
frame=22964 fps=169 q=31.0 size= 213760kB time=00:06:22.14 bitrate=4582.3kbits/s speed=2.81x
frame=23094 fps=169 q=31.0 size= 214272kB time=00:06:24.30 bitrate=4567.6kbits/s speed=2.81x
frame=23232 fps=169 q=31.0 size= 214528kB time=00:06:26.60 bitrate=4545.8kbits/s speed=2.82x
frame=23351 fps=170 q=31.0 size= 214784kB time=00:06:28.59 bitrate=4527.8kbits/s speed=2.82x
frame=23482 fps=170 q=31.0 size= 215040kB time=00:06:30.79 bitrate=4507.8kbits/s speed=2.83x
frame=23617 fps=170 q=31.0 size= 215296kB time=00:06:33.02 bitrate=4487.5kbits/s speed=2.83x
frame=23726 fps=170 q=31.0 size= 215808kB time=00:06:34.86 bitrate=4477.2kbits/s speed=2.84x
frame=23819 fps=171 q=31.0 size= 216576kB time=00:06:36.39 bitrate=4475.8kbits/s speed=2.84x
frame=23908 fps=171 q=31.0 size= 217600kB time=00:06:37.88 bitrate=4480.2kbits/s speed=2.84x
frame=24002 fps=171 q=31.0 size= 218368kB time=00:06:39.44 bitrate=4478.3kbits/s speed=2.84x
frame=24097 fps=171 q=31.0 size= 218880kB time=00:06:41.05 bitrate=4470.8kbits/s speed=2.84x
frame=24193 fps=171 q=31.0 size= 219648kB time=00:06:42.65 bitrate=4468.8kbits/s speed=2.84x
frame=24293 fps=171 q=31.0 size= 220160kB time=00:06:44.32 bitrate=4460.7kbits/s speed=2.84x
frame=24330 fps=170 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.84x
frame=24330 fps=170 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.83x
frame=24330 fps=169 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.82x
frame=24330 fps=169 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.81x
frame=24330 fps=168 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed= 2.8x
frame=24330 fps=168 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.79x
frame=24330 fps=167 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.78x
frame=24330 fps=166 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.77x
frame=24330 fps=166 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.76x
frame=24330 fps=165 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.75x
frame=24330 fps=165 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.74x
frame=24330 fps=164 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.73x
frame=24330 fps=164 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.72x
frame=24330 fps=163 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.71x
frame=24330 fps=162 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed= 2.7x
frame=24330 fps=162 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.69x
frame=24330 fps=161 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.68x
frame=24330 fps=161 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.68x
frame=24330 fps=160 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.67x
frame=24330 fps=160 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.66x
frame=24330 fps=159 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.65x
frame=24330 fps=159 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.64x
frame=24330 fps=158 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.63x
frame=24330 fps=158 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.62x
frame=24330 fps=157 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.61x
frame=24330 fps=157 q=31.0 size= 221696kB time=00:06:44.92 bitrate=4485.1kbits/s speed=2.61x
答案1
忙碌了一周后终于有时间重新回顾一下。
事实证明,这与模拟静态无关。或者可能只是部分原因。我能够顺利转换另一个包含静态的视频。这让我意识到视频中存在一些独特的损坏。
我能够使用 shotcut 进行转换,很好,然后我尝试了 stock ffmpeg。Stock ffmpeg 显示了很多错误,但能够完成该过程,最后的视频看起来很棒。我不知道 pymovie 在做什么,但我喜欢直接使用 ffmpeg。
不过有趣的是,我使用 ChatGPT 3.5 快速找出了 ffmpeg 命令,并使用该subprocess
命令开发了一个脚本来运行 ffmpeg。这很简单,我本来可以查阅的,但我尝试使用 ChatGPT 3.5,它成功了。最终我学会了如何subprocess.check_decode()
监控输出,现在我有了一个我认为非常强大的脚本。我甚至使用硬件加速在我的 GPU 上处理视频。我还意识到我似乎不需要转换视频。我能够根据时间直接提取我想要的剪辑。对结果非常满意!
import time
start_time = '2:33'
end_time = '2:51'
input_video = "video.MOV"
output_video = "output.mp4"
#Standard video conversion
ffmpeg_cmd = [
'ffmpeg',
'-i', input_video,
'-c:v', 'h264_nvenc',
'-c:a', 'aac',
'output.mp4', '-y', '']
#Extracting clip
ffmpeg_cmd_getclip = [
'ffmpeg',
'-i', input_video,
'-ss', start_time,
'-to', end_time,
output_video,'-y']
#Extracting clip with GPU
ffmpeg_cmd_getclipGPU = [
'ffmpeg',
'-hwaccel', 'cuvid',
'-c:v', 'h264_cuvid',
'-i', input_video,
'-ss', start_time,
'-to', end_time,
'-c:v', 'h264_nvenc',
output_video, '-y']
print('Starting!')
start = time.time()
output = subprocess.check_output(ffmpeg_cmd_getclip)
output = output.decode()
end = time.time()
run1 = end - start
start = time.time()
output = subprocess.check_output(ffmpeg_cmd_getclipGPU)
output = output.decode()
end = time.time()
run2 = end - start
#Seems as if the outut decoding runs a little while after the process has completed. Small delay to make sure things are cleaned up.
time.sleep(2)
print('Completed!')
print(run1, run2)```