Log in

View Full Version : MKV to MP4 creates redundant menu stream


unknownsoldierX
17th April 2016, 15:35
I have a batch of MKVs I'm trying to convert to MP4. The original MKVs have a single menu stream, but the MP4s created by FFmpeg have a second, redundant menu.

I'm not sure if this will present any playback issues on any devices, but it's annoying and I'm curious what's causing this.

ffmpeg.exe -i "S03E01- Chapter 27.mkv" -acodec copy -vcodec copy -sn "S03E01- Chapter 27.mp4"

ffmpeg version N-74525-gdb91e0e Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 58.100 / 56. 58.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 35.100 / 5. 35.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[aac @ 0000000002f5ca40] element type mismatch 1 != 0
Input #0, matroska,webm, from 'S03E01- Chapter 27.mkv':
Metadata:
encoder : libebml v1.3.1 + libmatroska v1.4.2
creation_time : 2015-07-24 14:09:58
Duration: 00:58:27.53, start: 0.000000, bitrate: 922 kb/s
Chapter #0:0: start 0.000000, end 288.788000
Metadata:
title : 00:00:00.000
Chapter #0:1: start 288.788000, end 540.915000
Metadata:
title : 00:04:48.788
Chapter #0:2: start 540.915000, end 1138.012000
Metadata:
title : 00:09:00.915
Chapter #0:3: start 1138.012000, end 1717.925000
Metadata:
title : 00:18:58.012
Chapter #0:4: start 1717.925000, end 2246.035000
Metadata:
title : 00:28:37.925
Chapter #0:5: start 2246.035000, end 2863.903000
Metadata:
title : 00:37:26.035
Chapter #0:6: start 2863.903000, end 3369.575000
Metadata:
title : 00:47:43.903
Chapter #0:7: start 3369.575000, end 3507.529000
Metadata:
title : 00:56:09.575
Stream #0:0: Video: h264 (High), yuv420p, 1280x640 [SAR 1:1 DAR 2:1], 23.98
fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
BPS : 872457
BPS-eng : 872457
DURATION : 00:58:27.421000000
DURATION-eng : 00:58:27.421000000
NUMBER_OF_FRAMES: 84094
NUMBER_OF_FRAMES-eng: 84094
NUMBER_OF_BYTES : 382509362
NUMBER_OF_BYTES-eng: 382509362
_STATISTICS_WRITING_APP: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_DATE_UTC: 2015-07-24 14:09:58
_STATISTICS_WRITING_DATE_UTC-eng: 2015-07-24 14:09:58
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: aac (HE-AAC), 48000 Hz, stereo, fltp (default)
Metadata:
BPS : 47774
BPS-eng : 47774
DURATION : 00:58:27.498000000
DURATION-eng : 00:58:27.498000000
NUMBER_OF_FRAMES: 82207
NUMBER_OF_FRAMES-eng: 82207
NUMBER_OF_BYTES : 20945982
NUMBER_OF_BYTES-eng: 20945982
_STATISTICS_WRITING_APP: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_DATE_UTC: 2015-07-24 14:09:58
_STATISTICS_WRITING_DATE_UTC-eng: 2015-07-24 14:09:58
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:2: Subtitle: subrip (default)
Metadata:
title : English
BPS : 71
BPS-eng : 71
DURATION : 00:55:45.900000000
DURATION-eng : 00:55:45.900000000
NUMBER_OF_FRAMES: 877
NUMBER_OF_FRAMES-eng: 877
NUMBER_OF_BYTES : 29901
NUMBER_OF_BYTES-eng: 29901
_STATISTICS_WRITING_APP: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_DATE_UTC: 2015-07-24 14:09:58
_STATISTICS_WRITING_DATE_UTC-eng: 2015-07-24 14:09:58
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[mp4 @ 0000000002ff8280] Codec for stream 0 does not use global headers but cont
ainer format requires global headers
[mp4 @ 0000000002ff8280] Codec for stream 1 does not use global headers but cont
ainer format requires global headers
Output #0, mp4, to 'S03E01- Chapter 27.mp4':
Metadata:
encoder : Lavf56.40.101
Chapter #0:0: start 0.000000, end 288.788000
Metadata:
title : 00:00:00.000
Chapter #0:1: start 288.788000, end 540.915000
Metadata:
title : 00:04:48.788
Chapter #0:2: start 540.915000, end 1138.012000
Metadata:
title : 00:09:00.915
Chapter #0:3: start 1138.012000, end 1717.925000
Metadata:
title : 00:18:58.012
Chapter #0:4: start 1717.925000, end 2246.035000
Metadata:
title : 00:28:37.925
Chapter #0:5: start 2246.035000, end 2863.903000
Metadata:
title : 00:37:26.035
Chapter #0:6: start 2863.903000, end 3369.575000
Metadata:
title : 00:47:43.903
Chapter #0:7: start 3369.575000, end 3507.529000
Metadata:
title : 00:56:09.575
Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x640 [SAR 1:
1 DAR 2:1], q=2-31, 23.98 fps, 23.98 tbr, 16k tbn, 1k tbc (default)
Metadata:
BPS : 872457
BPS-eng : 872457
DURATION : 00:58:27.421000000
DURATION-eng : 00:58:27.421000000
NUMBER_OF_FRAMES: 84094
NUMBER_OF_FRAMES-eng: 84094
NUMBER_OF_BYTES : 382509362
NUMBER_OF_BYTES-eng: 382509362
_STATISTICS_WRITING_APP: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_DATE_UTC: 2015-07-24 14:09:58
_STATISTICS_WRITING_DATE_UTC-eng: 2015-07-24 14:09:58
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo (def
ault)
Metadata:
BPS : 47774
BPS-eng : 47774
DURATION : 00:58:27.498000000
DURATION-eng : 00:58:27.498000000
NUMBER_OF_FRAMES: 82207
NUMBER_OF_FRAMES-eng: 82207
NUMBER_OF_BYTES : 20945982
NUMBER_OF_BYTES-eng: 20945982
_STATISTICS_WRITING_APP: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_APP-eng: mkvmerge v8.2.0 ('World of Adventure') 64bit
_STATISTICS_WRITING_DATE_UTC: 2015-07-24 14:09:58
_STATISTICS_WRITING_DATE_UTC-eng: 2015-07-24 14:09:58
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 5383 fps=0.0 q=-1.0 size= 38353kB time=00:03:44.67 bitrate=1398.5kbits/
frame=11149 fps=0.0 q=-1.0 size= 74276kB time=00:07:45.05 bitrate=1308.4kbits/
frame=17707 fps=11774 q=-1.0 size= 100488kB time=00:12:18.71 bitrate=1114.4kbit
frame=24332 fps=12142 q=-1.0 size= 128263kB time=00:16:55.11 bitrate=1035.1kbit
frame=31084 fps=12414 q=-1.0 size= 156963kB time=00:21:36.54 bitrate= 991.7kbit
frame=37637 fps=12529 q=-1.0 size= 181573kB time=00:26:09.94 bitrate= 947.4kbit
frame=42787 fps=12211 q=-1.0 size= 209333kB time=00:29:44.73 bitrate= 960.8kbit
frame=49725 fps=12419 q=-1.0 size= 240305kB time=00:34:34.22 bitrate= 949.1kbit
frame=56276 fps=12454 q=-1.0 size= 268861kB time=00:39:07.20 bitrate= 938.4kbit
frame=63439 fps=12641 q=-1.0 size= 297755kB time=00:44:06.13 bitrate= 921.8kbit
frame=71184 fps=12899 q=-1.0 size= 331311kB time=00:49:29.28 bitrate= 914.1kbit
frame=78622 fps=13063 q=-1.0 size= 363525kB time=00:54:39.30 bitrate= 908.1kbit
frame=84094 fps=12996 q=-1.0 Lsize= 396547kB time=00:58:27.52 bitrate= 926.2kbi
ts/s
video:373544kB audio:20455kB subtitle:0kB other streams:0kB global headers:0kB m
uxing overhead: 0.646495%

Complete name : G:\Temp\S03E01- Chapter 27.mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom (isom/iso2/avc1/mp41)
File size : 387 MiB
Duration : 58mn 27s
Overall bit rate : 926 Kbps
Writing application : Lavf56.40.101

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 58mn 27s
Bit rate : 872 Kbps
Width : 1 280 pixels
Height : 640 pixels
Display aspect ratio : 2.000
Frame rate mode : Variable
Frame rate : 23.976 (24000/1001) fps
Minimum frame rate : 23.564 fps
Maximum frame rate : 24.390 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.044
Stream size : 365 MiB (94%)
Writing library : x264 core 138 r2358 9e941d1
Encoding settings : cabac=1 / ref=5 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=12 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=872 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00
Menus : 3

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : HE-AAC / LC
Codec ID : 40
Duration : 58mn 27s
Bit rate mode : Constant
Bit rate : 48.0 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz / 24.0 KHz
Frame rate : 23.438 fps (1024 spf)
Compression mode : Lossy
Stream size : 20.0 MiB (5%)
Language : English
Default : Yes
Alternate group : 1
Menus : 3

Menu #1
ID : 3
Codec ID : text
Duration : 58mn 27s
Language : English
Bit rate mode : CBR
Menu For : 1,2
00:00:00.000 : 00:00:00.000
00:04:48.788 : 00:04:48.788
00:09:00.915 : 00:09:00.915
00:18:58.012 : 00:18:58.012
00:28:37.925 : 00:28:37.925
00:37:26.035 : 00:37:26.035
00:47:43.903 : 00:47:43.903
00:56:09.575 : 00:56:09.575

Menu #2
00:00:00.000 : 00:00:00.000
00:04:48.788 : 00:04:48.788
00:09:00.915 : 00:09:00.915
00:18:58.012 : 00:18:58.012
00:28:37.925 : 00:28:37.925
00:37:26.035 : 00:37:26.035
00:47:43.903 : 00:47:43.903
00:56:09.575 : 00:56:09.575

Jamaika
18th April 2016, 09:34
I'm not sure if this will present any playback issues on any devices, but it's annoying and I'm curious what's causing this.
It shouldn't be a problem. It reportedly menu 1 is for MAC.

How much it bothers you. Demuxer track on the prime factors and muxer in mp4box.
mkvextract.exe tracks "S03E01- Chapter 27.mkv" 0:111.h264 1:111.ac3 2:111.sup
ffmpeg -i "S03E01- Chapter 27.mkv" -f adts -c:a aac -ab 192k -ac 2 -ar 48000 111.aac
ffmpeg -i "S03E01- Chapter 27.mkv" -f srt -c:s srt 111.srt
mkvextract.exe chapters -s "S03E01- Chapter 27.mkv" >> chapter.txt
mp4box.exe -new -info -add 111.h264:fmt=h264:fps=23.976:noedit:trailing:xps_inband -add 111.aac -add 111.srt -add chapter.txt 111.mp4

unknownsoldierX
18th April 2016, 14:20
What do you mean by 'MAC'? As in Apple?

Is there no way to have ffmpeg put output just the original menu? This happens with every MKV that has a menu that I convert to MP4.

Jamaika
18th April 2016, 16:35
What do you mean by 'MAC'? As in Apple?
First Menu #1 is for standard Quicktime
Second Menu #2 is for standard Nero
Is there no way to have ffmpeg put output just the original menu? This happens with every MKV that has a menu that I convert to MP4.
You can turn off chapter Nero. Quicktime is for FFmpeg priority.

unknownsoldierX
18th April 2016, 19:42
Thanks. I hadn't seen any explanation anywhere. I've added -movflags disable_chpl to my command and now there is only one chapter stream. I've read that Nero chapters can cause problems, and there seems to be no need for them anyway.

You seem pretty knowledgeable, so I'd like to ask you another question. Is there a way to set a flag to have subtitles to be enabled by default?

I have some MKV files with subtitles I'm converting to MP4 containers. When I open the MKV files with VLC or whatever, the subtitles are enabled automatically. I convert them to MP4, and when I open the MP4, I need to go into the menu and enable subtitles.

Jamaika
19th April 2016, 06:25
http://forum.doom9.org/archive/index.php/t-165224.html
I don't know how works the VLC player. I have the MPC-HC. The functions default/forced on or not enabled do not affect the display of subtitles. It isn't possible not to display subtitles in MPC-HC. The first subtitle is always on, the rest off. You can change the track 'default' of the function 'disposition', but my player doesn't see it. The player doesn't respond to function container MP4 'default/forced'.
The 'metadata disposition:forced' is dead function in ffmpeg. Ie. which isn't to be typed track is enabled in MediaInfo. It seems that the mp4 container no function 'forced'.
The function "-disposition:3 forced" is only matroska and bluray. All subtitle tracks are then turn on in the "default". This option isn't recommended. It must be installed LAVfilters.
The function "-disposition:3 default" work used in the player MPC-HC v1.7.10.172 with container Matroska.
http://forum.doom9.org/archive/index.php/t-167595.html

ffmpeg.exe -i input.h265 -i input.ac3 -i input.ass -f mp4 -map 0:0 -c:v copy -map 1:0 -c:a aac -map 2:0 -c:s mov_text -metadata:s:2 disposition:default=0 -metadata:s:2 disposition:forced=0
-metadata:s:2 language=pol -metadata:s:2 handler=Subtitle output.mp4
It is more correct recording function ffmpeg v20160412:
ffmpeg.exe -i input.h265 -i input.ac3 -i input.ass -i input.ass -i input.ass -f mp4/mov -map 0:0 -c:v copy -map 1:0 -c:a aac -disposition:3 default -movflags faststart
-map 2:0 -c:s mov_text -metadata:s:2 language=fra -metadata:s:2 handler=Subtitle
-map 3:0 -c:s mov_text -metadata:s:3 language=pol -metadata:s:3 handler=Subtitle
-map 4:0 -c:s mov_text -metadata:s:4 language=eng -metadata:s:4 handler=Subtitle output.mp4/mov

I know how to turn off track in the MP4Box. Although not entirely recommend this muxer.
mp4box -add input.h265:mpeg4:noedit:trailing:xps_inband:name=
-add input.srt:disable:lang=fr:name=Subtitle
-add input.srt:lang=pol:name=Subtitle
-add input.srt:disable:lang=eng:name=Subtitle -new -info output.mp4
http://i67.tinypic.com/2efkt21.jpghttp://i67.tinypic.com/2vnl5i1.png<-- don't view default/forced subtitles, player always selects the first subtitle