Video 使用ffmpeg的视频连接提供了不正确的持续时间

Video 使用ffmpeg的视频连接提供了不正确的持续时间,video,ffmpeg,concatenation,fluent-ffmpeg,Video,Ffmpeg,Concatenation,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:

我有一个视频文件,我试图用它来操作的方式。以下是我通过
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: [] }
我已经看过了,但似乎没有帮助,只要它是完全相同的文件,所以所有的统计数据都是相同的

所以,主要的问题是“为什么结果持续时间不同于两个文件的总和?”以及“如何修复它?”


有人能建议帮忙吗?提前感谢。

如果可能,请提供输入文件的链接。这里是:输入文件是否在关键帧(Iframe)上开始和结束?抱歉,我没有听到您的问题。上面提供了有关输入文件的所有信息(以及它本身)。如果可能,请提供指向输入文件的链接。这里是:输入文件是否在关键帧(Iframe)上开始和结束?抱歉,我没有回答您的问题。上面提供了有关输入文件的所有信息(以及它本身)。