ScriptInfo

Struct ScriptInfo 

Source
pub struct ScriptInfo { /* private fields */ }
Expand description

The First part of any Advanced SubStation Alpha file is Script Info. This holds necessary information which include the version the resolution of subtitles etc of the .ass file.

Implementations§

Source§

impl ScriptInfo

Source

pub fn set_script(&mut self, script: ScriptInfo) -> &mut ScriptInfo

Examples found in repository?
examples/create_default_subtitles.rs (line 8)
4fn main() {
5    let mut ass_file = AssFile::new();
6
7    ass_file.components.script
8        .set_script(ScriptInfo::default());
9
10    ass_file.components.v4
11        .set_v4(V4Format::default());
12
13    ass_file.components.events
14        .set_events(Events::default());
15
16    AssFile::save_file(&ass_file, "default_subtitles.ass");
17}
More examples
Hide additional examples
examples/color.rs (line 15)
5fn main() {
6    let mut ass_file = AssFile::new();
7
8    let dialogue = Dialogue::new()
9        .set_start("0:00:00:00")
10        .set_end("0:00:02:00")
11        .set_text("Hello Friend!")
12        .set_colour(HexColor::YELLOW);
13
14    ass_file.components.script
15        .set_script(ScriptInfo::default());
16
17    ass_file.components.v4
18        .set_v4(V4Format::default());
19
20    ass_file.components.events
21        .set_events(Events::default())
22        .add_dialogue(dialogue);
23
24    AssFile::save_file(&ass_file, "new_subtitles.ass");
25}
examples/random_colors_from_subrip.rs (line 30)
6fn main() {
7    let hexcolor = AssFileOptions::get_ass_color(HexColor::YELLOW);
8    let srt_file = AssFile::from_srt("RapGod.srt");
9    let mut ass_file = AssFile::new();
10    let mut event = Events::default();
11
12    for srt_seg in srt_file.iter() {
13        let start = &srt_seg.start;
14        let end = &srt_seg.end;
15        let text = &srt_seg.text;
16
17        let random_color:HexColor = rand::random();
18
19        let dialogue = Dialogue::default()
20            .set_start(&start)
21            .set_end(&end)
22            .set_text(&text)
23            .set_colour(random_color);
24
25        event.add_dialogue(dialogue);
26    }
27    
28
29    ass_file.components.script
30        .set_script(ScriptInfo::default());
31
32
33
34    ass_file.components.v4
35        .set_v4(V4Format::default())
36        .set_primarycolour(&hexcolor);
37    ass_file.components.events
38        .set_events(event);
39
40    AssFile::save_file(&ass_file, "new_subtitle.ass");
41}
examples/timestamped_subtitles.rs (line 32)
5fn main() -> Result<(), IndexNotFound>{
6    let mut ass_file = AssFile::new();
7    let hexcolor = AssFileOptions::get_ass_color(HexColor::YELLOW);
8
9    let first_dialogue = Dialogue::default()
10        .set_start("0:00:00.10")
11        .set_end("0:00:00.50")
12        .set_text("Hello There.");
13
14    let second_dialogue = Dialogue::default()
15        .set_start("00:00.50")
16        .set_end("00:00.58")
17        .set_text("Hello Friend.");
18
19    let third_dialogue = Dialogue::default()
20        .set_start("0:00:00.58")
21        .set_end("0:00:01.01")
22        .set_text("Goodbye Friend.");
23
24    let events = Events::new()
25        .add_first_dialogue(first_dialogue)?
26        .add_dialogue(second_dialogue)
27        .add_dialogue(third_dialogue)
28        .create();
29
30
31    ass_file.components.script
32        .set_script(ScriptInfo::default())
33        .set_scripttype("FFMPEG");
34
35    ass_file.components.v4
36        .set_v4(V4Format::default())
37        .set_primarycolour(&hexcolor);
38
39    ass_file.components.events
40        .set_events(events);
41
42    AssFile::save_file(&ass_file, "new_subtitles.ass");
43
44    Ok(())
45
46}
Source§

impl ScriptInfo

Source

pub fn set_scripttype(&mut self, value: &str) -> &mut Self

After creating the AssFile set the scripttype of the .ass file. If you want to specify any, the default ScriptType from the original .ass file will be used. This is the SSA script format version eg. “V4.00”. It is used by SSA to give a warning if you are using a version of SSA older than the version that created the script. ASS version is “V4.00+”.

Examples found in repository?
examples/timestamped_subtitles.rs (line 33)
5fn main() -> Result<(), IndexNotFound>{
6    let mut ass_file = AssFile::new();
7    let hexcolor = AssFileOptions::get_ass_color(HexColor::YELLOW);
8
9    let first_dialogue = Dialogue::default()
10        .set_start("0:00:00.10")
11        .set_end("0:00:00.50")
12        .set_text("Hello There.");
13
14    let second_dialogue = Dialogue::default()
15        .set_start("00:00.50")
16        .set_end("00:00.58")
17        .set_text("Hello Friend.");
18
19    let third_dialogue = Dialogue::default()
20        .set_start("0:00:00.58")
21        .set_end("0:00:01.01")
22        .set_text("Goodbye Friend.");
23
24    let events = Events::new()
25        .add_first_dialogue(first_dialogue)?
26        .add_dialogue(second_dialogue)
27        .add_dialogue(third_dialogue)
28        .create();
29
30
31    ass_file.components.script
32        .set_script(ScriptInfo::default())
33        .set_scripttype("FFMPEG");
34
35    ass_file.components.v4
36        .set_v4(V4Format::default())
37        .set_primarycolour(&hexcolor);
38
39    ass_file.components.events
40        .set_events(events);
41
42    AssFile::save_file(&ass_file, "new_subtitles.ass");
43
44    Ok(())
45
46}
Source

pub fn set_playresx(&mut self, value: &str) -> &mut Self

After creating the AssFile set the playresx of the .ass file.

This is the height of the screen used by the script’s author(s) when playing the script. SSA v4 will automatically select the nearest enabled setting, if you are using Directdraw playback.

If you don’t want to specify any, the default playresx from the original .ass file will be used.

Source

pub fn set_playresy(&mut self, value: &str) -> &mut Self

After creating the AssFile set the playresy of the .ass file.

This is the height of the screen used by the script’s author(s) when playing the script. SSA v4 will automatically select the nearest enabled setting, if you are using Directdraw playback.

If you want to specify any, the default playresy from the original .ass file will be used.

Source

pub fn set_scaledborderandshadow(&mut self, value: &str) -> &mut Self

After creating the AssFile set the scaledborderandshadow of the .ass file. If you want to specify any, the default scaledborderandshadowfrom the original .ass file will be used.

Source

pub fn set_ycbcr_matrix(&mut self, value: &str) -> &mut Self

After creating the AssFile set the ycbcr_matrix( of the .ass file. If you want to specify any, the default ycbcr_matrix from the original .ass file will be used.

Trait Implementations§

Source§

impl Clone for ScriptInfo

Source§

fn clone(&self) -> ScriptInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScriptInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScriptInfo

Source§

fn default() -> ScriptInfo

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ScriptInfo

Source§

fn eq(&self, other: &ScriptInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ScriptInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V