Re: [FFmpeg-devel] [PATCH v5] libavformat: add DVD-Video demuxer, powered by libdvdnav and libdvdread

2024-01-31 Thread Stefano Sabatini
On date Sunday 2024-01-28 16:59:22 -0600, Marth64 wrote:
> - Add option to play only certain chapters or chapter ranges
> - Add option to do a second pass indexing for accurate chapter markers
> - Add documentation
> - Fixes issues with PCM audio
> - Support for essential track dispositions (forced, visual impaired, 
> commentary)
> - Better support for structure variances and padding cells/frames
> - More user friendly log messages and errors
> - dvdread/dvdnav logging is relatively very verbose, map lower levels as 
> DEBUG logs
> 
> Signed-off-by: Marth64 
> ---
>  Changelog |1 +
>  configure |8 +
>  doc/demuxers.texi |  129 
>  libavformat/Makefile  |1 +
>  libavformat/allformats.c  |1 +
>  libavformat/dvdvideodec.c | 1409 +
>  6 files changed, 1549 insertions(+)
>  create mode 100644 libavformat/dvdvideodec.c
> 
> diff --git a/Changelog b/Changelog
> index c1fd66b4bd..9de157abe4 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -23,6 +23,7 @@ version :
>  - ffmpeg CLI -bsf option may now be used for input as well as output
>  - ffmpeg CLI options may now be used as -/opt , which is equivalent
>to -opt >
> +- DVD-Video demuxer, powered by libdvdnav and libdvdread
>  
>  version 6.1:
>  - libaribcaption decoder
> diff --git a/configure b/configure
> index 21663000f8..d81420992a 100755
> --- a/configure
> +++ b/configure
> @@ -227,6 +227,8 @@ External library support:
>--enable-libdavs2enable AVS2 decoding via libdavs2 [no]
>--enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
> and libraw1394 [no]
> +  --enable-libdvdnav   enable libdvdnav, needed for DVD demuxing [no]
> +  --enable-libdvdread  enable libdvdread, needed for DVD demuxing [no]
>--enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
>--enable-libfliteenable flite (voice synthesis) support via 
> libflite [no]
>--enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
> [no]
> @@ -1806,6 +1808,8 @@ EXTERNAL_LIBRARY_GPL_LIST="
>  frei0r
>  libcdio
>  libdavs2
> +libdvdnav
> +libdvdread
>  librubberband
>  libvidstab
>  libx264
> @@ -3520,6 +3524,8 @@ dts_demuxer_select="dca_parser"
>  dtshd_demuxer_select="dca_parser"
>  dv_demuxer_select="dvprofile"
>  dv_muxer_select="dvprofile"
> +dvdvideo_demuxer_select="mpegps_demuxer"
> +dvdvideo_demuxer_deps="libdvdnav libdvdread"
>  dxa_demuxer_select="riffdec"
>  eac3_demuxer_select="ac3_parser"
>  evc_demuxer_select="evc_frame_merge_bsf evc_parser"
> @@ -6761,6 +6767,8 @@ enabled libdav1d  && require_pkg_config 
> libdav1d "dav1d >= 0.5.0" "dav1d
>  enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
> davs2.h davs2_decoder_open
>  enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
> dc1394/dc1394.h dc1394_new
>  enabled libdrm&& check_pkg_config libdrm libdrm xf86drm.h 
> drmGetVersion
> +enabled libdvdnav && require_pkg_config libdvdnav "dvdnav >= 6.1.1" 
> dvdnav/dvdnav.h dvdnav_open2
> +enabled libdvdread&& require_pkg_config libdvdread "dvdread >= 
> 6.1.2" dvdread/dvd_reader.h DVDOpen2 -ldvdread
>  enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
> "fdk-aac/aacenc_lib.h" aacEncOpen ||
> { require libfdk_aac fdk-aac/aacenc_lib.h 
> aacEncOpen -lfdk-aac &&
>   warn "using libfdk without pkg-config"; } }
> diff --git a/doc/demuxers.texi b/doc/demuxers.texi
> index e4c5b560a6..f7f9e6769a 100644
> --- a/doc/demuxers.texi
> +++ b/doc/demuxers.texi
> @@ -285,6 +285,135 @@ This demuxer accepts the following option:
>  
>  @end table
>  
> +@section dvdvideo
> +
> +DVD-Video demuxer, powered by libdvdnav and libdvdread.
> +
> +Can directly ingest DVD titles, specifically sequential PGCs (see below),
> +into a conversion pipeline. Menus and seeking are not supported at this time.
> +Block devices (DVD drives), ISO files, and directory structures are accepted.
> +Activate with @code{-f dvdvideo} in front of one of these inputs.
> +
> +Underlying playback is fully handled by libdvdnav, and structure parsing by 
> libdvdread.

> +Therefore, the ffmpeg build must be configured with these GPL libraries 
> enabled.

nit, specifically mention the @code{--enable-libdvdread} and
@code{--enable-libdvdnav} options as done in other places.

> +
> +You will need to provide either the desired "title" number or exact PGC/PG 
> coordinates.
> +Many open-source DVD tools and players can aid in providing this information.
> +If not specified, the demuxer will default to title 1 which works for many 
> discs.
> +However, due to the flexibility of the DVD standard, it is recommended to 
> check manually.
> +There are many discs that are authored strangely or with invalid headers.
> +
> +If the input is a real DVD 

[FFmpeg-devel] [PATCH v5] libavformat: add DVD-Video demuxer, powered by libdvdnav and libdvdread

2024-01-28 Thread Marth64
- Add option to play only certain chapters or chapter ranges
- Add option to do a second pass indexing for accurate chapter markers
- Add documentation
- Fixes issues with PCM audio
- Support for essential track dispositions (forced, visual impaired, commentary)
- Better support for structure variances and padding cells/frames
- More user friendly log messages and errors
- dvdread/dvdnav logging is relatively very verbose, map lower levels as DEBUG 
logs

Signed-off-by: Marth64 
---
 Changelog |1 +
 configure |8 +
 doc/demuxers.texi |  129 
 libavformat/Makefile  |1 +
 libavformat/allformats.c  |1 +
 libavformat/dvdvideodec.c | 1409 +
 6 files changed, 1549 insertions(+)
 create mode 100644 libavformat/dvdvideodec.c

diff --git a/Changelog b/Changelog
index c1fd66b4bd..9de157abe4 100644
--- a/Changelog
+++ b/Changelog
@@ -23,6 +23,7 @@ version :
 - ffmpeg CLI -bsf option may now be used for input as well as output
 - ffmpeg CLI options may now be used as -/opt , which is equivalent
   to -opt >
+- DVD-Video demuxer, powered by libdvdnav and libdvdread
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index 21663000f8..d81420992a 100755
--- a/configure
+++ b/configure
@@ -227,6 +227,8 @@ External library support:
   --enable-libdavs2enable AVS2 decoding via libdavs2 [no]
   --enable-libdc1394   enable IIDC-1394 grabbing using libdc1394
and libraw1394 [no]
+  --enable-libdvdnav   enable libdvdnav, needed for DVD demuxing [no]
+  --enable-libdvdread  enable libdvdread, needed for DVD demuxing [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
@@ -1806,6 +1808,8 @@ EXTERNAL_LIBRARY_GPL_LIST="
 frei0r
 libcdio
 libdavs2
+libdvdnav
+libdvdread
 librubberband
 libvidstab
 libx264
@@ -3520,6 +3524,8 @@ dts_demuxer_select="dca_parser"
 dtshd_demuxer_select="dca_parser"
 dv_demuxer_select="dvprofile"
 dv_muxer_select="dvprofile"
+dvdvideo_demuxer_select="mpegps_demuxer"
+dvdvideo_demuxer_deps="libdvdnav libdvdread"
 dxa_demuxer_select="riffdec"
 eac3_demuxer_select="ac3_parser"
 evc_demuxer_select="evc_frame_merge_bsf evc_parser"
@@ -6761,6 +6767,8 @@ enabled libdav1d  && require_pkg_config libdav1d 
"dav1d >= 0.5.0" "dav1d
 enabled libdavs2  && require_pkg_config libdavs2 "davs2 >= 1.6.0" 
davs2.h davs2_decoder_open
 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 
dc1394/dc1394.h dc1394_new
 enabled libdrm&& check_pkg_config libdrm libdrm xf86drm.h 
drmGetVersion
+enabled libdvdnav && require_pkg_config libdvdnav "dvdnav >= 6.1.1" 
dvdnav/dvdnav.h dvdnav_open2
+enabled libdvdread&& require_pkg_config libdvdread "dvdread >= 6.1.2" 
dvdread/dvd_reader.h DVDOpen2 -ldvdread
 enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac 
"fdk-aac/aacenc_lib.h" aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e4c5b560a6..f7f9e6769a 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -285,6 +285,135 @@ This demuxer accepts the following option:
 
 @end table
 
+@section dvdvideo
+
+DVD-Video demuxer, powered by libdvdnav and libdvdread.
+
+Can directly ingest DVD titles, specifically sequential PGCs (see below),
+into a conversion pipeline. Menus and seeking are not supported at this time.
+Block devices (DVD drives), ISO files, and directory structures are accepted.
+Activate with @code{-f dvdvideo} in front of one of these inputs.
+
+Underlying playback is fully handled by libdvdnav, and structure parsing by 
libdvdread.
+Therefore, the ffmpeg build must be configured with these GPL libraries 
enabled.
+
+You will need to provide either the desired "title" number or exact PGC/PG 
coordinates.
+Many open-source DVD tools and players can aid in providing this information.
+If not specified, the demuxer will default to title 1 which works for many 
discs.
+However, due to the flexibility of the DVD standard, it is recommended to 
check manually.
+There are many discs that are authored strangely or with invalid headers.
+
+If the input is a real DVD drive, please note that there are some drives which 
may
+silently fail on reading bad sectors from the disc, returning random bits 
instead
+which is effectively corrupt data. This is especially prominent on aging or 
rotting discs.
+A second pass and integrity checks would be needed to detect the corruption.
+This is not an ffmpeg issue.
+
+@subsection Background
+
+DVD-Video is not a directly accessible,