Last active
June 27, 2024 19:16
-
-
Save FedericoTartarini/7af4eb6fc13b1cb9cc68b7e8ea823d50 to your computer and use it in GitHub Desktop.
Embed a video into LaTeX wihout using Flash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% this code was copied from https://tex.stackexchange.com/a/516102 | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\usepackage[bigfiles]{pdfbase} | |
\ExplSyntaxOn | |
\NewDocumentCommand\embedvideo{smm}{ | |
\group_begin: | |
\leavevmode | |
\tl_if_exist:cTF{file_\file_mdfive_hash:n{#3}}{ | |
\tl_set_eq:Nc\video{file_\file_mdfive_hash:n{#3}} | |
}{ | |
\IfFileExists{#3}{}{\GenericError{}{File~`#3'~not~found}{}{}} | |
\pbs_pdfobj:nnn{}{fstream}{{}{#3}} | |
\pbs_pdfobj:nnn{}{dict}{ | |
/Type/Filespec/F~(#3)/UF~(#3) | |
/EF~<</F~\pbs_pdflastobj:>> | |
} | |
\tl_set:Nx\video{\pbs_pdflastobj:} | |
\tl_gset_eq:cN{file_\file_mdfive_hash:n{#3}}\video | |
} | |
% | |
\pbs_pdfobj:nnn{}{dict}{ | |
/Type/RichMediaInstance/Subtype/Video | |
/Asset~\video | |
/Params~<</FlashVars ( | |
source=#3& | |
skin=SkinOverAllNoFullNoCaption.swf& | |
skinAutoHide=true& | |
skinBackgroundColor=0x5F5F5F& | |
skinBackgroundAlpha=0 | |
)>> | |
} | |
% | |
\pbs_pdfobj:nnn{}{dict}{ | |
/Type/RichMediaConfiguration/Subtype/Video | |
/Instances~[\pbs_pdflastobj:] | |
} | |
% | |
\pbs_pdfobj:nnn{}{dict}{ | |
/Type/RichMediaContent | |
/Assets~<< | |
/Names~[(#3)~\video] | |
>> | |
/Configurations~[\pbs_pdflastobj:] | |
} | |
\tl_set:Nx\rmcontent{\pbs_pdflastobj:} | |
% | |
\pbs_pdfobj:nnn{}{dict}{ | |
/Activation~<< | |
/Condition/\IfBooleanTF{#1}{PV}{XA} | |
/Presentation~<</Style/Embedded>> | |
>> | |
/Deactivation~<</Condition/PI>> | |
} | |
% | |
\hbox_set:Nn\l_tmpa_box{#2} | |
\tl_set:Nx\l_box_wd_tl{\dim_use:N\box_wd:N\l_tmpa_box} | |
\tl_set:Nx\l_box_ht_tl{\dim_use:N\box_ht:N\l_tmpa_box} | |
\tl_set:Nx\l_box_dp_tl{\dim_use:N\box_dp:N\l_tmpa_box} | |
\pbs_pdfxform:nnnnn{1}{1}{}{}{\l_tmpa_box} | |
% | |
\pbs_pdfannot:nnnn{\l_box_wd_tl}{\l_box_ht_tl}{\l_box_dp_tl}{ | |
/Subtype/RichMedia | |
/BS~<</W~0/S/S>> | |
/Contents~(embedded~video~file:#3) | |
/NM~(rma:#3) | |
/AP~<</N~\pbs_pdflastxform:>> | |
/RichMediaSettings~\pbs_pdflastobj: | |
/RichMediaContent~\rmcontent | |
} | |
\phantom{#2} | |
\group_end: | |
} | |
\ExplSyntaxOff | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry about that, I have now added a reference to your original code.