Answers.Body: <p>Firstly, there is nothing wrong with the timebase; ffmpeg can compare timebases, and generate new timebases.</p>
  <p>Secondly, the problem is about different frame rates. if you use <strong>input frame rate settings</strong></p>
  <pre><code>ffmpeg -r 30 -i &quot;{fromPath}&quot; -r 30 -i &quot;{toPath}&quot; ...
  </code></pre>
  <p>or use <strong>filter frame rate settings</strong></p>
  <pre><code>ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0:v]fps=30[v0];[1:v]fps=30[v1];[v0][v1]xfade=transition ...
  </code></pre>
  <p>or use <strong>same frame rate input streams</strong>, i.e. 30 frame per second, on your original command,</p>
  <p>, ffmpeg will have no problems generating an output with fading transitions.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-18T19:38:01.740Z
Answers.LastActivityDate: 2023-11-18T19:38:01.740Z
Answers.UserDisplayName: xer-rex
Body: <p>ffmpeg community</p>
  <p>I am new to ffmpeg and i am facing this error for more then 2 days. This ffmpeg command:
  <code>!ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5&quot; -c:v libx264 -crf 18 -preset veryfast &quot;{outPath}&quot;</code>
  I run that previous command 3 times in row where output of the previous command is input that is getting produced as 15360 timebase video i guess.</p>
  <p>is giving me this error: &quot;First input link main timebase (1/15360) do not match the corresponding second input link xfade timebase (1/90000)&quot;</p>
  <p>So when i merge two of my videos the output is video with (1/15360) timebase. Original videos has (1/90000) timebase.</p>
  <p>Pls help what i wana archive is basicly multiple videos inside a folder called &quot;clips&quot; merge together using a random transition from xfade/ffmpeg.</p>
  <p>On colab i tried all this ways:</p>
  <pre><code>!rm -rf chunks
  !mkdir chunks
  time.sleep(1)
  folderPath = '/content/clips'
  videoOutput = '/content/test.mp4'
  transitionDuration = 6
  
  videoFiles = [f&quot;{folderPath}/{f}&quot; for f in os.listdir(folderPath) if f.endswith('.mp4')]
  random.shuffle(videoFiles)
  fromPath = videoFiles[0]
  toPath = ''
  outPath = ''
  transitions = ['fade', 'wipeup', 'slidedown', 'circleclose', 'radial' , 'hrslice', 'hblur', 'smoothleft', 'smoothright']
  
  for videoIndex, videoName in enumerate(videoFiles):
      if videoIndex == 0:
          continue
      toPath = videoName
      chosenTransition = random.choice(transitions)
      print('chosenTransition', chosenTransition)
      clipDuration = int((imageio.get_reader(fromPath)).get_meta_data()['duration']) - transitionDuration
      # !echo -i /content/clips/clip0.mp4 -i /content/clips/clip1.mp4 -filter_complex xfade=transition={chosenTransition}:duration=3:offset={clipDuration} dissolveVideo.mp4
  
      if videoIndex == len(videoFiles) - 1:
          outPath = videoOutput
      else:
          outPath = f'/content/chunks/chunk{videoIndex}.mp4'
      time.sleep(2)
      
      # !echo -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0:v]xfade=transition={chosenTransition}:duration=3:offset={clipDuration},settb=1/19000[v0];[0:a][1:a]acrossfade=d=3[aout]&quot; -map &quot;[v0]&quot; -map &quot;[aout]&quot; -c:v libx264 -crf 18 -preset ultrafast &quot;{outPath}&quot;
      !ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5,settb=1/15360&quot; -c:v libx264 -crf 18 -preset veryfast &quot;{outPath}&quot;
      # !ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0:v]settb=1/15360,setpts=PTS-STARTPTS[v0];[1:v]settb=1/15360,setpts=PTS-STARTPTS[v1];[v0][v1]xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5[vout]&quot; -map &quot;[vout]&quot; -c:v libx264 -crf 18 -preset ultrafast &quot;{outPath}&quot;
      # !ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0]settb=AVTB [0v]; [1]settb=AVTB [1v]; [0v] [1v]xfade=transition={chosenTransition}:duration={transitionDuration}:offset=1&quot; -c:v libx264 -crf 18 -preset ultrafast &quot;{outPath}&quot;
      # !ffmpeg -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0:v]xfade=transition={chosenTransition}:duration=3:offset={clipDuration},settb=1/15360[v0];[0:a][1:a]acrossfade=d=3[aout]&quot; -map &quot;[v0]&quot; -map &quot;[aout]&quot; -c:v libx264 -crf 18 -preset ultrafast &quot;{outPath}&quot;
      # !ffmpeg -y -progress .progressinfo.dat -i &quot;{fromPath}&quot; -i &quot;{toPath}&quot; -filter_complex &quot;[0:v]settb=AVTB,setpts=PTS-STARTPTS[v0];[1:v]settb=AVTB,setpts=PTS-STARTPTS[v1];[v0][v1]xfade=transition={chosenTransition}:duration={transitionDuration}:offset={clipDuration}[vout];[0:a]asettb=AVTB,asetpts=PTS-STARTPTS[a0];[1:a]asettb=AVTB,asetpts=PTS-STARTPTS[a1];[a0][a1]acrossfade=d=3[aout]&quot; -map &quot;[vout]&quot; -map &quot;[aout]&quot; -c:v libx264 -crf 18 -preset ultrafast &quot;{outPath}&quot;
  </code></pre>
  
Tags: <ffmpeg><ffprobe>
Title: First input link main timebase (1/15360) do not match the corresponding second input link xfade timebase (1/90000)
UserDisplayName: Rino
ThreadText: # First input link main timebase (1/15360) do not match the corresponding second input link xfade timebase (1/90000)
  
  (Asked by: username_0 on 2023-11-15)
  
  ffmpeg community
  
  I am new to ffmpeg and i am facing this error for more then 2 days. This ffmpeg command:
  `!ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5" -c:v libx264 -crf 18 -preset veryfast "{outPath}"`
  I run that previous command 3 times in row where output of the previous command is input that is getting produced as 15360 timebase video i guess.
  
  is giving me this error: "First input link main timebase (1/15360) do not match the corresponding second input link xfade timebase (1/90000)"
  
  So when i merge two of my videos the output is video with (1/15360) timebase. Original videos has (1/90000) timebase.
  
  Pls help what i wana archive is basicly multiple videos inside a folder called "clips" merge together using a random transition from xfade/ffmpeg.
  
  On colab i tried all this ways:
  
  ```
  !rm -rf chunks
  !mkdir chunks
  time.sleep(1)
  folderPath = '/content/clips'
  videoOutput = '/content/test.mp4'
  transitionDuration = 6
  
  videoFiles = [f"{folderPath}/{f}" for f in os.listdir(folderPath) if f.endswith('.mp4')]
  random.shuffle(videoFiles)
  fromPath = videoFiles[0]
  toPath = ''
  outPath = ''
  transitions = ['fade', 'wipeup', 'slidedown', 'circleclose', 'radial' , 'hrslice', 'hblur', 'smoothleft', 'smoothright']
  
  for videoIndex, videoName in enumerate(videoFiles):
      if videoIndex == 0:
          continue
      toPath = videoName
      chosenTransition = random.choice(transitions)
      print('chosenTransition', chosenTransition)
      clipDuration = int((imageio.get_reader(fromPath)).get_meta_data()['duration']) - transitionDuration
      # !echo -i /content/clips/clip0.mp4 -i /content/clips/clip1.mp4 -filter_complex xfade=transition={chosenTransition}:duration=3:offset={clipDuration} dissolveVideo.mp4
  
      if videoIndex == len(videoFiles) - 1:
          outPath = videoOutput
      else:
          outPath = f'/content/chunks/chunk{videoIndex}.mp4'
      time.sleep(2)
      
      # !echo -i "{fromPath}" -i "{toPath}" -filter_complex "[0:v]xfade=transition={chosenTransition}:duration=3:offset={clipDuration},settb=1/19000[v0];[0:a][1:a]acrossfade=d=3[aout]" -map "[v0]" -map "[aout]" -c:v libx264 -crf 18 -preset ultrafast "{outPath}"
      !ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5,settb=1/15360" -c:v libx264 -crf 18 -preset veryfast "{outPath}"
      # !ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "[0:v]settb=1/15360,setpts=PTS-STARTPTS[v0];[1:v]settb=1/15360,setpts=PTS-STARTPTS[v1];[v0][v1]xfade=transition={chosenTransition}:duration={transitionDuration}:offset=-1.5[vout]" -map "[vout]" -c:v libx264 -crf 18 -preset ultrafast "{outPath}"
      # !ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "[0]settb=AVTB [0v]; [1]settb=AVTB [1v]; [0v] [1v]xfade=transition={chosenTransition}:duration={transitionDuration}:offset=1" -c:v libx264 -crf 18 -preset ultrafast "{outPath}"
      # !ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "[0:v]xfade=transition={chosenTransition}:duration=3:offset={clipDuration},settb=1/15360[v0];[0:a][1:a]acrossfade=d=3[aout]" -map "[v0]" -map "[aout]" -c:v libx264 -crf 18 -preset ultrafast "{outPath}"
      # !ffmpeg -y -progress .progressinfo.dat -i "{fromPath}" -i "{toPath}" -filter_complex "[0:v]settb=AVTB,setpts=PTS-STARTPTS[v0];[1:v]settb=AVTB,setpts=PTS-STARTPTS[v1];[v0][v1]xfade=transition={chosenTransition}:duration={transitionDuration}:offset={clipDuration}[vout];[0:a]asettb=AVTB,asetpts=PTS-STARTPTS[a0];[1:a]asettb=AVTB,asetpts=PTS-STARTPTS[a1];[a0][a1]acrossfade=d=3[aout]" -map "[vout]" -map "[aout]" -c:v libx264 -crf 18 -preset ultrafast "{outPath}"
  
  ```
  
  **Tags:** ffmpeg, ffprobe
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-18. Score: 1
  
  Firstly, there is nothing wrong with the timebase; ffmpeg can compare timebases, and generate new timebases.
  
  Secondly, the problem is about different frame rates. if you use **input frame rate settings**
  
  ```
  ffmpeg -r 30 -i "{fromPath}" -r 30 -i "{toPath}" ...
  
  ```
  
  or use **filter frame rate settings**
  
  ```
  ffmpeg -i "{fromPath}" -i "{toPath}" -filter_complex "[0:v]fps=30[v0];[1:v]fps=30[v1];[v0][v1]xfade=transition ...
  
  ```
  
  or use **same frame rate input streams**, i.e. 30 frame per second, on your original command,
  
  , ffmpeg will have no problems generating an output with fading transitions.
  
  
  ---
  
  