微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用偏移量调用时FFMPEG失败

如何解决使用偏移量调用时FFMPEG失败

我是FFMPEG的新手。抱歉,这个问题太基础了。

我想从30秒开始剪切30秒的样本。但是,当我执行以下命令时,它会失败并出现异常

cmd

ffmpeg -loglevel debug  -ss 00:00:30.000 -t 30 -i source.flac -acodec libmp3lame -ab 64k -ac 2 -ar 22050 -y -vn target.mp3

输出

ur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[flac @ 0x7f9603006200] blocksize 32768 > 4096
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[flac @ 0x7f9603006200] decode_frame() Failed
Error while decoding stream #0:0: Invalid data found when processing input
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[graph_0_in_0_0 @ 0x7f960241ab00] Setting 'time_base' to value '1/0'
[abuffer @ 0x7f960241ac00] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 1 times
[graph_0_in_0_0 @ 0x7f960241ab00] Setting 'sample_rate' to value '0'
[graph_0_in_0_0 @ 0x7f960241ab00] Setting 'sample_fmt' to value 's32'
[graph_0_in_0_0 @ 0x7f960241ab00] Setting 'channel_layout' to value '0x4'
[abuffer @ 0x7f960241ac00] Value inf for parameter 'time_base' out of range [0 - 2.14748e+09]
    Last message repeated 1 times

但是当我将偏移量更改为零秒时,它已经成功进行了转码。

cmd

ffmpeg -loglevel debug  -ss 00:00:00.000 -t 30 -i source.flac -acodec libmp3lame -ab 64k -ac 2 -ar 22050 -y -vn target.mp3  

输出

Output file #0 (target2.mp3):
  Output stream #0:0 (audio): 2680 frames encoded (1543500 samples); 2682 packets muxed (560483 bytes); 
  Total: 2682 packets (560483 bytes) muxed
756 frames successfully decoded,0 decoding errors
[AVIOContext @ 0x7f9050d05980] Statistics: 2 seeks,4 writeouts
[AVIOContext @ 0x7f9050e18b00] Statistics: 12320768 bytes read,2 seeks

我检查mediainfo没有找到任何东西

{
  "index": "0","codec_name": "flac","codec_long_name": "FLAC (Free Lossless Audio Codec)","profile": "unkNown","codec_type": "audio","codec_time_base": "1/44100","codec_tag_string": "[0][0][0][0]","codec_tag": "0x0000","sample_fmt": "s32","sample_rate": "44100","channels": "2","channel_layout": "stereo","bits_per_sample": "0","id": "N/A","r_frame_rate": "0/0","avg_frame_rate": "0/0","time_base": "1/44100","start_pts": "0","start_time": "0.000000","duration_ts": "9784915","duration": "221.880159","bit_rate": "1347288","max_bit_rate": "N/A","bits_per_raw_sample": "24","nb_frames": "N/A","nb_read_frames": "N/A","nb_read_packets": "N/A","disPOSITION": {
    "default": "0","dub": "0","original": "0","comment": "0","lyrics": "0","karaoke": "0","forced": "0","hearing_impaired": "0","visual_impaired": "0","clean_effects": "0","attached_pic": "0","timed_thumbnails": "0"
  },"filename": "source.flac","nb_streams": "1","nb_programs": "0","format_name": "flac","format_long_name": "raw FLAC","size": "37367072","probe_score": "100"
}

解决方法

将偏移量和持续时间应用于输出选项:

ffmpeg -loglevel debug -i source.flac -ss 00:00:30.000 -t 30 -c:a libmp3lame -b:a 64k -ac 2 -ar 22050 -y -vn target.mp3

FLAC容器在某些方面很奇怪。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。