Last active
April 2, 2025 04:46
-
-
Save FedericoTartarini/7af4eb6fc13b1cb9cc68b7e8ea823d50 to your computer and use it in GitHub Desktop.
Embed a video into LaTeX wihout using Flash
This file contains hidden or 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 | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
No sorry I am not sure how to add those controls
Thanks for your answer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @FedericoTartarini ,
Thanks for the code!
I would like to know if you have managed to add controls to the video ( play/stop buttons ) I have been trying many solutions but have no clue!
Best