13

When a file has more audio tracks, VLC can show their names - or titles, I am not sure about the terminology - in menu under Audio>Audio Track.

When I recode the file with

ffmpeg -i input.mp4 -map 0:0 -map 0:1 -map 0:2  -c:v libx264 -preset slow -profile:v high -crf 17  -c:a copy output.mp4

The names get lost and only generic "Track 1" and "Track 2" appear. How do I keep it? Or how do I set a custom name.

The output of the command is like this:

ffmpeg -ss 0 -i Shades_of_winter_24FPS_x264_5.1_AC3+R128.mp4 -map 0:0 -map 0:1 -map 0:2  -vf "ass=p.ass"  -c:v libx264 -preset slow -profile:v high -crf 17  -c:a copy -metadata:s:a:0:0 -language="ble" -metadata:s:a:1 language="bli" -metadata:s:a:0:2 title="bla"  -t 6 a.mp4
ffmpeg version 2.3.git-1ace957 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jul 26 2014 20:25:06 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-x11grab --enable-libpulse --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr
  libavutil      52. 92.101 / 52. 92.101
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 49.100 / 55. 49.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.102 /  4. 11.102
  libavresample   1.  3.  0 /  1.  3.  0
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Shades_of_winter_24FPS_x264_5.1_AC3+R128.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2014-10-04 00:16:47
    encoder         : HandBrake 0.9.9 2013051800
  Duration: 00:51:22.63, start: 0.000000, bitrate: 19802 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 18780 kb/s, 24 fps, 24 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      creation_time   : 2014-10-04 00:16:47
      encoder         : JVT/AVC Coding
    Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 640 kb/s (default)
    Metadata:
      creation_time   : 2014-10-04 00:16:47
    Stream #0:2(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 197 kb/s
    Metadata:
      creation_time   : 2014-10-12 23:08:29
File 'a.mp4' already exists. Overwrite ? [y/N] y
[Parsed_ass_0 @ 0x1a682a0] Added subtitle file: 'p.ass' (7 styles, 9 events)
[libx264 @ 0x1a87be0] using SAR=1/1
[libx264 @ 0x1a87be0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x1a87be0] profile High, level 5.0
[libx264 @ 0x1a87be0] 264 - core 142 r2389 956c8d8 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 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=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=17.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[mp4 @ 0x1a86a20] track 1: codec frame size is not set
Output #0, mp4, to 'a.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf55.49.100
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2014-10-04 00:16:47
      encoder         : Lavc55.69.100 libx264
    Stream #0:1(und): Audio: ac3 ([165][0][0][0] / 0x00A5), 48000 Hz, 5.1(side), 640 kb/s (default)
    Metadata:
      creation_time   : 2014-10-04 00:16:47
      -language       : ble
      title           : bla
    Stream #0:2(bli): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 197 kb/s
    Metadata:
      creation_time   : 2014-10-12 23:08:29
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
Press [q] to stop, [?] for help
[Parsed_ass_0 @ 0x1a682a0] Neither PlayResX nor PlayResY defined. Assuming 384x288
frame=  144 fps= 79 q=-1.0 Lsize=     651kB time=00:00:06.01 bitrate= 886.3kbits/s    
video:122kB audio:522kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.122499%
[libx264 @ 0x1a87be0] frame I:1     Avg QP: 2.17  size:  7785
[libx264 @ 0x1a87be0] frame P:48    Avg QP:11.31  size:  2128
[libx264 @ 0x1a87be0] frame B:95    Avg QP:11.73  size:   151
[libx264 @ 0x1a87be0] consecutive B-frames: 11.1%  1.4%  4.2% 83.3%
[libx264 @ 0x1a87be0] mb I  I16..4: 99.1%  0.0%  0.9%
[libx264 @ 0x1a87be0] mb P  I16..4:  0.1%  0.1%  0.2%  P16..4:  1.1%  0.2%  0.1%  0.0%  0.0%    skip:98.1%
[libx264 @ 0x1a87be0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.4%  0.0%  0.0%  direct: 0.0%  skip:99.5%  L0:51.3% L1:43.9% BI: 4.8%
[libx264 @ 0x1a87be0] 8x8 transform intra:4.3% inter:28.6%
[libx264 @ 0x1a87be0] direct mvs  spatial:92.6% temporal:7.4%
[libx264 @ 0x1a87be0] coded y,uvDC,uvAC intra: 5.4% 2.2% 2.2% inter: 0.2% 0.0% 0.0%
[libx264 @ 0x1a87be0] i16 v,h,dc,p: 97%  1%  2%  0%
[libx264 @ 0x1a87be0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  2%  3% 94%  0%  0%  0%  0%  0%  0%
[libx264 @ 0x1a87be0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 15% 19%  4%  6%  5%  5%  4%  5%
[libx264 @ 0x1a87be0] i8c dc,h,v,p: 98%  0%  1%  0%
[libx264 @ 0x1a87be0] Weighted P-Frames: Y:39.6% UV:0.0%
[libx264 @ 0x1a87be0] ref P L0: 72.3%  8.1% 14.8%  2.8%  1.6%  0.3%  0.1%
[libx264 @ 0x1a87be0] ref B L0: 58.4% 29.7%  8.5%  3.5%
[libx264 @ 0x1a87be0] ref B L1: 95.3%  4.7%
[libx264 @ 0x1a87be0] kb/s:165.74
  • Have you seen any other kind? e.g. "surround track"? Or are you referring to the language option? – Rajib Oct 31 '14 at 12:47
  • Yeah, one is "Surround" and the other is "R128 Stereo" – sup Oct 31 '14 at 13:54
15

You can apply metadata to particular streams:

ffmpeg -i input.mp4 -map 0 -metadata:s:a:0 title="One" \
-metadata:s:a:1 title="Two" output.mp4
  • VLC will show the titles, but other players like QuickTime may not.

  • I'm not sure why ffmpeg does not show the input stream title names in the console output or why it does not copy it automatically because:

    By default, global metadata is copied from the first input file, per-stream and per-chapter metadata is copied along with streams/chapters.

  • You can use -map 0 to map all streams from the first input, and only input in this case, to the output; otherwise default stream selection will only choose one stream per stream type.

  • You can also set the language: -metadata:s:a:1 language=eng.

  • Look for -metadata and -map_metadata in the documentation for more info.

  • Thanks, but this command does not produce anything that vlc recognizes (it plays it, but does not display the titles under Audio>Audio Track ). But your answer helped me to understand ffmpeg syntax better:-). – sup Nov 3 '14 at 1:01
  • @sup Strange. It works for me. Is your VLC ancient? – llogan Nov 3 '14 at 1:02
  • Indeed, strange. No, both ffmpeg (2.3.git-1ace957) and VLC (2.3.git-1ace957) are fairly new - I am on Ubuntu 14.04. – sup Nov 3 '14 at 9:40
  • 1
    MPC-HC seems to ignore title but does display handler_name as though it were a title. Worth a shot to see if it works for VLC, too. (note that the ffmpeg command line should set handler, not handler_name). – Stephen Cleary Jan 23 '17 at 3:28
  • 1
    Thanks, worked like a charm except that I had to use "language" instead of "lang" to set the language metadata. – Zoltan Feb 10 '18 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.