ffmpeg 截取切割视频报错

在用ffmpeg来截取只有视频没有音频的mp4文件时,有一些视频可以切割,少部分不能分割,遇到到了bug。

截取命令:

cd D:\ffmpeg\bin>
ffmpeg -ss 370 -to 389 -i 01.mp4 -y -f mp4 -vcodec copy  -q:v 1  output.mp4

报错如下:

[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing

[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[mpeg @ 0000022b8218dcc0] Packet corrupt (stream = 0, dts = 37275057).
01.mp4: corrupt input packet in stream 0
[mp3float @ 0000022b8220d300] Header missing
Error while decoding stream #0:1: Invalid data found when processing input
[abuffer @ 0000022b830c9100] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 3 times
[abuffer @ 0000022b830c9100] Error setting option time_base to value 1/0.
[graph_0_in_0_1 @ 0000022b827ab240] Error applying options to the filter.
Error reinitializing filters!
Error while filtering: Result too large
Finishing stream 0:1 without any data written to it.
[abuffer @ 0000022b830c9640] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 3 times
[abuffer @ 0000022b830c9640] Error setting option time_base to value 1/0.
[graph_0_in_0_1 @ 0000022b827ab240] Error applying options to the filter.
Error configuring filter graph
Conversion failed!

解决方法:

增加 -an 参数。

ffmpeg -ss 370 -to 389 -i 01.mp4 -y -f mp4 -vcodec copy -acodec copy -q:v 1 -an output.mp4

附ffmpeg参数含义:

'''
-ss 指定要截取的视频的起始时间。

-to 指定要截取的视频的终止时间。

-i 输入文件,这里指的就是视频文件。

-y 表示无需询问,直接覆盖输出文件(如果有原文件的话)。

-f 指定输出视频的格式。

-acodec 指定音频编码格式。copy表示编码格式不发生改变,直接复制原来的编码格式,这样会大大提升速度。

-vcodec 指定视频编码格式。copy表示编码格式不发生改变,直接复制原来的编码格式,这样会大大提升速度。

-q:v 1 q是质量,v是视频,v的取值范围是[1, 35],取值1的时候,对应着最佳的视频质量。

-an:a代表音频,n代表no an就是无音频的意思

'''

猜你喜欢

转载自blog.csdn.net/y459541195/article/details/125537703