VideoHelp Forum
+ Reply to Thread
Results 1 to 16 of 16
Thread
  1. Hey,

    I have an audio and video file i want to mux together into a MKV container. files are video.mkv and audio.m4a. Both of these files have bitrate in the metadata but when i mux them using this command into a mkv. `ffmpeg -i video.mkv -i audio.m4a -map 0 -map 1 -c copy output.mkv` there is no bitrate for video or audio but there is an overall bitrate.

    Now if i mux them into a mp4 container the bitrate meta data are there. I have tired using -map_metadata 1 which i seen posted would transfer the metadata but doesn't.

    video mediainfo
    Code:
    General
    Unique ID                                : 244809118920359629491762342051475808478 (0xB82C857286A6134DDE6AF7BE9A7AE0DE)
    Complete name                            : v1.mkv
    Format                                   : Matroska
    Format version                           : Version 4
    File size                                : 427 MiB
    Duration                                 : 10 min 0 s
    Overall bit rate                         : 5 973 kb/s
    Writing application                      : Lavf58.45.100
    Writing library                          : Lavf58.45.100
    ErrorDetectionType                       : Per level 1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Format settings, GOP                     : M=3, N=50
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 10 min 0 s
    Bit rate                                 : 5 854 kb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.113
    Stream size                              : 419 MiB (98%)
    Default                                  : Yes
    Forced                                   : No
    Color range                              : Limited
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    audio mediainfo
    Code:
    General
    Complete name                            : v1.m4a
    Format                                   : MPEG-4
    Format profile                           : Apple audio with iTunes info
    Codec ID                                 : M4A  (M4A /isom/iso2)
    File size                                : 9.26 MiB
    Duration                                 : 10 min 0 s
    Overall bit rate mode                    : Constant
    Overall bit rate                         : 130 kb/s
    Writing application                      : Lavf58.45.100
    
    Audio
    ID                                       : 1
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 10 min 0 s
    Bit rate mode                            : Constant
    Bit rate                                 : 128 kb/s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 9.16 MiB (99%)
    Language                                 : English
    Default                                  : Yes
    Alternate group                          : 1
    MKV output media info after running `ffmpeg -i v1.mkv -i v1.m4a -map 0 -map 1 -c copy -map_metadata 1 output.mkv`
    Code:
    General
    Unique ID                                : 325517703584640152619819065611482253966 (0xF4E46DE50B3D88B35AB2D782F1EF4A8E)
    Complete name                            : output.mkv
    Format                                   : Matroska
    Format version                           : Version 4
    File size                                : 437 MiB
    Duration                                 : 10 min 0 s
    Overall bit rate                         : 6 103 kb/s
    Writing application                      : Lavf58.45.100
    Writing library                          : Lavf58.45.100
    ErrorDetectionType                       : Per level 1
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Format settings, GOP                     : M=3, N=50
    Codec ID                                 : V_MPEG4/ISO/AVC
    Duration                                 : 10 min 0 s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Default                                  : Yes
    Forced                                   : No
    Color range                              : Limited
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : A_AAC-2
    Duration                                 : 10 min 0 s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Language                                 : English
    Default                                  : Yes
    Forced                                   : No

    MP4 output media info after running `ffmpeg -i v1.mkv -i v1.m4a -map 0 -map 1 -c copy -map_metadata 1 output.mp4`
    Code:
    General
    Complete name                            : output.mp4
    Format                                   : MPEG-4
    Format profile                           : Base Media
    Codec ID                                 : isom (isom/iso2/avc1/mp41)
    File size                                : 437 MiB
    Duration                                 : 10 min 0 s
    Overall bit rate                         : 6 104 kb/s
    Writing application                      : Lavf58.45.100
    
    Video
    ID                                       : 1
    Format                                   : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : High@L4
    Format settings                          : CABAC / 4 Ref Frames
    Format settings, CABAC                   : Yes
    Format settings, Reference frames        : 4 frames
    Format settings, GOP                     : M=3, N=50
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Duration                                 : 10 min 0 s
    Bit rate                                 : 5 971 kb/s
    Width                                    : 1 920 pixels
    Height                                   : 1 080 pixels
    Display aspect ratio                     : 16:9
    Frame rate mode                          : Constant
    Frame rate                               : 25.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:0
    Bit depth                                : 8 bits
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 0.115
    Stream size                              : 427 MiB (98%)
    Color range                              : Limited
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    Codec configuration box                  : avcC
    
    Audio
    ID                                       : 2
    Format                                   : AAC LC
    Format/Info                              : Advanced Audio Codec Low Complexity
    Codec ID                                 : mp4a-40-2
    Duration                                 : 10 min 0 s
    Bit rate mode                            : Constant
    Bit rate                                 : 128 kb/s
    Channel(s)                               : 2 channels
    Channel layout                           : L R
    Sampling rate                            : 48.0 kHz
    Frame rate                               : 46.875 FPS (1024 SPF)
    Compression mode                         : Lossy
    Stream size                              : 9.16 MiB (2%)
    Language                                 : English
    Default                                  : Yes
    Alternate group                          : 1

    version of ffmpeg
    Code:
    ffmpeg version 4.3.6-0+deb11u1 Copyright (c) 2000-2023 the FFmpeg developers
    built with gcc 10 (Debian 10.2.1-6)
    configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
    libavutil      56. 51.100 / 56. 51.100
    libavcodec     58. 91.100 / 58. 91.100
    libavformat    58. 45.100 / 58. 45.100
    libavdevice    58. 10.100 / 58. 10.100
    libavfilter     7. 85.100 /  7. 85.100
    libavresample   4.  0.  0 /  4.  0.  0
    libswscale      5.  7.100 /  5.  7.100
    libswresample   3.  7.100 /  3.  7.100
    libpostproc    55.  7.100 / 55.  7.100

    Anyone have any idea how to get the meta data from the original files into the mux MKV file?
    Last edited by grimeire; 18th Sep 2023 at 10:48.
    Quote Quote  
  2. Try -map_metadata 0
    Quote Quote  
  3. Originally Posted by ProWo View Post
    Try -map_metadata 0
    nope still the same
    Quote Quote  
  4. Then add
    -movflags use_metadata_tags
    Quote Quote  
  5. Originally Posted by ProWo View Post
    Then add
    -movflags use_metadata_tags

    tired both these and still the same.

    ffmpeg -i v1.mkv -i v1.m4a -map 0 -map 1 -c copy -map_metadata 0 -movflags use_metadata_tags output.mkv

    ffmpeg -i v1.mkv -i v1.m4a -map 0 -map 1 -c copy -movflags use_metadata_tags output.mkv

    Does it matter where the options are passed in the command?
    Quote Quote  
  6. Your commandline is fine.
    The problem is that your video stream does not contain bitrate info.
    With mp4 this is calculated and added by the mp4 muxer.
    The mkv muxer takes the tags of the individual streams and that is missing this info.
    Quote Quote  
  7. Mux to mp4 first, then mux from the mp4 to mkv?
    Quote Quote  
  8. Could be caused by the variable bitrate of the aac audio stream...

    Try to recode the audiostream to ac3 2ch 256k and then remux this ac3 stream with your mkv videostream to mkv.
    Then check, if both bitrates (audio and video) are shown in mediainfo.
    Last edited by ProWo; 18th Sep 2023 at 12:29.
    Quote Quote  
  9. Originally Posted by jagabo View Post
    Mux to mp4 first, then mux from the mp4 to mkv?
    Thank you I appreciate the help

    so i tired that and still get the same result. the mux mp4 does have the bitrate data but when i convert it to mkv it doesnt.


    here is the command i used. Also tired it without '-map_metadata 0 -movflags use_metadata_tags'
    ffmpeg -i output.mp4 -map 0 -c copy -map_metadata 0 -movflags use_metadata_tags output.mkv

    I dont really want to convert audio as it just adding additional steps for no real benefit.
    Last edited by grimeire; 18th Sep 2023 at 14:59.
    Quote Quote  
  10. Originally Posted by grimeire View Post
    I dont really want to convert audio as it just adding additional steps for no real benefit.
    Not for real, just as test...
    Quote Quote  
  11. Member netmask56's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Search Comp PM
    Why not just drag and drop the audio and video files into mkvtoolnix? Run mkvtoolnix-gui.exe, drag and drop the audio and video files into the source files box, and then click the Start Multiplexing button. done!
    SONY 75" Full array 200Hz LED TV, Yamaha A1070 amp, Zidoo UHD3000, BeyonWiz PVR V2 (Enigma2 clone), Chromecast, Windows 11 Professional, QNAP NAS TS851
    Quote Quote  
  12. Originally Posted by netmask56 View Post
    Why not just drag and drop the audio and video files into mkvtoolnix? Run mkvtoolnix-gui.exe, drag and drop the audio and video files into the source files box, and then click the Start Multiplexing button. done!
    This is a headless machine so no UI.
    Quote Quote  
  13. Originally Posted by ProWo View Post
    Could be caused by the variable bitrate of the aac audio stream...

    Try to recode the audiostream to ac3 2ch 256k and then remux this ac3 stream with your mkv videostream to mkv.
    Then check, if both bitrates (audio and video) are shown in mediainfo.

    why 256k the bit rate from mediainfo says its 128K constant and not variable.

    any suggestion on the command for this? dont ever really ever convert audio so open to suggestions
    Quote Quote  
  14. Originally Posted by grimeire View Post
    why 256k the bit rate from mediainfo says its 128K constant and not variable.

    any suggestion on the command for this? dont ever really ever convert audio so open to suggestions
    -c:a ac3 - b:a 256k

    This should be constant bitrate.
    Quote Quote  
  15. Originally Posted by grimeire View Post
    Originally Posted by netmask56 View Post
    Why not just drag and drop the audio and video files into mkvtoolnix? Run mkvtoolnix-gui.exe, drag and drop the audio and video files into the source files box, and then click the Start Multiplexing button. done!
    This is a headless machine so no UI.
    mkvmerge CLI
    Quote Quote  
  16. Originally Posted by poisondeathray View Post
    Originally Posted by grimeire View Post
    Originally Posted by netmask56 View Post
    Why not just drag and drop the audio and video files into mkvtoolnix? Run mkvtoolnix-gui.exe, drag and drop the audio and video files into the source files box, and then click the Start Multiplexing button. done!
    This is a headless machine so no UI.
    mkvmerge CLI
    thanks mkvmerge worked a dream
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!