我正在尝试通过提取元数据文件并按照以下方法使用 ffmpeg 将自定义章节添加到 mp4 文件中本指南。
但是,当我编辑元数据文件以更改任何章节名称时,重新添加元数据的第二个命令会忽略对章节的更改并保持原样。它肯定正确地读取了元数据文件,因为当 ffmpeg 打印出两个输入文件的数据时,它会打印 mp4 的流和元数据文件的所有元数据,所有章节都正确格式化和解析。
但是,一旦创建输出文件,它就会再次使用旧的章节名称。如果我更改其他元数据,则会出现这种情况(例如标题键或艺术家键),但章节不会。
命令启动的完整日志:
PS D:\ffmpeg> ./bin/ffmpeg.exe -i .\new_file.mp4 -i FFMETADATAFILE -map_metadata 1 -codec copy .\output.mp4
ffmpeg version N-90979-g08032331ac Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 18.100 / 56. 18.100
libavcodec 58. 19.100 / 58. 19.100
libavformat 58. 13.101 / 58. 13.101
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 21.100 / 7. 21.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\new_file.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : new_file
encoder : Lavf57.46.100
Duration: 02:01:34.85, start: 0.000000, bitrate: 2940 kb/s
Chapter #0:0: start 0.000000, end 628.962000
Metadata:
title : Chapter 1
Chapter #0:1: start 628.962000, end 1042.083000
Metadata:
title : Chapter 2
Chapter #0:2: start 1042.083000, end 1882.172000
Metadata:
title : Chapter 3
Chapter #0:3: start 1882.172000, end 2479.102000
Metadata:
title : Chapter 4
Chapter #0:4: start 2479.102000, end 3095.718000
Metadata:
title : Chapter 5
Chapter #0:5: start 3095.718000, end 3681.511000
Metadata:
title : Chapter 6
Chapter #0:6: start 3681.511000, end 4145.600000
Metadata:
title : Chapter 7
Chapter #0:7: start 4145.600000, end 5149.019000
Metadata:
title : Chapter 8
Chapter #0:8: start 5149.019000, end 5704.908000
Metadata:
title : Chapter 9
Chapter #0:9: start 5704.908000, end 5980.850000
Metadata:
title : Chapter 10
Chapter #0:10: start 5980.850000, end 6826.403000
Metadata:
title : Chapter 11
Chapter #0:11: start 6826.403000, end 7294.746000
Metadata:
title : Chapter 12
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x816 [SAR 1:1 DAR 40:17], 2678 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream #0:2(eng): Data: bin_data (text / 0x74786574)
Metadata:
handler_name : SubtitleHandler
Input #1, ffmetadata, from 'FFMETADATAFILE':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Title
encoder : Lavf58.13.101
Duration: 02:01:34.75, start: 0.000000, bitrate: 0 kb/s
Chapter #1:0: start 0.000000, end 628.962000
Metadata:
title : Edited Name
Chapter #1:1: start 628.962000, end 1042.083000
Metadata:
title : Chapter 2
Chapter #1:2: start 1042.083000, end 1882.172000
Metadata:
title : Chapter 3
Chapter #1:3: start 1882.172000, end 2479.102000
Metadata:
title : Chapter 4
Chapter #1:4: start 2479.102000, end 3095.718000
Metadata:
title : Chapter 5
Chapter #1:5: start 3095.718000, end 3681.511000
Metadata:
title : Chapter 6
Chapter #1:6: start 3681.511000, end 4145.600000
Metadata:
title : Chapter 7
Chapter #1:7: start 4145.600000, end 5149.019000
Metadata:
title : Chapter 8
Chapter #1:8: start 5149.019000, end 5704.908000
Metadata:
title : Chapter 9
Chapter #1:9: start 5704.908000, end 5980.850000
Metadata:
title : Chapter 10
Chapter #1:10: start 5980.850000, end 6826.403000
Metadata:
title : Chapter 11
Chapter #1:11: start 6826.403000, end 7294.746000
Metadata:
title : Chapter 12
File '.\output.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to '.\output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : Title
encoder : Lavf58.13.101
Chapter #0:0: start 0.000000, end 628.962000
Metadata:
title : Chapter 1
Chapter #0:1: start 628.962000, end 1042.083000
Metadata:
title : Chapter 2
Chapter #0:2: start 1042.083000, end 1882.172000
Metadata:
title : Chapter 3
Chapter #0:3: start 1882.172000, end 2479.102000
Metadata:
title : Chapter 4
Chapter #0:4: start 2479.102000, end 3095.718000
Metadata:
title : Chapter 5
Chapter #0:5: start 3095.718000, end 3681.511000
Metadata:
title : Chapter 6
Chapter #0:6: start 3681.511000, end 4145.600000
Metadata:
title : Chapter 7
Chapter #0:7: start 4145.600000, end 5149.019000
Metadata:
title : Chapter 8
Chapter #0:8: start 5149.019000, end 5704.908000
Metadata:
title : Chapter 9
Chapter #0:9: start 5704.908000, end 5980.850000
Metadata:
title : Chapter 10
Chapter #0:10: start 5980.850000, end 6826.403000
Metadata:
title : Chapter 11
Chapter #0:11: start 6826.403000, end 7294.746000
Metadata:
title : Chapter 12
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x816 [SAR 1:1 DAR 40:17], q=2-31, 2678 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 90k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
您可以看到,我已经在输入#1(元数据文件)中编辑了标题键和第一章的名称,但输出中只有标题不同。
任何帮助均感激不尽。
答案1
已解决 - 看起来-map_metadata
只在章节之前按下顶部的键,您-map_chapters
还需要获取章节。
ffmpeg -i INPUT -i FFMETADATAFILE -map_metadata 1 -map_chapters 1 -codec copy OUTPUT