1

I have a video in MKV format that I wanted to convert to MP4, so I used ffmpeg to convert it. The command I used was pretty simple:

ffmpeg -i <path_and_name_of_file>.mkv <path_and_name_of_file>.mp4

I don't really know how to use ffmpeg and since this is probably the only time I plan to use it I looked up how to do it online and it said I can just use that simple command if all I'm doing is changing the file format.

So I did that, and it did the process like normal (it took about 10 hours because it's a 1080p 3+ hours video) but when I tried playing the file it didn't work. I tried Movies & TV and Windows Media Player and they both open the file and show how long it is, but when I hit play nothing happens, not even an error message. But it did play when opening it with VLC Media Player or Chrome.

The problem is, both Movies & TV and WMP play the original MKV file just fine, so I must have done something wrong with FFmpeg. Is it that I have to add more stuff to the command or something?


Update: Sorry it took me so long to come back to this. I'm guessing this bit is what grawity was asking for. The original MKV video:

Input #0, matroska,webm, from '<original_video_path>.mkv':
  Metadata:
    encoder         : libebml v1.4.5 + libmatroska v1.7.1
  Duration: 03:30:24.32, start: 0.000000, bitrate: 8122 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn (default)
  Stream #0:1(eng): Audio: eac3 (Dolby Digital Plus + Dolby Atmos), 48000 Hz, 5.1(side), fltp, 768 kb/s (default)
  Stream #0:2(eng): Subtitle: subrip

The converted MP4 video:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '<converted_video_path>.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.16.100
  Duration: 03:30:24.32, start: 0.000000, bitrate: 4843 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4441 kb/s, 24 fps, 24 tbr, 12288 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      encoder         : Lavc60.31.102 libx264
  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 6 channels, fltp, 394 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
6
  • 3
    The difference might be that VLC comes with its own codecs, but the others use the installed system codecs. You might try installing some good codec pack. My own favorite is the K-Lite Codec Pack.
    – harrymc
    Commented Mar 29 at 12:34
  • What was the original audio/video codec of the MKV file according to ffprobe, and what is the format of the new MP4? Commented Mar 29 at 15:53
  • @JayCravens That seems to have worked. The resulting MP4 video plays just fine and I can see no visual differences so I think it converted properly. Please put your comment as an answer
    – Alfrodo8
    Commented Jun 4 at 14:42
  • @Alfrodo8 Copy that. Answer added.
    – JayCravens
    Commented Jun 4 at 20:40
  • 1
    Both source and unnecessarily converted video are already yuv420p, by the way.
    – Daniel B
    Commented Jun 5 at 4:58

1 Answer 1

0

You need to re-encode, at least to get the bitrate back up.

ffmpeg -i file.mkv -c:v h264 -c:a copy -b:v 8000k -preset ultrafast out.mp4 

Using -c:v h264 will increase play ability. -c:a copy will keep your original 5.1 channel audio track.


@DanielB raises a good point with -c copy, which I overlooked due to his other point, "You should never use it without specifying video and audio handling parameters." Facts.

Also, using yuv420p is correct. It should make x264 play without issue, but requires re-encoding.

6
  • 1
    Actually, re-encoding the video should not be necessary at all.
    – Daniel B
    Commented Jun 4 at 20:48
  • @DanielB That's a good call. -c copy should switch containers, no problem.
    – JayCravens
    Commented Jun 4 at 20:51
  • Why do you suggest copying audio in eac3 format into mp4 but not h264? AAC is the usual, commonplace audio codec for mp4. E-AC-3 is at least not listed on Wikipedia at all. If suggesting copy I would only suggest it for video, which is already h264.
    – Kissaki
    Commented Jun 4 at 21:37
  • What do you mean by "at least to get the bitrate back up"? To my knowledge, ffmpeg has defaults, and h264 will use an adequate compression for good image quality. Unless it's not enough and OP specifically wants higher quality at the cost of time and size I would not specify the bitrate [and to almost double].
    – Kissaki
    Commented Jun 4 at 21:40
  • I don't think -c:v h264 is necessary because ffmpeg will default to h264 when targeting mp4. As per OP edit, the source is h264 too, so ffmpeg will take that over too.
    – Kissaki
    Commented Jun 4 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .