-
-
Save alexlib/05e82d6486832376953734d68fb0d12d 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% \embedvideo{<poster or text>}{<video file (MP4+H264)>} | |
% \embedvideo*{...}{...} % auto-play | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\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