0

I'm using FFmpeg to merge an MKA and MKV files to generate an MP4 file.

The command shown below is working good sometimes:

  • 1st pair of mkv/mka : gives a successful MP4 with no problems in audio/video.

  • 2nd pair of mkv/mka : the audio of output.mp4 is distorted (I mean just noise) but the video track itself is working fine.

  • 3rd pair of mkv/mka : the audio is working fine but video speed slows down. I think it decreases the bit rate of output mp4.

I'm using this command:

ffmpeg -i m.mkv -i m.mka -c:v libx264 -c:a aac -map 0:v:0 -map 1:a:0 output.mp4

The codec of mka is "opus: while codec of mpv is "vp8"

here I also attached the ss of properties of output.mp4

enter image description here

VC.One
  • 14,790
  • 4
  • 25
  • 57
habib
  • 1,454
  • 17
  • 31
  • 2
    *"It's working great for one pair but for other pair (mkv + mka), it really slows down the output"*? Are you expecting us to guess the differences between your various pairs? Why are you posting an image of the properties of output.mp4, when the issue is related to the input? Can you share a sample of your input? – Rotem Jan 24 '22 at 17:27

1 Answers1

0
  • 2nd pair of mkv/mka : the audio of output.mp4 is distorted (I mean just noise) but the video track itself is working fine.

  • 3rd pair of mkv/mka : the audio is working fine but video speed slows down. I think it decreases the bit rate of output mp4.

You have not provided any testable file links or useful details about the codecs (ie: frame rates, etc).
This makes it hard to advise you, but you still can consider the following towards a solution:

(1) Try a basic command (FFmpeg will know to use AAC since it's MP4)

ffmpeg -i m.mkv -i m.mka output.mp4

(2) For distorted audio : Convert the audio m.mka to AAC first then try

ffmpeg -i m.mkv -i m.aac -c:a copy output.mp4 

(3) For bad frame rate : I suspect you have variable frame rate There is no frame rate in MKV just timestamps for each frame (PTS). For example in a 30 FPS video, if a frame image looks same for one second then the FPS for that image is 1000/1 (1 frame for 1 second), but next frames could be 1000/30 (making 30 frames in 1 second). I suspect FFmpeg calculated wrong based on either metadata or even first few frames (since the FPS should be constant by default, it actually correct to do this).

Possible fix:
Try setting an output framerate (example 60 FPS)

ffmpeg -i m.mkv -i m.mka -r 60 output.mp4
VC.One
  • 14,790
  • 4
  • 25
  • 57