10

我发现了很多关于使用 ffmpeg 创建 DVD 菜单的问题,但我没有找到任何关于以编程方式访问 DVD 结构信息的问题。当我使用 libav(或 FFmpeg)库时,我可以打开 DVD 映像(iso 文件)并访问视频、音频和字幕流。但我找不到任何 API。

我可以使用 VLC 播放器(以及 libvlc 库)播放视频并找到信息。但我需要以编程方式对音频和字幕流进行一些处理。我不想使用 SmartRipper 之类的工具拆分 VOB,然后才进行处理。

libav(ffmpeg) 是否包含任何用于处理 DVD 菜单的 API?如果不是,您能否推荐任何其他可用于以一帧(样本,AVPacket)精度获取有关标题(章节)开始和结束时间的信息的库?

我听说过 libdvdnav 库,但我不知道它是否适合我。我是 libav 和 DVD 格式内部的新手。

4

4 回答 4

9

我不确定在这种情况下 1 帧精度意味着什么。但是,我一直在使用一个名为lsdvd的工具,它是一个基本的 CLI 工具,它的唯一参数是 DVD 驱动器的块设备。(如果没有这个参数,它会猜测/dev/dvd,现代 Linux 上没有这个参数,通常是/dev/sr0。)然后它会给你一个很好的光盘章节列表,如下所示:

$ lsdvd /dev/sr0
Disc Title: METAL_DISC_2
Title: 01, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 02, Length: 00:00:11.500 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 03, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 04, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 05, Length: 00:00:09.000 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 06, Length: 00:00:10.000 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 07, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
Title: 08, Length: 00:25:02.333 Chapters: 06, Cells: 06, Audio streams: 01, Subpictures: 00
Title: 09, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 10, Length: 00:07:48.700 Chapters: 16, Cells: 16, Audio streams: 01, Subpictures: 00
Title: 11, Length: 00:00:00.433 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 00
Title: 12, Length: 00:16:43.066 Chapters: 08, Cells: 08, Audio streams: 01, Subpictures: 00
...snip...
Longest track: 20

如果您想编写自己的代码,我想查看源代码lsdvd会很有启发性。它在 Fedora 25 中链接的唯一库(除了标准的东西)是dvdnav项目libdvdread.so.4的一部分。

HTH。

于 2018-01-06T20:42:54.147 回答
3

Mplayer 可以做到这一点。我不熟悉他们的图书馆,但这可以让你开始

mplayer dvd:// -identify

结果

章节:00:00:00.000,00:03:40.200,00:07:29.500,00:12:04.033,00:16:17.199,
00:27:36.499,00:34:26.166,00:43:37.199,00:49:29.533,00:59:46.500,01:12:47.667,
01:17:09.000,01:26:13.700,01:47:15.833,01:50:06.200,01:55:25.500,02:06:42.500,
02:13:03.666,02:20:37.499,02:28:20.832,02:33:26.832,02:37:47.532,02:43:58.665,
02:51:00.165,02:56:36.165,03:01:21.998,03:05:09.331,03:07:14.665,03:11:49.665,
03:16:35.165,
于 2013-04-21T03:45:39.617 回答
2

我使用上述两者的组合来创建 DVD 章节文件,稍后我可以使用 mkvmerge 将其添加到编码的 mkv 文件中:

#!/bin/bash
if [ $# -lt 1 ]; then
    echo "Usage: $0 filename title_no"
    exit 
fi

i=1
j2=01
filename=$1
echo "Using lsdvd to load chapter info:"
lsdvd -c ./
if [ -z "$2" ]; then
    echo -ne "What title number do you want to create chapter info for: "
    read title
else
    title=$2
fi
IFS=',' read -r -a CHAPTERS <<< `mplayer -identify -frames 0 "./VTS_0"$title"_0.IFO" 2>/dev/null | grep CHAPTERS: | sed 's/CHAPTERS: //'`

for chapter in "${CHAPTERS[@]}"
do
    echo "Chapter $i: $chapter"
    let i++
done

echo -ne "Creating chapter data file...."
sleep 3
for chapter in "${CHAPTERS[@]}"
do
    echo "CHAPTER$j2=$chapter" >> $filename.txt
    echo "CHAPTER"$j2"NAME=Chapter $j2" >> $filename.txt
    j2=$(printf %02d $((10#$j2 + 1 )))

done
echo "DONE."
echo "Chapter data file: $filename.txt"

示例输出:

$ read_chapters.sh whiteglasses_chapters
Using lsdvd to load chapter info: 
libdvdread: Couldn't find device name.
Couldn't read enough bytes for title.
Disc Title: unknown
Title: 01, Length: 00:00:21.000 Chapters: 01, Cells: 01, Audio streams: 00, Subpictures: 00
    Chapter: 01, Length: 00:00:21.000, Start Cell: 01
Title: 02, Length: 01:52:32.166 Chapters: 11, Cells: 12, Audio streams: 02, Subpictures: 01
    Chapter: 01, Length: 00:10:23.200, Start Cell: 01
    Chapter: 02, Length: 00:11:53.200, Start Cell: 02
    Chapter: 03, Length: 00:08:02.367, Start Cell: 03
    Chapter: 04, Length: 00:11:28.533, Start Cell: 04
    Chapter: 05, Length: 00:12:55.834, Start Cell: 05
    Chapter: 06, Length: 00:12:26.600, Start Cell: 06
    Chapter: 07, Length: 00:16:20.766, Start Cell: 07
    Chapter: 08, Length: 00:10:31.934, Start Cell: 09
    Chapter: 09, Length: 00:09:24.033, Start Cell: 10
    Chapter: 10, Length: 00:09:04.767, Start Cell: 11
    Chapter: 11, Length: 00:00:00.800, Start Cell: 12
    Longest track: 02
    What title number do you want to create chapter info for: 2 
    Chapter 1: 00:00:00.000
    Chapter 2: 00:10:23.200
    Chapter 3: 00:22:16.400
    Chapter 4: 00:30:18.767
    Chapter 5: 00:41:47.300
    Chapter 6: 00:54:43.134
    Chapter 7: 01:07:09.734
    Chapter 8: 01:23:30.500
    Chapter 9: 01:34:02.434
    Chapter 10: 01:43:26.467
    Chapter 11: 01:52:31.234 
    Creating chapter data file....DONE.
    Chapter data file: whiteglasses_chapters.txt

然后我简单地运行:

mkvmerge --chapters chapters.txt -o output.mkv input-file.mkv
于 2018-04-27T21:53:27.737 回答
2

基本上你不能说,但你可以寻找最长的标题。

一种选择:使用handbrakecli -scan e:(手刹的一部分)

另:使用mplayer -identify dvd:// -dvd-device e:(mplayer标准)

来自:http ://betterlogic.com/roger/2011/07/dvd-determine-main-title-from-command-line/

这对我有帮助,因为 VLC 在它的 GUI 菜单中列出了标题和章节

基本上,安装 VLC 媒体播放器,然后在其中播放您的 DVD。浏览直到它“正在播放真正的标题”</p>

然后转到Playback [menu] -> title并查看当前突出显示的是哪一个。

现在您知道哪个标题是“主要”标题轨道。

资料来源:http ://betterlogic.com/roger/2010/11/how-to-use-vlc-to-tell-how-many-titles-and-chapters-and-which-is-the-main/

于 2016-01-01T09:21:12.283 回答