You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature requestNew feature or requestpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
IMO, one of the biggest pains in Tex is its support for videos.
Previously, it could work with the help of Flash and media9 pacakge, but not anymore since Flash gets outdated.
So far, the only two options in Tex is an unstable hack (try it, and you will see how frequently videos get stuck in any popular PDF viewer),
OR
the animate package that manipulates a whole seq of frames (it takes SO long to compile and the PDF size easily reaches 100 MB while mp4 is only 1MB).
Use Case
Videos have been more and more important in presenting technical content, see e.g., 3b1b and Manim.
I wish Typst could take this into serious consideration.
Reacted by Philipp Glira, Lukas Stratmann, Ase, OrangeX4, Daniel Volya, Erik Hennig, Ian Graham, Unactive, Mufan Qiu, François Beaubert and 91 more
IMO, one of the biggest pains in Tex is its support for videos.
The problem is not in LaTeX. If you have examples of PDF with well working embedded videos build with some other tool it would be quite straightforward to transfer that to LaTeX but imho such examples still don't exist (at least that was the situation last year, but I don't think that much happened here).
Beamer supports adding videos with \usepackage{multimedia} then \movie{path/to/image}{path/to/video}. I've succsefully read that with okular, so it's not just Adobe Reader that supports it. The video is not really inside the pdf, it must be copied in a relative path to the pdf that matches the one in the command.
Reacted by Oromion, Raghav Mishra, Derived Cat, Alex Muirhead, Felix Wechsler, Arvid Norlander, Max and Antoine Viallon
Yes, this could work, sometimes. It is similar to the hack I mentioned.
In my experience, sometimes the video can't be played and gets stuck, and sometimes the video size is off when I enter the full screen mode. This can be catastrophic in a serious presentation.
BTW, I usually use Foxit PDF viewer and it also supports videos.
Due to the way PDF implements videos, these cannot interact with many layout features (rotations, overlapping containers etc.) and must always be rendered as rectangles on top of all other content.
IMO, one of the biggest pains in Tex is its support for videos.
The problem is not in LaTeX. If you have examples of PDF with well working embedded videos build with some other tool it would be quite straightforward to transfer that to LaTeX but imho such examples still don't exist (at least that was the situation last year, but I don't think that much happened here).
LibreOffice Impress embeds videos automatically when doing a PDF export, and those videos seem to play without issues in Okular.
I had a brief look at this, and I believe the way LibreOffice implements this might be a viable solution for this here too.
PDF specification:
The LibreOffice implementation relies on the "Multimedia Features" specified in section 13.2 of the PDF 1.7 specification. The specification explicitly mentions that the media (e.g. videos) may be played with a variety of external players or the reader itself. Many PDF readers support this feature, include the Adobe Reader (for certain media types) or Okular (for a broad range of media types via the respective gstreamer or VLC backends).
Linked videos:
In particular, LibreOffice can add linked videos to a PDF file. Links can be of various type, including paths to local files. This was implemented here, and the resulting object in the PDF file looks like this:
LibreOffice can also embed video files directly into a PDF file. This was implemented as an extension to the above implementation here, and the resulting object in the PDF file looks like this:
The main difference here is in the /Type /Filespec, which for the linked video is /FS /URL /F and the embedded file /F (<embedded file>) /EF.
It is worth to note that pdf-writer has support for embedded files already (typst/pdf-writer@ba040ac), and linked files seem to be supported as well (#2695).
I think that there are a few things to consider here:
Most common PDF viewers except for Adobe Acrobat do not support videos. Over 50% of consumers of a PDF file with media will not be able to play it when opening it in their default viewer (Pdfium, pdf.js, Quartz). Hence, the videos should gracefully fall back to poster images, perhaps with a note that video content is available here. Likewise, the documentation should be written with this in mind. We will also need to fail PDF/A-2 export for files with video since multimedia is not allowed in these files.
The most commonly supported format is H.264 in MP4 containers. I think that Typst should check the magic numbers and such of a video file to verify that it will play. This means only supporting the H.264 codec and only MP4 containers, perhaps M4A, too. Including a video transcoding library in Typst is out of scope and will bloat the binary too much. However, Typst could be able to point the user to how to transcode their file, e.g. outputting the right ffmpeg command if that tool is detected on the system.
The functionality should be exposed in a video function that works similar to the image function with the additional capability of supplying a poster/fallback image. We want to add HTML export soon and the compatibility situation there looks quite different. Not only does HTML support more codecs (VP9, AV1, H.265), it also offers the possibility of linking video sources in multiple resolutions (one of which the browser automatically selects based on connectivity and viewport size). The API of the video function should be designed with this in mind. Ultimately, it would be best if the user could just specify an array of source files whose resolution and MIME types Typst will automatically detect to yield the right source tags or srcset attributes. It should also select the best H.264 video for the PDF.
I think it would be best to come up with a plan for the user-facing API and how to process / identify video files. After that, you can be sure that your implementation has a good chance to be merged!
Reacted by Juntong Chen, odilf, Vera Gonzalez and Cristóbal Tapia
I didn't get the workbook part. A lot of graphical stuff can be created via cetz.
Yes, I'm aware of both, but I'm talking about videos no slideshows, today is common to play videos in the middle of slideshows and teaching (digital ) books
Reacted by Andrew Voynov, Andrea Pierré, OrangeX4, Hyeonseo Yang and Dang Fan
Thanks for pointing out pympress, very interesting tool. They use Poppler to render PDF files and support VLC/Gstreamer to play videos (similar to other Poppler-based viewers like Okular).
Otherwise, as @reknih pointed out that pdf.js doesn't support videos quite yet, but there was an early proof-of-concept implementation (mozilla/pdf.js#5450) which uses the html5 video element to render multimedia content in PDF files. While nobody seems to be actively working on this, it also doesn't seem an unsurmountable task to implement this as video in PDF files match nicely to the html5 video element.
I think it would be best to come up with a plan for the user-facing API and how to process / identify video files. After that, you can be sure that your implementation has a good chance to be merged!
Thanks for your comments and view on this @reknih - very insightful and helpful to get started. I agree, there should be a clear user-facing API first, which probably requires a solid understanding of typst internals in the first place, and is thus a bit out of my comfort zone.
However, I think such a user-facing API could be kept quite simple at first, and be extended later on. And while it would indeed be nice to support a whole range of video codecs, in practice H.264 in MP4 containers is probably still the most widely used one and also the most widely supported one, and thus maybe the best first target. Mapping such video support for PDF files to HTML is straight forward, since as you said, the HTML video tag is very versatile and pdf.js even had a proof-of-concept implementation (mozilla/pdf.js#5450).
A comment on the use-cases for such multimedia support:
Personally, I use multimedia files in presentation slides, such as for teaching or scientific presentations such as in conferences.
I previously used the LaTeX multimedia package in beamer slides, which produces PDF files with links to the multimedia files. This is very similar to my implementation (Add video/multimedia support pdf-writer#31) or what LibreOffice does, though beamer + multimedia does not support embedding the multimedia files in the PDF itself.
A few years ago, I started using Quarto/reveal.js to create HTML slides which works otherwise real nice, but is cumbersome when sharing the slides with others since many people expect PDF and not HTML files. Having first-class support for PDF files is a very important feature and would give typst an edge over tools like Quarto + reveal.js.
Reacted by Andrea Pierré, Pierrot, Hongyang Zhou, Abdulaziz Alqasem, nonotran68, François Beaubert, odilf and Vera Gonzalez
For presentation slides (à la beamer) it would be a game changer if we were able to write everything in typst and to include some videos and then export to HTML. I'm really hoping that this will become a reality. Then it's forever goodbye to powerpoint, google slides, etc.
Reacted by Andrea Pierré, Victor L., Abdulaziz Alqasem, Junjie Fang, Guang Yin, Cornelius-G, vincentme, Yujia Cui, stelzo, Oncelock and 20 more
Keep in mind that everyone who has subscribed to this issue (including those that have commented) receive an email for every reply. Let's refrain from adding replies that do not add to the discussion.
Reacted by Yohaï-Eliel Berreby, Mel Massadian, Nicolai Weitkemper, George-Vladut PIRCA, Victor L., David, lubyou, Louis, Jiawei Gao, Vera Gonzalez and 12 more
feature requestNew feature or requestpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
Activity
u-fischer commentedon Apr 24, 2023
The problem is not in LaTeX. If you have examples of PDF with well working embedded videos build with some other tool it would be quite straightforward to transfer that to LaTeX but imho such examples still don't exist (at least that was the situation last year, but I don't think that much happened here).
Enivex commentedon Apr 24, 2023
Are there even PDF readers that properly support video apart from Adobe Reader?
I think your best bet would be waiting for HTML output. That should more easily be able to support interactive content.
vbarrielle commentedon Apr 24, 2023
Beamer supports adding videos with
\usepackage{multimedia}then\movie{path/to/image}{path/to/video}. I've succsefully read that with okular, so it's not just Adobe Reader that supports it. The video is not really inside the pdf, it must be copied in a relative path to the pdf that matches the one in the command.Guangyi-Zhang commentedon Apr 25, 2023
Yes, this could work, sometimes. It is similar to the hack I mentioned.
In my experience, sometimes the video can't be played and gets stuck, and sometimes the video size is off when I enter the full screen mode. This can be catastrophic in a serious presentation.
BTW, I usually use Foxit PDF viewer and it also supports videos.
reknih commentedon May 9, 2023
Due to the way PDF implements videos, these cannot interact with many layout features (rotations, overlapping containers etc.) and must always be rendered as rectangles on top of all other content.
lumpiluk commentedon Aug 2, 2023
LibreOffice Impress embeds videos automatically when doing a PDF export, and those videos seem to play without issues in Okular.
I found the relevant issues for embedded videos and linked videos in a blog post from 2017.
awehrfritz commentedon Feb 8, 2024
I had a brief look at this, and I believe the way LibreOffice implements this might be a viable solution for this here too.
PDF specification:
The LibreOffice implementation relies on the "Multimedia Features" specified in section 13.2 of the PDF 1.7 specification. The specification explicitly mentions that the media (e.g. videos) may be played with a variety of external players or the reader itself. Many PDF readers support this feature, include the Adobe Reader (for certain media types) or Okular (for a broad range of media types via the respective gstreamer or VLC backends).
Linked videos:
In particular, LibreOffice can add linked videos to a PDF file. Links can be of various type, including paths to local files. This was implemented here, and the resulting object in the PDF file looks like this:
Embedded videos:
LibreOffice can also embed video files directly into a PDF file. This was implemented as an extension to the above implementation here, and the resulting object in the PDF file looks like this:
The main difference here is in the
/Type /Filespec, which for the linked video is/FS /URL /Fand the embedded file/F (<embedded file>) /EF.It is worth to note that
pdf-writerhas support for embedded files already (typst/pdf-writer@ba040ac), and linked files seem to be supported as well (#2695).awehrfritz commentedon Feb 16, 2024
Now that typst/pdf-writer#31 is merged, does anyone (@reknih, @laurmaedje) have any pointers on how to add support for videos in typst?
Like, I mean where in the code base should we start looking, or could find an implementation of similar features?
reknih commentedon Feb 17, 2024
I think that there are a few things to consider here:
ffmpegcommand if that tool is detected on the system.videofunction that works similar to theimagefunction with the additional capability of supplying a poster/fallback image. We want to add HTML export soon and the compatibility situation there looks quite different. Not only does HTML support more codecs (VP9, AV1, H.265), it also offers the possibility of linking video sources in multiple resolutions (one of which the browser automatically selects based on connectivity and viewport size). The API of thevideofunction should be designed with this in mind. Ultimately, it would be best if the user could just specify an array of source files whose resolution and MIME types Typst will automatically detect to yield the rightsourcetags orsrcsetattributes. It should also select the best H.264 video for the PDF.I think it would be best to come up with a plan for the user-facing API and how to process / identify video files. After that, you can be sure that your implementation has a good chance to be merged!
leiserfg commentedon May 10, 2024
https://github.com/Cimbali/pympress supports playing videos, it sounds useful for slideshows and workbooks.
Andrew15-5 commentedon May 10, 2024
Slideshows are already available via polylux.
I didn't get the workbook part. A lot of graphical stuff can be created via cetz.
leiserfg commentedon May 10, 2024
Yes, I'm aware of both, but I'm talking about videos no slideshows, today is common to play videos in the middle of slideshows and teaching (digital ) books
awehrfritz commentedon Jun 6, 2024
Thanks for pointing out pympress, very interesting tool. They use Poppler to render PDF files and support VLC/Gstreamer to play videos (similar to other Poppler-based viewers like Okular).
Otherwise, as @reknih pointed out that pdf.js doesn't support videos quite yet, but there was an early proof-of-concept implementation (mozilla/pdf.js#5450) which uses the html5
videoelement to render multimedia content in PDF files. While nobody seems to be actively working on this, it also doesn't seem an unsurmountable task to implement this as video in PDF files match nicely to the html5videoelement.awehrfritz commentedon Jun 6, 2024
Thanks for your comments and view on this @reknih - very insightful and helpful to get started. I agree, there should be a clear user-facing API first, which probably requires a solid understanding of
typstinternals in the first place, and is thus a bit out of my comfort zone.However, I think such a user-facing API could be kept quite simple at first, and be extended later on. And while it would indeed be nice to support a whole range of video codecs, in practice H.264 in MP4 containers is probably still the most widely used one and also the most widely supported one, and thus maybe the best first target. Mapping such video support for PDF files to HTML is straight forward, since as you said, the HTML video tag is very versatile and pdf.js even had a proof-of-concept implementation (mozilla/pdf.js#5450).
A comment on the use-cases for such multimedia support:
multimediapackage inbeamerslides, which produces PDF files with links to the multimedia files. This is very similar to my implementation (Add video/multimedia support pdf-writer#31) or what LibreOffice does, thoughbeamer+multimediadoes not support embedding the multimedia files in the PDF itself.typstan edge over tools like Quarto + reveal.js.mrlogick commentedon Nov 10, 2024
Thanks guys for this amazing project. Video support is so important. If you manage to solve this, everyone would switch to Typst.
luiswirth commentedon Nov 23, 2024
For presentation slides (à la beamer) it would be a game changer if we were able to write everything in typst and to include some videos and then export to HTML. I'm really hoping that this will become a reality. Then it's forever goodbye to powerpoint, google slides, etc.
branaway commentedon Jan 6, 2025
A much needed feature. Please continue innovating...
fbob commentedon Mar 9, 2025
This PR Add video/multimedia support #31 was merged on Feb 16, 2024.
Any update on this feature ?
Thanks.
HackYardo commentedon Apr 8, 2025
There are concise tricks for X:
although music, video, 3d-model and etc is useful and PDF standard supported.
Enivex commentedon Apr 8, 2025
As far as I know no one is working on this.
Technically, although support outside of adobe reader is an extremely mixed bag
knightnemo commentedon Apr 20, 2025
Really need this, fingers crossed
Enivex commentedon Apr 20, 2025
Keep in mind that everyone who has subscribed to this issue (including those that have commented) receive an email for every reply. Let's refrain from adding replies that do not add to the discussion.