title: FFmpeg iOS -> output file is invalid
body: <p>I'm using following library to convert mkv to mp4: <a href="https://github.com/SterlingOnLoop/FFmpegWrapper" rel="nofollow">https://github.com/SterlingOnLoop/FFmpegWrapper</a>. </p>
  
  <pre><code>- (void)convertUsingFFmpegWrapper {
      NSString *mp4Extension = @"mp4";
      NSString *mkvExtension = @"mkv";
  
      NSString *videoName = @"file1";
  //    NSString *videoName = @"file2";
  
      NSString *mkvVideoFilePath = [[NSBundle mainBundle] pathForResource:videoName ofType:mkvExtension];
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = paths[0];
      NSString *mp4VideoFilePath = [NSString stringWithFormat:@"%@/%@.%@", documentsDirectory, videoName, mp4Extension];
  
      FFmpegWrapper *ffmpegWrapper = [[FFmpegWrapper alloc] init];
      NSDictionary *options = @{kFFmpegInputFormatKey: mkvExtension, kFFmpegOutputFormatKey: mp4Extension};
      [ffmpegWrapper convertInputPath:mkvVideoFilePath outputPath:mp4VideoFilePath options:options progressBlock:nil completionBlock:^(BOOL success, NSError *error) {
          if (success &amp;&amp; !error) {
              // delete mp4 file
          } else if (error) {
              NSLog(@"Error during .MKV -&gt; .MP4 conversion occured: %@", error.localizedDescription);
          } else {
              NSLog(@"Unknown error during .MKV -&gt; .MP4 conversion occured.");
          }
      }];
  }
  </code></pre>
  
  <p>Here are the values from LLDB about the automatically detected codec types:</p>
  
  <pre><code>(lldb) po inputStream.codecName
  aac
  
  (lldb) po outputStream.codecName
  aac
  </code></pre>
  
  <p>I should mention here, that originally the file is generated on Linux with following codecs: <code>vaapiencode_h264</code> for video and <code>faac</code> for sound.</p>
  
  <p>The issue is that the file simply does not work. I get huge amount of logs in the console, where most important is:</p>
  
  <pre><code>[aac @ 0x7f7f65019200] Format aac detected only with low score of 1, misdetection possible!
  </code></pre>
  
  <p>Inside the library, the following function is used:</p>
  
  <pre><code>int streamInfoValue = avformat_find_stream_info(inputFormatContext, NULL);
  </code></pre>
  
  <p>And exactly this line does the whole mess with the logs. Obviously, without this line I receive an error with invalid argument.</p>
  
  <p>When that line is turned on, the .mp4 file is generated. It lasts > 5 minutes, while input file is 11 seconds long. It cannot be played using VLC on my mac (seems to be broken). I get following errors (I'm pasting few of them, full track can be found <a href="https://gist.github.com/natalia-osa/988b6f84f0e1da5519b3b7fbd2c574c8" rel="nofollow">here</a>, it's too long to quote it here):</p>
  
  <pre><code>[aac @ 0x7ff07c00b000] More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
  [aac @ 0x7ff07c00b000] channel element 0.0 is not allocated
  [aac @ 0x7ff07c00b000] Sample rate index in program config element does not match the sample rate index configured by the container.
  [aac @ 0x7ff07c00b000] Inconsistent channel configuration.
  [aac @ 0x7ff07c00b000] get_buffer() failed
  [aac @ 0x7ff07c00b000] channel element 3.10 is not allocated
  [aac @ 0x7ff07c00b000] Reserved bit set.
  [aac @ 0x7ff07c00b000] invalid band type
  [aac @ 0x7ff07c00b000] Number of scalefactor bands in group (50) exceeds limit (41).
  [aac @ 0x7ff07c00b000] Reserved bit set.
  [aac @ 0x7ff07c00b000] Number of bands (7) exceeds limit (4).
  [aac @ 0x7ff07c00b000] Reserved bit set.
  [aac @ 0x7ff07c00b000] Dependent coupling is not supported together with LTP
  </code></pre>
  
  <p>Any idea how to simply convert mkv to mp4? I don't have any idea why the errors occurs. I'd claim that the file is not aac, but the linux uses this encoding, so it should be valid.</p>