我有一个视频文件,我尝试通过fluent-ffmpeg对其进行操作。这是我通过ffprobe
获得的有关此文件的信息。您可以看到视频时长为6.014s。
{ streams:
[ { index: 0,
codec_name: 'h264',
codec_long_name: 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
profile: 'Constrained Baseline',
codec_type: 'video',
codec_time_base: '1001/60000',
codec_tag_string: 'avc1',
codec_tag: '0x31637661',
width: 376,
height: 668,
coded_width: 376,
coded_height: 668,
has_b_frames: 0,
sample_aspect_ratio: '0:1',
display_aspect_ratio: '0:1',
pix_fmt: 'yuv420p',
level: 30,
color_range: 'N/A',
color_space: 'unknown',
color_transfer: 'unknown',
color_primaries: 'unknown',
chroma_location: 'left',
field_order: 'unknown',
timecode: 'N/A',
refs: 1,
is_avc: 'true',
nal_length_size: 4,
id: 'N/A',
r_frame_rate: '30000/1001',
avg_frame_rate: '30000/1001',
time_base: '1/30000',
start_pts: 0,
start_time: 0,
duration_ts: 178200,
duration: 5.94,
bit_rate: 1161187,
max_bit_rate: 'N/A',
bits_per_raw_sample: 8,
nb_frames: 178,
nb_read_frames: 'N/A',
nb_read_packets: 'N/A',
tags: [Object],
disposition: [Object] },
{ index: 1,
codec_name: 'aac',
codec_long_name: 'AAC (Advanced Audio Coding)',
profile: 'LC',
codec_type: 'audio',
codec_time_base: '1/44100',
codec_tag_string: 'mp4a',
codec_tag: '0x6134706d',
sample_fmt: 'fltp',
sample_rate: 44100,
channels: 1,
channel_layout: 'mono',
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,
duration_ts: 264159,
duration: 5.99,
bit_rate: 70594,
max_bit_rate: 70594,
bits_per_raw_sample: 'N/A',
nb_frames: 259,
nb_read_frames: 'N/A',
nb_read_packets: 'N/A',
tags: [Object],
disposition: [Object] } ],
format:
{ filename: '/Users/sergey/Desktop/vid1.mp4',
nb_streams: 2,
nb_programs: 0,
format_name: 'mov,mp4,m4a,3gp,3g2,mj2',
format_long_name: 'QuickTime / MOV',
start_time: 0,
duration: 6.014,
size: 921490,
bit_rate: 1225793,
probe_score: 100,
tags:
{ major_brand: 'isom',
minor_version: '512',
compatible_brands: 'isomiso2avc1mp41',
encoder: 'Lavf57.25.100' } },
chapters: [] }
但是,如果我将两个这样的文件连接成一个文件:
ffmpeg -r 30000/1001 -i /Users/sergey/Desktop/vid1.mp4 -r 30000/1001 -i /Users/sergey/Desktop/vid1.mp4 -y -filter_complex concat=n=2:v=1:a=1 -r 30000/1001 -video_track_timescale 30k /var/folders/8z/5zzmwz4d6mnc2bwfb_1h8jbw0000gn/T/1552213381581.mp4
结果的持续时间为12.005,而不是预期的12.028 :
{ streams:
[ { index: 0,
codec_name: 'h264',
codec_long_name: 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
profile: 'High',
codec_type: 'video',
codec_time_base: '1001/60000',
codec_tag_string: 'avc1',
codec_tag: '0x31637661',
width: 376,
height: 668,
coded_width: 376,
coded_height: 668,
has_b_frames: 2,
sample_aspect_ratio: '0:1',
display_aspect_ratio: '0:1',
pix_fmt: 'yuv420p',
level: 30,
color_range: 'N/A',
color_space: 'unknown',
color_transfer: 'unknown',
color_primaries: 'unknown',
chroma_location: 'left',
field_order: 'unknown',
timecode: 'N/A',
refs: 1,
is_avc: 'true',
nal_length_size: 4,
id: 'N/A',
r_frame_rate: '30000/1001',
avg_frame_rate: '30000/1001',
time_base: '1/30000',
start_pts: 0,
start_time: 0,
duration_ts: 358380,
duration: 11.946,
bit_rate: 859761,
max_bit_rate: 'N/A',
bits_per_raw_sample: 8,
nb_frames: 358,
nb_read_frames: 'N/A',
nb_read_packets: 'N/A',
tags: [Object],
disposition: [Object] },
{ index: 1,
codec_name: 'aac',
codec_long_name: 'AAC (Advanced Audio Coding)',
profile: 'LC',
codec_type: 'audio',
codec_time_base: '1/44100',
codec_tag_string: 'mp4a',
codec_tag: '0x6134706d',
sample_fmt: 'fltp',
sample_rate: 44100,
channels: 1,
channel_layout: 'mono',
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,
duration_ts: 528362,
duration: 11.980998,
bit_rate: 70319,
max_bit_rate: 70319,
bits_per_raw_sample: 'N/A',
nb_frames: 517,
nb_read_frames: 'N/A',
nb_read_packets: 'N/A',
tags: [Object],
disposition: [Object] } ],
format:
{ filename: '/var/folders/8z/5zzmwz4d6mnc2bwfb_1h8jbw0000gn/T/1552213381581.mp4',
nb_streams: 2,
nb_programs: 0,
format_name: 'mov,mp4,m4a,3gp,3g2,mj2',
format_long_name: 'QuickTime / MOV',
start_time: 0,
duration: 12.005,
size: 1403350,
bit_rate: 935177,
probe_score: 100,
tags:
{ major_brand: 'isom',
minor_version: '512',
compatible_brands: 'isomiso2avc1mp41',
encoder: 'Lavf57.71.100' } },
chapters: [] }
我已经浏览过this question,但只要文件完全相同,因此所有统计信息都相同,似乎就无济于事。
因此,主要问题是“为什么结果持续时间与两个文件的总和不同?”和“如何解决?”。
有人可以建议一些帮助吗?预先感谢。