Opened 17 months ago

Last modified 17 months ago

#8697 new defect

ffmpeg can't detect the language tag of mkv files after editing with mkvpropedit

Reported by: random404 Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mkv
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

If you change the language of some mkv files with mkvpropedit, ffmpeg fails to see the new language even after remuxing the file again or running mkclean on the files.

Change History (6)

comment:1 by mkver, 17 months ago

Keywords: mkv added
Priority: importantnormal

Does your file have a tag called "LANGUAGE"?

comment:2 by random404, 17 months ago

Keywords: mkv removed
Priority: normalimportant

confirmed by https://gitlab.com/mbunkus/mkvtoolnix/-/issues/2826

and yes, like i said, both mkvinfo and mediainfo can see the correct language...only ffmpeg and ffprobe think it's undefined

Last edited 17 months ago by random404 (previous) (diff)

comment:3 by Carl Eugen Hoyos, 17 months ago

Component: undeterminedavdevice
Keywords: mkv added
Priority: importantminor

Please provide the command line you tested together with the complete, uncut console output and an input sample to make this a valid ticket.

comment:4 by mkver, 17 months ago

Component: avdeviceavformat
Priority: minornormal

Related to #7549. In this ticket, a tag that is parsed later overwrites a part of the metadata that has already been set via non-tags (via the TrackEntry's Language element); in #7549, an edition tag called TITLE is treated as if it were a segment's title.

Given that Matroska tags are supposed to be upper-case, one could distinguish the two by using AV_DICT_MATCH_CASE in both the demuxer as well as the muxer. But FFmpeg doesn't exist for Matroska alone and I don't know whether this might break anything. Most other demuxers use the key "title" for the title; only the mv demuxer seems to be setting "TITLE". Any title from mv would then be mapped to a tag which doesn't seem intended. My patch based upon this furthermore needs to change ff_metadata_conv slightly. I don't think that this will break anything though.

comment:5 by random404, 17 months ago

This is my original, untouched file:

Mediainfo output:

General
Unique ID                                : 23332720418937201122794855998739214663 (0x118DB7EF371902B27D405ABC76B87147)
Complete name                            : 40 Orgalorg.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 83.7 MiB
Duration                                 : 10 min 45 s
Overall bit rate                         : 1 088 kb/s
Writing application                      : HandBrake 0.10.0 2014112200
Writing library                          : Lavf55.12.0

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 10 min 45 s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Writing library                          : x264 core 142 r2479 dd79a61
Encoding settings                        : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=3 / 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=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=300 / keyint_min=30 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=20000 / vbv_bufsize=25000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : A_AAC-2
Duration                                 : 10 min 45 s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Delay relative to video                  : -23 ms
Title                                    : Stereo
Default                                  : Yes
Forced                                   : No

mkvinfo output:

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ Maximum EBML ID length: 4
|+ Maximum EBML size length: 8
|+ Document type: matroska
|+ Document type version: 2
|+ Document type read version: 2
+ Segment: size 87805255
|+ Seek head (subentries will be skipped)
|+ EBML void: size 147
|+ Segment information
| + Timestamp scale: 1000000
| + Multiplexing application: Lavf55.12.0
| + Writing application: HandBrake 0.10.0 2014112200
| + Segment UID: 0x11 0x8d 0xb7 0xef 0x37 0x19 0x02 0xb2 0x7d 0x40 0x5a 0xbc 0x76 0xb8 0x71 0x47
| + Duration: 00:10:45.579000000
|+ Tracks
| + Track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Lacing flag: 0
|  + Language: und
|  + Codec ID: V_MPEG4/ISO/AVC
|  + Track type: video
|  + Default duration: 00:00:00.033366666 (29.970 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1280
|   + Pixel height: 720
|   + Display width: 1280
|   + Display height: 720
|   + Display unit: 3 (aspect ratio)
|  + Codec's private data: size 43 (H.264 profile: Main @L4.0)
| + Track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 2
|  + Lacing flag: 0
|  + Name: Stereo
|  + Language: und
|  + Codec ID: A_AAC
|  + Track type: audio
|  + Audio track
|   + Channels: 2
|   + Sampling frequency: 44100
|  + Codec's private data: size 5
|+ Tags
| + Tag
|  + Targets
|  + Simple
|   + Name: ENCODER
|   + String: Lavf55.12.0
| + Tag
|  + Targets
|   + Track UID: 2
|  + Simple
|   + Name: LANGUAGE
|   + String: und
|+ Cluster

ffmpeg output:

ffmpeg version N-52628-g79e3c4dd74-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 43.100 / 56. 43.100
  libavcodec     58. 82.100 / 58. 82.100
  libavformat    58. 42.102 / 58. 42.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 80.100 /  7. 80.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from '40 Orgalorg.mkv':
  Metadata:
    ENCODER         : Lavf55.12.0
  Duration: 00:10:45.58, start: 0.044000, bitrate: 1088 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 180k tbc (default)
    Stream #0:1(und): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Stereo
      LANGUAGE        : und
At least one output file must be specified

Then I now run:

mkvpropedit 'file.mkv' --edit track:2 --set language=por

Now mkvinfo output:

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ Maximum EBML ID length: 4
|+ Maximum EBML size length: 8
|+ Document type: matroska
|+ Document type version: 2
|+ Document type read version: 2
+ Segment: size 87805255
|+ Seek head (subentries will be skipped)
|+ EBML void: size 147
|+ Segment information
| + Timestamp scale: 1000000
| + Multiplexing application: Lavf55.12.0
| + Writing application: HandBrake 0.10.0 2014112200
| + Segment UID: 0x11 0x8d 0xb7 0xef 0x37 0x19 0x02 0xb2 0x7d 0x40 0x5a 0xbc 0x76 0xb8 0x71 0x47
| + Duration: 00:10:45.579000000
|+ Tracks
| + Track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Lacing flag: 0
|  + Language: und
|  + Codec ID: V_MPEG4/ISO/AVC
|  + Track type: video
|  + Default duration: 00:00:00.033366666 (29.970 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1280
|   + Pixel height: 720
|   + Display width: 1280
|   + Display height: 720
|   + Display unit: 3 (aspect ratio)
|  + Codec's private data: size 43 (H.264 profile: Main @L4.0)
| + Track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 2
|  + Lacing flag: 0
|  + Name: Stereo
|  + Language: por
|  + Codec ID: A_AAC
|  + Track type: audio
|  + Audio track
|   + Channels: 2
|   + Sampling frequency: 44100
|  + Codec's private data: size 5
|+ Tags
| + Tag
|  + Targets
|  + Simple
|   + Name: ENCODER
|   + String: Lavf55.12.0
| + Tag
|  + Targets
|   + Track UID: 2
|  + Simple
|   + Name: LANGUAGE
|   + String: und
|+ Cluster
†

ffmpeg output which doesn't see the new language tag:

ffmpeg version N-52628-g79e3c4dd74-static https://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Debian 8.3.0-6)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-libgme --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
  libavutil      56. 43.100 / 56. 43.100
  libavcodec     58. 82.100 / 58. 82.100
  libavformat    58. 42.102 / 58. 42.102
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 80.100 /  7. 80.100
  libswscale      5.  6.101 /  5.  6.101
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, matroska,webm, from '40 Orgalorg.mkv':
  Metadata:
    ENCODER         : Lavf55.12.0
  Duration: 00:10:45.58, start: 0.044000, bitrate: 1088 kb/s
    Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 180k tbc (default)
    Stream #0:1(und): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Stereo
      LANGUAGE        : und
At least one output file must be specified

The mediainfo output of the altered file:

General
Unique ID                                : 23332720418937201122794855998739214663 (0x118DB7EF371902B27D405ABC76B87147)
Complete name                            : 40 Orgalorg.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 83.7 MiB
Duration                                 : 10 min 45 s
Overall bit rate                         : 1 088 kb/s
Writing application                      : HandBrake 0.10.0 2014112200
Writing library                          : Lavf55.12.0

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : Main@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 10 min 45 s
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Writing library                          : x264 core 142 r2479 dd79a61
Encoding settings                        : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=3 / 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=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=300 / keyint_min=30 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=crf / mbtree=1 / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=20000 / vbv_bufsize=25000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : A_AAC-2
Duration                                 : 10 min 45 s
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 kHz
Frame rate                               : 43.066 FPS (1024 SPF)
Compression mode                         : Lossy
Delay relative to video                  : -23 ms
Title                                    : Stereo
Language                                 : Portuguese
Default                                  : Yes
Forced                                   : No

I'm not sure I'm allowed to post a sample...is this enough?

Also how can I start using your patch immediately? My scripts rely on the assumption you can trust ffmpeg and mapping by language and mkvpropedit to make changes, if that doesn't work then it breaks everything!

comment:6 by random404, 17 months ago

I just found that if you remove all tags with

mkvpropedit "input.mkv" --tags all:

then ffmpeg will the language tag

output of mkvinfo after doing that:

+ EBML head
|+ EBML version: 1
|+ EBML read version: 1
|+ Maximum EBML ID length: 4
|+ Maximum EBML size length: 8
|+ Document type: matroska
|+ Document type version: 2
|+ Document type read version: 2
+ Segment: size 87805255
|+ Seek head (subentries will be skipped)
|+ EBML void: size 162
|+ Segment information
| + Timestamp scale: 1000000
| + Multiplexing application: Lavf55.12.0
| + Writing application: HandBrake 0.10.0 2014112200
| + Segment UID: 0x11 0x8d 0xb7 0xef 0x37 0x19 0x02 0xb2 0x7d 0x40 0x5a 0xbc 0x76 0xb8 0x71 0x47
| + Duration: 00:10:45.579000000
|+ Tracks
| + Track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track UID: 1
|  + Lacing flag: 0
|  + Language: und
|  + Codec ID: V_MPEG4/ISO/AVC
|  + Track type: video
|  + Default duration: 00:00:00.033366666 (29.970 frames/fields per second for a video track)
|  + Video track
|   + Pixel width: 1280
|   + Pixel height: 720
|   + Display width: 1280
|   + Display height: 720
|   + Display unit: 3 (aspect ratio)
|  + Codec's private data: size 43 (H.264 profile: Main @L4.0)
| + Track
|  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
|  + Track UID: 2
|  + Lacing flag: 0
|  + Name: Stereo
|  + Language: por
|  + Codec ID: A_AAC
|  + Track type: audio
|  + Audio track
|   + Channels: 2
|   + Sampling frequency: 44100
|  + Codec's private data: size 5
|+ EBML void: size 108
|+ Cluster
Last edited 17 months ago by random404 (previous) (diff)
Note: See TracTickets for help on using tickets.