Repository navigation
feat: turn audio/video transcripts and slide media into tracks - #4752
Conversation
A video shape (python-pptx Movie) was not a Picture, so the backend skipped it and the video was absent from the document. An audio shape came out as a plain picture of its speaker icon, with nothing to say that it plays a file. A video shape now becomes a picture of its poster frame, on its slide. Video and audio pictures record the media file in a docling__video or docling__audio meta field: the path inside the package for an embedded file, or the link target for a linked file. The media element in p:nvPr gives the kind; the p14:media extension or the media element gives the relationship. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
The ODP backend skipped the draw:plugin of a media frame. Only its draw:image preview came out, as a plain picture. The preview picture now records the media file in the same docling__video or docling__audio meta field as PPTX. A frame without a preview gets an empty picture. When LibreOffice declares its generic media type, the manifest or the file extension gives the kind. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
A pipeline needs the bytes of a media file to convert it. The new DeclarativeDocumentBackend.load_media takes the value of a docling__video or docling__audio field and returns the bytes. The default returns None. The PPTX backend reads an embedded file from its package part and the ODP backend from its archive. A linked file goes through the ImageResourceLoader rules: a URL needs enable_remote_fetch, and a local file needs enable_local_fetch, a document read from a Path, and a place in the folder of the document or below it. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
The new ConvertPipelineOptions.do_media_conversion (off by default) makes the simple pipeline convert each recorded media file with the ASR pipeline (audio) or the video pipeline (video), with the Whisper model of media_asr_options. The result goes in a group right after the picture: the transcript with its timestamps and, for a video, the sampled frames. The items take the provenance and the content layer of the picture. A media file that cannot be loaded or converted, also for a missing ASR extra, keeps its picture, is listed in the conversion errors, and makes the result a partial success. A linked file that the backend options do not allow is skipped with a warning. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
|
✅ DCO Check Passed Thanks @DanielNg0729, all your commits are properly signed off. 🎉 |
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Signed-off-by: Nguyen Hoang Duong <danielnguyenh07@gmail.com>
AI triage (advisory)Checked commit The PR keeps video and audio on PPTX and ODP slides as tracks. It records each media file and adds opt-in CI safety: needs maintainer care before you approve CI.
1 related pull request(s) in the same code
Reference data changes
Assessment: unclear. The WebVTT reference changes match the backend change that puts cues in a track. The one-line changes in the LaTeX reference files have no cause in this PR's LaTeX-related code, and the diff does not show their content. The The |
Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
|
@DanielNg0729 I love this feature, but I need to understand a bit more how you want to construct it and in particular, I need to see how this will play with the new I would love to see:
|
From the review of Steve-Allison: - Older decks embed .wmv, .m4v, .mpg, .mpeg, .flv, .asf, .wma or .aiff. With LibreOffice's generic media type, the ODP backend did not record such a file. media_kind() now knows these containers. - The video pipeline reads only some containers. A video in another one is recorded but not converted, with a warning, so the deck no longer becomes a partial success for a file that cannot be converted at all. - A media part that several slides show is converted once; each slide gets its copy of the result. A video without an audio track already converts to its frames without an error; a test now covers it. Signed-off-by: Daniel Nguyen <danielnguyenh07@gmail.com>
Add the transcript items to one TrackItem instead of the body. With the new keep_media option (--keep-media), reference the input file as the track's audio, or video for a video file, so that e.g. a DocLang archive stores it. Only file inputs are supported, and the CLI then keeps them in place. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Like ASR, add the frames and transcript of a video, and the cues of a WebVTT file, to one TrackItem. Frames become instants at their timestamp. The video pipeline also takes keep_media (--keep-media), which references the input file as the track's video. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
With the new --keep-source option, store the input file unchanged in the archive written by --to dclx, with the file name and media type of the document's origin. Only file inputs have a source to store. A source that is also the media of a track (--keep-media) is stored once. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
…rge-main Keep the video shapes of a slide next to the Office 2016 charts from main, and record the media of a picture after main's new picture decoding. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
The audio and video pipelines now put their transcript in a track, so the media group of a slide holds that track. Two tests of the slide transcription still expect the transcript directly in the group; the move of slide media to tracks replaces them. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
A video or audio object on a PPTX or ODP slide becomes a track, with its poster frame or icon as the cover and a MediaRef to the media file, in place of a picture with a docling__video or docling__audio meta field. With do_media_conversion, the transcript and frames go in that track instead of a group after the picture. The new keep_media option (also --keep-media) holds the media file in the track, so that a DocLang archive stores it. Media in a container that a track cannot reference yet, such as .wmv, stays a picture. Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
…round truth Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
vagenas
left a comment
There was a problem hiding this comment.
Thanks @DanielNg0729, approving, with these changes of mine on top:
- Slide media as tracks: video and audio on PPTX and ODP slides become a
TrackItemunder the slide, with the poster frame or preview as cover and aMediaRefto the media, in place of a picture withdocling__*metadata. Withdo_media_conversion, the transcript and video frames go into that track. - New options:
keep_mediaholds the media in the track, so that a DCLX archive stores it. On the CLI,--keep-mediaand--convert-media(which uses the--asr-*options). - Audio, video and WebVTT conversions put their transcript in one track.
--keep-mediareferences the input as the track's recording, and--keep-sourcestores the input in the DCLX archive. - Fixes: standard media types for audio inputs (
audio/mpegetc.), and stripped segment text for native Whisper. - Up to date with
main, and requires docling-core 2.108.0, which brings the tracks (docling-project/docling-core#940).
@Steve-Allison, on the points you raised: (1) the track always records where its media is (video / audio), also without transcription; a place for it in DocLang markup is raised in doclang-project/doclang#248; (2) older containers (.wmv, .mpg, .wma, ...) are tracks too; (3) silent videos give frames only and still succeed; (4) shared media is converted once.
Hi maintainers, this PR stops PPTX and ODP conversion from dropping slide video and audio, and adds an opt-in step that transcribes them with the existing audio and video pipelines.
Issue resolved by this Pull Request:
Resolves #4740
What changes
Movie, which is not aPicture, so the backend skipped it. A video now becomes a picture of its poster frame, with provenance on its slide. Audio was already a picture of the speaker icon.docling__videoordocling__audio. The value is the path inside the package for an embedded file (ppt/media/media1.mp4), or the link target for a linked file. In PPTX, the media element inp:nvPr(a:videoFile,a:quickTimeFile,a:audioFile,a:wavAudioFile) gives the kind, and thep14:mediarelationship, or else the one of the media element, gives the file.draw:pluginof a media frame, and only its preview came out. The preview picture now records the same field. A frame without a preview gets an empty picture. When LibreOffice declares its genericapplication/vnd.sun.star.mediatype, the manifest or the file extension gives the kind.DeclarativeDocumentBackend.load_media(location)returns the bytes of a recorded file. The default returnsNone. PPTX reads the package part, and ODP reads the archive. A linked file follows theImageResourceLoaderrules: a URL needsenable_remote_fetch, and a local file needsenable_local_fetch, a document given as aPath, and a place in the folder of the document or below it.ConvertPipelineOptions.do_media_conversion(defaultFalse),SimplePipelinesends each recorded file toAsrPipeline(audio) orVideoPipeline(video), with the Whisper model ofmedia_asr_options. The result goes in asectiongroup right after the picture: the transcript with itsTrackSourcetimestamps and, for a video, the sampled frames. The items take the provenance (slide and box) and the content layer of the picture. A file that cannot be loaded or converted, also for a missingasrextra or ffmpeg, keeps its picture, is listed inConversionResult.errors, and makes the resultPARTIAL_SUCCESS. A linked file that the options do not allow is skipped with a warning.supported_formats.md, a new "Video and audio in slides" section inprocessing_audio_media.md, and the Python SDK reference of the usage skill.Design note: the conversion is a pipeline step, not a backend feature, because
docling.backendmust not importdocling.pipeline(Tach layers). As a pipeline step, the user sets it in the options they already pass, the media pipelines are built only when a document has media, and any declarative format that recordsdocling__video/docling__audiocan use it later.Usage
Markdown of the first slide of my test deck (Whisper tiny):
Without
do_media_conversion, only the picture and the path line are there.Notes for reviewers. I am happy to change any of these:
<!-- image -->line. I used a plain string for this reason, because a dict prints as a Python repr. A dedicated field in docling-core is another option.ConvertPipelineOptions, next todo_picture_descriptionanddo_chart_extraction. OnlySimplePipelinereads them. Frames use the defaultVideoPipelineOptions, and only the Whisper model can be set.Checklist: