使用偏移量调用时 FFMPEG 失败

标签 ffmpeg

我是 FFMPEG 的新手。对不起,如果这个问题太基本了。
我想从 30 秒开始切割 30 秒的样本。但是当我执行下面的命令时,它失败并出现异常
命令

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

但是,当我更改偏移量为零秒时,它已成功转码。
命令
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 容器在某些方面很奇怪。

关于使用偏移量调用时 FFMPEG 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63787984/

相关文章:

ffmpeg - 如何防止视频开头出现质量损失?

sorting - "MMdd"中的昨天日期,具体的输出文件夹选择取决于日期

ffmpeg - 通过 ffmpeg 将声音与音乐同步。现场卡拉 OK FMS

Android libstagefright_h264 ff_get_buffer is not declared in this scope 错误

iphone - Windows 上使用 FFmpeg 的多比特率实时 HLS

python - 使用 BytesIO 进入 python-ffmpeg 或其他

video - 如何使用 ffmpeg 加速视频和添加水印

python - openCV中的视频捕获使用ffmpeg吗?

ffmpeg - ffmpeg 5.0 与 ffmpeg 4.1.1 的 Concat 失败

FFMPEG - 过滤器卷有一个未连接的输出