1

I have a video file and I try to operate with it by means of fluent-ffmpeg. Here is an information which I get about this file with ffprobe. You can see that video duration is 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: [] }

However, if I concatenate two such files into a single one:

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

the duration of result is 12.005 instead of 12.028 expected:

{ 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: [] }

I've already looked through this question but it seems doesn't help as long as it is exactly the same file so all stats are the same.

So, main questions are "Why result duration differs from sum of two files?" and "How to fix it?".

Could anybody suggest some help? Thanks in advance.

Sergey Mell
  • 7,780
  • 1
  • 26
  • 50

0 Answers0