如何使用ffmpeg命名音轨


13

当文件具有更多音轨时,VLC可以在“音频”>“音轨”下的菜单中显示其名称-或标题,我不确定该用语。

当我用

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

名称丢失,仅显示通用的“ Track 1”和“ Track 2”。我该如何保存?或如何设置自定义名称。

命令的输出如下所示:

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

你有没有看到其他种类的东西?例如“环绕轨道”?还是您指的是语言选项?
拉吉卜2014年

是的,一个是“ Surround”,另一个是“ R128 Stereo”
sup

Answers:


15

您可以将元数据应用于特定的流:

ffmpeg -i input.mp4 -map 0 -metadata:s:a:0 title="One" \
-metadata:s:a:1 title="Two" output.mp4
  • VLC将显示标题,但其他播放器(如QuickTime)可能不会显示。

  • 我不确定为什么ffmpeg不在控制台输出中显示输入流标题名称,或者为什么它不自动复制它,因为:

    默认情况下,从第一个输入文件复制全局元数据,按流和按章复制元数据以及流/章。

  • 您可以-map 0用来将所有流从第一个输入(在这种情况下仅输入)映射到输出;否则,默认流选择只会为每种流类型选择一个流。

  • 您还可以设置语言:-metadata:s:a:1 language=eng

  • 文档中查找-metadata-map_metadata以获取更多信息。


谢谢,但是此命令不会产生vlc可以识别的任何内容(它会播放它,但是不会在Audio> Audio Track下显示标题)。但是您的回答帮助我更好地理解了ffmpeg语法:-)。
2014年

@sup奇怪。这个对我有用。您的VLC古老吗?
llogan 2014年

确实,很奇怪。不,ffmpeg(2.3.git-1ace957)和VLC(2.3.git-1ace957)都是相当新的-我在Ubuntu 14.04上。
sup 2014年

1
MPC-HC似乎忽略了,title但显示的handler_name好像是标题一样。值得一试,看看它是否也适用于VLC。(请注意ffmpeg命令行应设置handler,而不是handler_name)。
Stephen Cleary

1
谢谢,工作起来很吸引人,只是我必须使用“语言”而不是“ lang”来设置语言元数据。
Zoltan '18年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.