我发现很多关于使用ffmpeg创建DVD菜单的问题,但我没有发现任何关于以编程方式访问DVD结构信息的问题。当我使用libav(或FFmpeg)库时,我可以打开DVD映像(iso文件)并访问视频,音频和字幕流。但我找不到任何API。
我可以使用VLC播放器(以及libvlc库)播放视频和查找信息。但我需要在程序上对音频和字幕流进行一些处理。我不想使用像SmartRipper这样的工具拆分VOB,然后才进行处理。
libav(ffmpeg)是否包含用于处理DVD菜单的任何API?如果没有,你能推荐任何其他库,可以用来获得有关标题(章节)开始和结束时间的信息,一帧(样本,AVPacket)准确吗?
我听说过libdvdnav库,但我不知道它是否适合我。 我是libav和DVD格式内部的新手。
答案 0 :(得分:5)
我不确定在这种情况下1帧精度意味着什么。但是,我一直在使用一个名为lsdvd的工具,这是一个基本的CLI工具,它只作为参数,DVD驱动器的块设备。 (如果没有该参数,它将猜测现代Linux上缺少的/dev/dvd
,并且通常是/dev/sr0
。)然后它将为您提供光盘章节的精彩列表,如下所示: / p>
$ 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中链接的唯一库(标准内容除外)是libdvdread.so.4
,它是dvdnav项目的一部分。
HTH。
答案 1 :(得分:3)
Mplayer可以做到这一点。我不熟悉他们的图书馆,但这可以让你开始
mplayer dvd:// -identify
结果
CHAPTERS: 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,
答案 2 :(得分:1)
基本上你不能说,但你可以寻找最长的头衔。
一个选项:使用
handbrakecli -scan e:
(手刹的一部分)另一个:使用
mplayer -identify dvd:// -dvd-device e:
(mplayer 标准)
来自:http://betterlogic.com/roger/2011/07/dvd-determine-main-title-from-command-line/
这帮助了我,因为VLC列出了其中的菜单页面中的标题和章节
基本上,安装VLC Media Player,然后在其中播放DVD。 浏览直至“正在播放真正的标题”
然后转到播放[菜单] - >标题,看看它目前是哪一个 高亮。
现在您知道哪个标题是“主要”标题曲目。
答案 3 :(得分:1)
我使用上述两者的组合来创建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