diff --git a/CHANGELOG.md b/CHANGELOG.md index f7da34a..082a436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to TeXora. The newest version is first. +## 1.5.1 + +### Fixed + +- **Editing in LaTeX Studio.** After a click on Save, Compile, a checkbox or the slide, the editor lost the keyboard, so the next letters ran presenter shortcuts instead of typing: **B** blacked out the slide and the arrows changed slides and moved the cursor. The keyboard now stays with the editor; another text box (such as Search) still gets its own typing. +- **No more rebuilding as you type.** The **Live** box is gone: typing never saves or rebuilds by itself. Press **Compile** (Cmd/Ctrl+B), or **Save** (Cmd/Ctrl+S) with **Rebuild on save** on. +- A file opened from a terminal with a short path (`texora talk.tex`) now compiles and checks its packages; before, both failed with "No such file or directory". +- Videos play with their sound. The sound comes from ffplay, which is part of every ffmpeg install (TeXora finds it beside your ffmpeg), and follows the picture: it starts, pauses and starts again from the same place, starts again with a `loop` clip, and stops when you show another slide. TeXora still contains no decoder of its own. +- **Settings > Video > Play sound** turns video sound on or off (on by default), and the `mute` option of `\includevideo` now keeps one clip silent. GIFs have no sound. +- ffplay runs with the same safety as ffmpeg: no window, no shell, local files only and real video formats only. +- The Video Guide template's sample video has a soft chord, so you can hear sound working. +- **Sound with VLC only.** Without ffmpeg, a clip opened in VLC plays its sound in VLC (ffplay is not needed). The `mute` option and **Settings > Video > Play sound** off now also keep VLC silent, and Settings > Video says where the sound plays. +- **Picture and sound in sync.** The picture now follows the sound's own clock (ffplay reports it), so it waits the moment ffplay takes to start instead of running ahead. Measured with a clip that flashes and beeps each second: the picture was 730 ms ahead of the sound, now within about 5 ms, also after pause and play. After a pause the sound starts again exactly where the picture is (before, it could start seconds early, from the last key frame). + ## 1.5.0 ### Security diff --git a/Cargo.lock b/Cargo.lock index 9344cd1..8072cae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2935,7 +2935,7 @@ dependencies = [ [[package]] name = "texora" -version = "1.5.0" +version = "1.5.1" dependencies = [ "dirs", "display-info", diff --git a/Cargo.toml b/Cargo.toml index 002b962..00c9b15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "texora" -version = "1.5.0" +version = "1.5.1" edition = "2021" description = "TeXora: a LaTeX-native presenter for Beamer and PDF slides" license = "PolyForm-Noncommercial-1.0.0" diff --git a/README.md b/README.md index 3624efb..bf3af4d 100644 --- a/README.md +++ b/README.md @@ -1,370 +1,394 @@

- TeXora icon + TeXora icon

TeXora

- Present PDF and LaTeX Beamer slides with confidence.
- Free for non-commercial use, with its source code open to read, for macOS, Windows and Linux. + A presenter for LATEX Beamer and PDF slides:
+ private notes, audience screen, live LaTeX editor, rehearsal analytics, animation and video.
+ macOS, Windows and Linux.

- Download · + Download · Features · - Guide · + Quick start · + Guide · Shortcuts · Build

-![The large slide view: the slide with its drawing tools, notes, the next slide, the talk's sections and the timer](screenshots/large-slide.png) +

+ Large slide view: the slide with drawing tools, speaker notes, next slide, sections bar and timer +

-TeXora is a presenter for **LaTeX Beamer** and **PDF** slides. You see your notes, the current and -next slide and the time; the room sees only the slide. Open a `.tex` file and edit it in the built-in -LaTeX studio, beside a live preview, or in your own editor: the slides rebuild either way. +TeXora shows the speaker the notes, the current and next slide and the time, while the audience sees +only the slide. It opens PDF files and LaTeX Beamer sources; a `.tex` file is compiled on opening and +can be edited in the built-in LaTeX studio or in any other editor. ## Screenshots -| Home | Presenter view | -|---|---| -| ![Home page with recent files](screenshots/home.png) | ![Presenter view with notes, current and next slide](screenshots/presenter.png) | + + + + + + + + + +
Presenter view
Presenter view
LaTeX studio
LaTeX studio
Slide and notes split view
Slide and notes, side by side
Slide overview
Slide overview
+ +
+More screenshots +
+ + + + + + + + + + + + + +
Home page with recent files
Home
Audience window
Audience window
Editing speaker notes
Editing notes
Contents sidebar
Contents and bookmarks
Rehearsal analytics
Analytics
Settings sidebar
Settings
+
-| Slide and notes, side by side | Every slide at a glance | -|---|---| -| ![Split view with the audience slide, notes and next slide](screenshots/split.png) | ![Overview of all slides](screenshots/overview.png) | +## Features -The audience window shows only the slide, fullscreen on a projector or second screen: +| | | +| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| **Presenter view** | Notes, current and next slide, overlay step, elapsed time, pace against a set duration, and a clock. Large-slide and split views. | +| **Audience window** | Fullscreen on a projector or second display (F5). Black screen, whiteboard and freeze. | +| **LaTeX studio** | Source editor beside a slide and notes preview, with problems listed by line and SyncTeX links between slide and source. | +| **LaTeX Beamer** | Compiles with pdfLaTeX, XeLaTeX or LuaLaTeX, chosen from `% !TEX program` or the packages used. Rebuilds when the file is saved in any editor. | +| **Required packages** | Lists every package, theme and program a file needs, with how to install the missing ones. | +| **Speaker notes** | From Beamer notes pages, `\note{}`, `.pdfpc` files or a Markdown file; editable in the app, in any language. | +| **Animations and video** | `animate` package animations, GIFs and video clips play inside the slide; video uses an installed ffmpeg or VLC. | +| **Drawing and pointing** | Pen, highlighter, eraser, laser pointer and zoom to an area. Ink is kept per slide. | +| **Navigation** | Contents, bookmarks, question marks and full-text search in a sidebar. Tabs for several presentations. | +| **Analytics** | Time on each slide for every rehearsal, compared with the previous one. | +| **Tools** | Configurable shortcuts, a system check, a command-line interface and update notices. | -![The audience window](screenshots/audience.png) +## Download and install -## Features +Each system has an installer and a portable package in the [latest release](https://github.com/khalidt/TeXora/releases/latest). -- **Presenter view**: notes, current and next slide, slide number and overlay step, elapsed time, talk - duration with pace (ahead or behind), and a clock. Also a large-slide view and a split view. -- **Audience window** (F5): fullscreen on a second display, or press F11 on one display. Black screen - (B), whiteboard (W) and freeze (F) to look ahead privately. -- **LaTeX studio**: edit the `.tex` source beside a live preview of the slide and its notes. Slides - rebuild as you type, problems are listed with their line numbers, and a double-click on a slide finds - its source. -- **LaTeX Beamer**: a `.tex` file compiles with pdfLaTeX, XeLaTeX or LuaLaTeX (chosen for you from - `% !TEX program` or the packages used). Editing it in your own editor works too: the slides rebuild - when you save. -- **Required packages**: every package, theme and program your file needs, marked Installed or Needs - download, with how to get it, in the studio and in Settings. -- **Speaker notes** from PDF notes pages (Beamer's `show notes on second screen`), from `\note{}` in the - source, from a `.pdfpc` file, or from a Markdown file beside the presentation. **Edit notes** for any - slide right in the notes panel. -- **Animations and videos**: animations made with the LaTeX `animate` package play on the slide, with - autoplay, looping and play controls. Videos and GIFs placed with the built-in `texoravideo` package - play inside the slide; `\movie` and media9 clips open in your video player. -- **Drawing and pointing**: pen, highlighter, eraser, a laser pointer in several colours, and zoom into - an area. Ink is kept per slide. -- **Zoom** any slide with the wheel or a pinch, around the pointer. -- **Bookmarks and questions**: mark slides in their section's colour, and mark where questions came up. - Only you see them. -- **Contents and search** in a sidebar, from the PDF outline and text. -- **Analytics**: time on each slide for every rehearsal, compared with the last one. -- **Tabs**: several presentations open at once, each keeping its place, ink and timer. -- **Configurable shortcuts**, a **System check** (? menu) that shows what your computer has, a - **command-line tool**, and **update notices**: TeXora looks for a new release when it starts and every - few hours while it is open, and tells you in a small notice with a download for your computer. +| System | Installer | Portable | +| -------------------------------------- | ---------------------------------------- | ------------------------------------- | +| macOS, Apple silicon (M1 and later) | `TeXora--mac-arm64.dmg` | `…-mac-arm64.zip` | +| macOS, Intel | `TeXora--mac-x64.dmg` | `…-mac-x64.zip` | +| Windows 10 and 11 (x64) | `TeXora--windows-x64-setup.exe` | `…-windows-x64.zip` | +| Debian, Ubuntu and derivatives (x64) | `texora__amd64.deb` | `TeXora--linux-x64.tar.gz` | +| Debian, Ubuntu and derivatives (arm64) | `texora__arm64.deb` | `TeXora--linux-arm64.tar.gz` | -## Download and install +- **macOS**: open the `.dmg` and drag **TeXora** to **Applications**. macOS asks for confirmation the + first time; see [First launch on macOS](#first-launch-on-macos). +- **Windows**: run the setup program. It installs per user without administrator rights (or for all + users), adds Start menu and "Open with" entries for PDF and `.tex` files, and can be removed from + *Installed apps*. Windows may warn about an unknown publisher. +- **Linux**: `sudo apt install ./texora__amd64.deb`, then start **TeXora** from the menu or + run `texora`. The `.tar.gz` runs from any folder with `./TeXora`. Requires glibc 2.31 or newer + (Ubuntu 20.04, Debian 11 or later) and an X11 or Wayland desktop. + +**Requirements.** Presenting PDF files needs nothing else: each package includes the PDF engine. -Get TeXora from the [latest release](https://github.com/khalidt/TeXora/releases/latest). +| To | Install | +| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | +| Presenting `PDF` files | nothing | +| Compile `.tex` files | A TeX distribution: **MacTeX** (macOS), **MiKTeX** or TeX Live (Windows), **TeX Live** (Linux) | +| Play MP4 and other videos | **ffmpeg** (plays inside the slide, with sound through ffplay) or **VLC** (plays in its own window). Optional; GIFs need neither. | -| System | Installer | Portable | -|---|---|---| -| macOS, Apple chips (M1 and later) | `TeXora--mac-arm64.dmg` | `…-mac-arm64.zip` | -| macOS, Intel | `TeXora--mac-x64.dmg` | `…-mac-x64.zip` | -| Windows 10 and 11 (x64) | `TeXora--windows-x64-setup.exe` | `…-windows-x64.zip` | -| Debian, Ubuntu and relatives (x64) | `texora__amd64.deb` | `TeXora--linux-x64.tar.gz` | -| Debian, Ubuntu and relatives (arm64) | `texora__arm64.deb` | `TeXora--linux-arm64.tar.gz` | +Every release file is listed with its checksum in `SHA256SUMS.txt`; `VALIDATION.txt` records how each +file was tested. -- **macOS**: open the `.dmg` and drag **TeXora** to **Applications**. The first time, macOS asks you - to confirm it; see [Opening TeXora on a Mac the first time](#opening-texora-on-a-mac-the-first-time). -- **Windows**: run the setup program. It installs for you alone without administrator rights (or for - everyone, if you choose), adds TeXora to the Start menu and to "Open with" for PDF and `.tex` - files, and appears in *Installed apps* for uninstalling. Windows may warn about an unknown publisher. -- **Linux**: `sudo apt install ./texora__amd64.deb`, then start **TeXora** from the - menu or run `texora`. Or unpack the `.tar.gz` anywhere and run `./TeXora`. Needs glibc 2.31 or - newer (Ubuntu 20.04, Debian 11 or later) and an X11 or Wayland desktop. +### First launch on macOS -### Opening TeXora on a Mac the first time +TeXora is signed *ad hoc* rather than with an Apple Developer ID, so macOS blocks the first launch. -TeXora is signed *ad hoc*, not with a paid Apple Developer ID, so macOS cannot check who made it and -blocks it the first time it is opened. +
+Steps to open TeXora the first time +
-On **macOS 15 Sequoia and later**, the old right-click > **Open** shortcut no longer works. Instead: +**macOS 15 Sequoia and later** -1. Open **TeXora** once and click **Done** on the warning. -2. Go to **System Settings > Privacy & Security**. -3. Scroll to the **Security** section, find the line saying TeXora was blocked, and click **Open Anyway**. -4. Enter your password or use Touch ID, and confirm. +1. Open **TeXora** and click **Done** on the warning. +2. Open **System Settings > Privacy & Security**. +3. In the **Security** section, find the entry for TeXora and click **Open Anyway**. +4. Confirm with the password or Touch ID. -On **macOS 14 Sonoma and earlier**, right-click (or Control-click) TeXora in Applications, choose +**macOS 14 Sonoma and earlier**: right-click (or Control-click) TeXora in Applications, choose **Open**, then **Open** again. -If you prefer Terminal, this removes the download mark so TeXora opens normally: +**Terminal** (any version): remove the download mark. ```sh xattr -dr com.apple.quarantine /Applications/TeXora.app ``` -You only need to do this once; after that TeXora opens like any other app. +This is needed only once. + +
+ +## Quick start + +1. Start TeXora. **Home** lists recent files and ways to begin. +2. Choose **New LaTeX presentation**, **Open PDF presentation** or **Open LaTeX project**, pick a + recent file, or drop a file on the window. **Try the sample lecture** opens a complete example talk. +3. A `.tex` file is compiled on opening. Edit it in the **LaTeX studio** (Cmd/Ctrl+E) or in another + editor. +4. Press **F5** to open the audience window, then move through the slides with the arrow keys or + **Space**. + +Each presentation opens in its own tab, with its own position, ink and timer. Every button shows its +name and shortcut on hover. + +
+Templates for new LaTeX presentations +
+ +Each template is a complete Beamer file with speaker notes. -Every file is listed with its checksum in `SHA256SUMS.txt`, and `VALIDATION.txt` shows how each one was -tested before the release. +| Template | Contents | +| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------ | +| Classic Green, Midnight, Minimal White, Conference, Sunrise | Static themes | +| Motion Lab | Animations drawn with TikZ | +| Flipbook | The frames of a GIF and charts that grow | +| Media Studio | A video clip and charts that draw themselves | +| Video Guide | `\includevideo` explained slide by slide, with a video and a GIF playing inside the slides | -Nothing else is needed to present PDFs: each package carries the program and its PDF engine. To compile -`.tex` files, install a TeX distribution: **MacTeX** on macOS, **MiKTeX** or TeX Live on Windows, -**TeX Live** on Linux. +Flipbook, Media Studio and Video Guide save their pictures and clips in a `media` folder beside the +new file. -## Using TeXora +
-### Getting started +## Guide -1. Start TeXora. **Home** shows your recent files and ways to begin. -2. Choose **New LaTeX presentation** to start from a template, **Open PDF presentation** or **Open - LaTeX project**, pick a recent file, or drop a file on the window. **Try the sample lecture** opens - a ready-made talk to explore. +### Presenter screen - **New LaTeX presentation** offers nine templates, each a complete Beamer file with speaker notes: - Classic Green, Midnight, Minimal White, Conference and Sunrise, and four animated ones. **Motion - Lab** shows animations drawn with TikZ, **Flipbook** plays the frames of a GIF and charts that - grow, **Media Studio** has a video clip and charts that draw themselves, and **Video Guide** - explains `\includevideo` slide by slide, with a video and a GIF that play inside the slides. - Flipbook, Media Studio and Video Guide save their pictures and clips in a `media` folder beside - the new file. -3. A `.tex` file is compiled for you. Edit it in the **LaTeX studio** (Cmd/Ctrl+E), or in your own - LaTeX editor: the slides rebuild either way. -4. Press **F5** to show the slides to the room, then move with the arrow keys or **Space**. +The left panel holds the speaker notes; the right panel shows the current slide (what the audience +sees) and the next slide. The timer, slide number and sections bar run along the bottom. -Each presentation opens in its own tab, and keeps its place, ink and timer. Hover over any button to -see its name and shortcut. +
+Areas of the presenter screen +
+

Presenter screen

-### The presenter screen +| Area | Content | +| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Top row** | Open files; readiness (displays, duration, notes) or, while presenting, what the audience sees; the time of day; **Present**, which opens the audience window. | +| **Notes** | Speaker notes for the slide on screen. Scroll or pinch to change the text size. | +| **Current slide** | What the audience sees. | +| **Next slide** | The next slide or overlay step. | +| **Timer** | Elapsed time (click to pause or resume), talk duration (click to set), and play, pause and stop buttons. | +| **Previous and next** | One step back or forward, with the slide number and overlay step. | +| **Sections** | The talk's sections in their colours, sized by number of slides. A black line marks the position; ribbons mark bookmarks. Click a section to go there. | +| **Pace** | Time left, or time ahead, behind or over. When behind, a button offers to skip slides to recover the time. | -![The presenter screen: notes on the left, current and next slide on the right, the talk's sections and the timer below](screenshots/presenter.png) +**Large slide** view (**N**) shows the slide across the main panel with the drawing tools beside it. +Drag the dividers to resize panels; **View > Fit all panels automatically** resets them. -| Area | What it shows | -|---|---| -| **Top row** | The open files; whether you are ready (displays, duration, notes) or, while presenting, what the audience sees; the time of day; and **Present**, which opens the audience window. | -| **Notes** | Your speaker notes for the slide on screen. Scroll or pinch to change the text size. | -| **Current slide** | What the room sees right now. | -| **Next slide** | What comes next, including the next overlay step. | -| **Timer** | Under the main panel, left of the slide number: time elapsed (click it to pause or resume), the duration (click it to set it), and play, pause and stop buttons. | -| **Previous and next** | Beside the timer: one step back or on, with the slide number and overlay step between them. | -| **Sections** | Your talk's sections in their colours, each as wide as its share of the slides. A black line marks where you are and ribbons mark bookmarks. Click a section to go there. | -| **Pace** | Under the sections: the time left, or how far ahead, behind or over you are. When you are behind, a button offers to skip the next slides that would make up the time. | +
-In **Large slide** view (**N**) the slide fills the main panel, with the drawing tools beside it and the -notes and next slide on the right: +### Toolbar -![The large slide view with the drawing tools beside the slide](screenshots/large-slide.png) +The second row of buttons acts on the open presentation: views, the audience screen, notes, drawing, +zoom and navigation. -Drag the dividers between the panels to resize them; **View > Fit all panels automatically** resets them. +
+All toolbar buttons +
-### The toolbar +**Views** -The second row of buttons acts on the open presentation. From left to right: +| Button | Name | Action | Key | +|:--------------------------------------------------------------------------:| --------------------- | ------------------------------------------------- | ---------- | +| Presenter | Presenter | Notes with the current and next slide | | +| Large slide | Large slide | A large current slide with notes beside it | N | +| Split | Slide and notes split | Slide and notes side by side, with the next slide | S | +| Overview | Slide overview | Every slide at a glance; click one to go there | O | +| LaTeX studio | LaTeX studio | Edit the `.tex` source beside the slide | Cmd/Ctrl+E | -#### Views +**Audience screen** -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Presenter | **Presenter** | Notes with the current and next slide. | | -| Large slide | **Large slide** | A large current slide with the notes beside it. | N | -| Slide and notes split | **Slide and notes split** | The slide and the notes side by side, with the next slide. | S | -| Slide overview | **Slide overview** | Every slide at a glance. Click one to go there. | O | -| LaTeX studio | **LaTeX studio** | Edit the `.tex` source beside the slide. See [The LaTeX studio](#the-latex-studio). | Cmd/Ctrl+E | +| Button | Name | Action | Key | +|:---------------------------------------------------------------------------:| --------------- | ---------------------------------------------------------------- | --- | +| Audience window | Audience window | Slides in their own window, fullscreen on a second display | F5 | +| Black screen | Black screen | Blanks the audience screen; press again to restore | B | +| Whiteboard | Whiteboard | A white page to draw on | W | +| Freeze | Freeze | Holds the audience on this slide while the presenter moves ahead | F | -#### The room's screen +**Notes** -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Audience window | **Audience window** | Opens the slides in their own window, fullscreen on a projector or second display. | F5 | -| Black screen | **Black screen** | Blanks the room's screen. Press again to show the slide. | B | -| Whiteboard | **Whiteboard** | Shows a white page to draw on. | W | -| Freeze | **Freeze** | Keeps the room on this slide while you look ahead privately. | F | +| Button | Name | Action | Key | +|:------------------------------------------------------------------------:| ---------- | ------------------------------------ | -------------- | +| Edit notes | Edit notes | Opens this slide's notes for editing | E | +| Save notes | Save notes | Saves the edited notes | Cmd/Ctrl+Enter | +| Cancel | Cancel | Discards the changes | Esc | -#### Notes +**Drawing and pointing** -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Edit notes | **Edit notes** | Opens the notes of this slide for editing, in the notes panel. | E | -| Save notes | **Save notes** | Shown while editing. Saves your changes. | Cmd/Ctrl+Enter | -| Cancel | **Cancel** | Shown while editing. Leaves the notes as they were. | Esc | +| Button | Name | Action | Key | +|:--------------------------------------------------------------------------:| ------------- | ------------------------------------------------- | ---------- | +| Pointer | Pointer | Normal pointer; click to advance | V | +| Pen | Pen | Draws on the slide, also on the audience screen | D | +| Highlighter | Highlighter | A wide, transparent stroke | H | +| Laser pointer | Laser pointer | A bright dot with a short trail | L | +| Eraser | Eraser | Removes the strokes it touches | X | +| Zoom to area | Zoom to area | Drag a box to enlarge that part for everyone | Z | +| Undo ink | Undo ink | Removes the last stroke | Cmd/Ctrl+Z | +| Colour | Colour | Ink colour, or laser colour while the laser is on | | -#### Drawing and pointing +Ink stays with each slide. **C** clears the ink on the current slide. -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Pointer | **Pointer** | The normal pointer: click to move on, no drawing. | V | -| Pen | **Pen** | Draw on the slide. The room sees it too. | D | -| Highlighter | **Highlighter** | A wide, see-through stroke to mark text. | H | -| Laser pointer | **Laser pointer** | A bright dot that follows your pointer, with a short trail. | L | -| Eraser | **Eraser** | Removes the strokes you touch. | X | -| Zoom to area | **Zoom to area** | Drag a box on the slide to enlarge that part for everyone. | Z | -| Undo ink | **Undo ink** | Takes back the last stroke. | Cmd/Ctrl+Z | -| Colour | **Colour** | Chooses the ink colour, or the laser colour while the laser is on. | | +**Zoom** -Ink is kept with each slide, so it is still there when you come back. **C** clears the ink on the slide. +| Button | Name | Action | Key | +|:--------------------------------------------------------------------:| ----------- | ----------------------------------------------------------------- | --- | +| Zoom out | Zoom out | Makes the slide smaller | - | +| Zoom in | Zoom in | Enlarges the slide; the wheel or a pinch zooms around the pointer | + | +| Fit to page | Fit to page | Shows the whole slide | 0 | -#### Zoom +**Navigation** -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Zoom out | **Zoom out** | Makes the slide smaller again. | - | -| Zoom in | **Zoom in** | Enlarges the slide. The mouse wheel or a pinch zooms around the pointer. | + | -| Fit to page | **Fit to page** | Shows the whole slide again. | 0 | +| Button | Name | Action | Key | +|:--------------------------------------------------------------------:| ----------- | ------------------------------ | ------------ | +| First slide | First slide | Goes to the start | Home | +| Previous | Previous | One step back | Left | +| Next | Next | The next overlay step or slide | Right, Space | +| Last slide | Last slide | Goes to the end | End | -#### Moving through the slides - -| Button | Name | What it does | Key | -|:---:|---|---|---| -| First slide | **First slide** | Goes to the start. | Home | -| Previous | **Previous** | One step back. | Left | -| Next | **Next** | One step on: the next overlay or the next slide. | Right, Space | -| Last slide | **Last slide** | Goes to the end. | End | - -Between **Previous** and **Next**, the box shows the slide number: click it, type a number and press -Enter. **Shift+Right** and **Shift+Left** skip whole slides, and **Backspace** goes back to where you were. - -### The buttons at the top right - -| Button | Name | What it does | Key | -|:---:|---|---|---| -| Bookmark | **Bookmark** | Marks this slide in the colour of its section, to find it again quickly. | M | -| Question | **Question** | Marks that someone asked a question on this slide. Analytics counts them. | Q | -| Contents and bookmarks | **Contents and bookmarks** | Opens the sidebar with sections, bookmarks and questions. | T | -| Search | **Search** | Finds a word or phrase in the slides and notes. | Cmd/Ctrl+F | -| Analytics | **Analytics** | Shows how long you spent on each slide. | Y | -| Settings | **Settings** | Text size, LaTeX engine, required packages, notes, updates and shortcuts. | Cmd/Ctrl+, | -| Help | **Help** | Documentation, system check, command-line tool, shortcuts, updates and About. | | +Click the slide number between **Previous** and **Next** to type a slide number. **Shift+Right** and +**Shift+Left** skip whole slides; **Backspace** returns to the previous position. -These open a sidebar on the left. Click the same button again, or the cross, to close it. +**Top right** + +| Button | Name | Action | Key | +|:----------------------------------------------------------------------:| ---------------------- | ------------------------------------------------------------------------- | ---------- | +| Bookmark | Bookmark | Marks the slide in its section's colour | M | +| Question | Question | Records a question on this slide, counted in Analytics | Q | +| Contents | Contents and bookmarks | Sidebar with sections, bookmarks and questions | T | +| Search | Search | Finds text in slides and notes | Cmd/Ctrl+F | +| Analytics | Analytics | Time spent on each slide | Y | +| Settings | Settings | Text size, LaTeX, packages, video, notes, updates and shortcuts | Cmd/Ctrl+, | +| Help | Help | Documentation, system check, command-line tool, shortcuts, updates, About | | + +These buttons open a sidebar on the left; the same button or the cross closes it. + +
### Speaker notes -TeXora shows notes from any of these: - -- **Beamer notes pages**: add `\setbeameroption{show notes on second screen=right}` to your preamble. -- **`\note{...}`** in your `.tex` source. -- A **`.pdfpc`** file beside the PDF. -- A **notes file** saved next to the presentation (see below), with a `## Slide N` heading for each - slide. You can also write it yourself in any text editor. - -**Where notes are saved.** It depends on what you opened: - -| You opened | Notes are saved in | -|---|---| -| `Lecture.pdf` | `Lecture.note.md`, in the same folder | -| `Week 3 - Graphs.pdf` | `Week 3 - Graphs.note.md`, in the same folder | -| `Thesis defense.tex` | `Thesis defense.tex` itself, as `\note{...}` in each slide (or `Thesis defense.note.md`, with **Also save in the .tex file** unticked) | - -For a PDF, keep the `.note.md` file with the presentation when you move or share it, and the notes come -along. Notes saved by earlier versions as `Lecture.notes.md` are still read, and take the new name the -next time you save. - -For a LaTeX presentation, the source is the one place its notes live, so the presenter and the LaTeX -studio always show the same notes: a note edited in the presenter is written into that slide's -`\note{...}` and the slides rebuild, and a `\note` edited in the studio (or in your own editor) shows -in the presenter after the rebuild. A note you save in the presenter shows at once, without waiting -for the rebuild. To leave the `.tex` file alone, untick **Also save in the .tex file** under the note -editor (or in **Settings > Speaker notes**); the notes then go into the `.note.md` file beside it. **Settings > Speaker notes** shows where the open presentation's -notes are. - -**Edit notes.** Click Edit notes or press -**E**, type, then click Save or press -**Cmd/Ctrl+Enter** to save; **Esc** cancels. On a slide without notes, **Write notes** in the notes panel -does the same. Your notes are saved where the table above says, so they open with the presentation -next time. Markdown works: `**bold**`, `*emphasis*`, `- lists` and `# headings` (in a `.tex` file they -become `\textbf`, `\emph` and a list). Clearing all the text removes the slide's note. - -**Any language.** Notes can be written in any language, including Arabic, Chinese, Japanese and -Korean, and emoji. The fonts come from your computer. Arabic notes are shown right to left, aligned to -the right, both while you type them and when they are shown. Notes are -saved as UTF-8; files saved as UTF-16 or in older encodings are read too. - -![Editing the notes of a slide](screenshots/notes-edit.png) - -### The LaTeX studio - -Open a `.tex` file, then click LaTeX studio, -choose **View > LaTeX studio** or press **Cmd/Ctrl+E**. The source is on the left, the slide and its -notes on the right, and compile messages along the bottom. - -![The LaTeX studio: source editor, slide preview with notes, and the problems panel](screenshots/studio.png) - -| Control | What it does | -|---|---| -| **Compile** | Saves the source and builds the slides now. Also **Cmd/Ctrl+B**. | -| **Save** | Saves the source, and rebuilds if **Rebuild on save** is on. Also **Cmd/Ctrl+S**. | -| **Engine** (Auto) | pdfLaTeX, XeLaTeX or LuaLaTeX. **Auto** picks from `% !TEX program` or the packages used. | -| **Check packages** | Lists every package, theme and program the file needs, and how to get any that are missing. | -| **Live** | Saves and rebuilds shortly after you stop typing. | -| **Rebuild on save** | Rebuilds each time the file is saved, here or in your own editor. | -| **Follow cursor** | Shows the slide for the line the cursor is on. | -| **Wrap text** | Wraps long lines at the editor's width instead of scrolling sideways. | -| **Present** | Back to the presenter view. | - -- **Comment lines**: **Cmd/Ctrl+/** comments out the line the cursor is on, or every selected line, - with `%`; if they are all commented already, it uncomments them. **Cmd/Ctrl+]** always comments and - **Cmd/Ctrl+[** always uncomments. Change these keys in **Settings > Keyboard shortcuts**. -- **Find the source of a slide**: double-click anywhere on the slide preview; the editor jumps to that - line. The **<** and **>** buttons above the preview move between slides, and the wheel zooms. -- **Problems, Packages, Full log**: the panel along the bottom. Errors show their line number; click - one to go there. The panel's buttons wrap long lines, copy the text, and hide or show the panel. Drag - its top edge to resize it. -- Drag the edge between the source and the preview to make either wider; double-click it to split them - half and half again. -- If a presentation does not compile when you open it, it opens in the studio with the problems listed. -- Linking slides and source uses SyncTeX, which comes with TeX Live, MacTeX and MiKTeX. - -### Animations and videos - -**Animations.** Animations made with the LaTeX `animate` package play on the slide: -`\begin{animateinline}...\end{animateinline}`, or `\animategraphics` with a series of pictures (for -example the frames of a GIF). TeXora follows these settings of the animation: - -| Setting | What TeXora does | -|---|---| -| `autoplay` | Starts when its slide is shown and stops when you move on. Without it, the animation waits for a click. | -| `loop` | Starts again from the first frame. | -| `palindrome` | Plays forward, then backward. | -| Frame rate | Uses the rate set in the source, including changes with `\newframe[rate]`. | - -Other `animate` options have not been tested. Click the animation to play or pause it, in either window. -In the presenter view, a bar under the animation has **first**, **previous**, **play/pause**, **next** -and **last** frame buttons, and shows which frame is on show. The audience sees the same frame. - -**Using a GIF.** LaTeX cannot include a `.gif` file directly, so split it into pictures first and play -them with `\animategraphics`. With [ffmpeg](https://ffmpeg.org): +Notes come from Beamer notes pages (`\setbeameroption{show notes on second screen=right}`), from +`\note{...}` in the source, from a `.pdfpc` file, or from a Markdown notes file beside the +presentation. **Edit notes** (**E**) edits them in place; **Cmd/Ctrl+Enter** saves and **Esc** cancels. + +
+Where notes are saved, formatting and languages +
+ +| Opened file | Notes saved in | +| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| `Lecture.pdf` | `Lecture.note.md` in the same folder | +| `Thesis defense.tex` | `Thesis defense.tex`, as `\note{...}` in each frame (or `Thesis defense.note.md` with **Also save in the .tex file** off) | + +- **PDF**: keep the `.note.md` file with the PDF when moving or sharing it. Each slide has a + `## Slide N` heading; the file can also be written in any text editor. Files named + `Lecture.notes.md` by earlier versions are still read and renamed on the next save. +- **LaTeX**: the source is the single place for notes, so the presenter and the studio always agree. + A note saved in the presenter is written into the frame's `\note{...}`, shows at once, and the + slides rebuild. **Settings > Speaker notes** shows where the current notes are stored. +- **Formatting**: Markdown `**bold**`, `*emphasis*`, `- lists` and `# headings`; in a `.tex` file + these become `\textbf`, `\emph` and lists. Clearing all text removes the slide's note. +- **Languages**: any language and emoji, using the computer's fonts. Arabic and Hebrew are laid out + right to left while typing and when shown. Notes are saved as UTF-8; UTF-16 and older encodings are + read. + +

Editing the notes of a slide

+
+ +### LaTeX studio + +**View > LaTeX studio** (**Cmd/Ctrl+E**) shows the source on the left, the slide and its notes on the +right, and compile messages at the bottom. Typing never saves or rebuilds by itself: **Compile** +(**Cmd/Ctrl+B**) builds the slides, and **Save** (**Cmd/Ctrl+S**) rebuilds when **Rebuild on save** is on. + +

LaTeX studio: source editor, slide preview with notes, and the problems panel

+ +
+Studio controls and editing +
+ +| Control | Action | +| ------------------- | ----------------------------------------------------------------------------------- | +| **Compile** | Saves the source and builds the slides. **Cmd/Ctrl+B** | +| **Save** | Saves the source; rebuilds if **Rebuild on save** is on. **Cmd/Ctrl+S** | +| **Engine** | pdfLaTeX, XeLaTeX or LuaLaTeX; **Auto** reads `% !TEX program` or the packages used | +| **Check packages** | Lists every package, theme and program the file needs, and how to get missing ones | +| **Rebuild on save** | Rebuilds whenever the file is saved, in the studio or another editor | +| **Follow cursor** | Shows the slide for the line under the cursor | +| **Wrap text** | Wraps long lines at the editor's width | +| **Present** | Returns to the presenter view | + +- The editor keeps the keyboard while the studio is open, so typing never triggers presenter + shortcuts. Other text fields, such as Search, receive their own input. +- **Cmd/Ctrl+/** comments or uncomments the current or selected lines; **Cmd/Ctrl+]** always comments + and **Cmd/Ctrl+[** always uncomments. +- Double-click the slide preview to jump to its source. The **<** and **>** buttons move between + slides; the wheel zooms. +- The bottom panel has **Problems**, **Packages** and **Full log** tabs. Click a problem to go to its + line. Drag the panel's top edge to resize it. +- Drag the divider between source and preview to resize; double-click it to split evenly. +- A file that fails to compile on opening opens in the studio with its problems listed. +- The first time a file is opened, an untouched copy is kept as `.tex.texora-backup`. +- Slide and source links use SyncTeX, included with TeX Live, MacTeX and MiKTeX. + +
+ +### Animations + +Animations made with the LaTeX `animate` package (`animateinline` or `\animategraphics`) play on the +slide. Click to play or pause; in the presenter view a bar under the animation steps through frames. + +
+Supported settings and using a GIF with animate +
+ +| Setting | Behaviour | +| ------------ | ----------------------------------------------------------------------------------- | +| `autoplay` | Starts when the slide is shown and stops on leaving it; otherwise waits for a click | +| `loop` | Restarts from the first frame | +| `palindrome` | Plays forward, then backward | +| Frame rate | Follows the source, including changes with `\newframe[rate]` | + +Other `animate` options are untested. The audience sees the same frame as the presenter. + +LaTeX cannot include a `.gif` directly. Split it into pictures with [ffmpeg](https://ffmpeg.org) and +play them with `\animategraphics`, or use `\includevideo` (below), which plays GIFs without splitting. ```sh mkdir frames -ffmpeg -i anim.gif frames/f%d.png -ls frames | wc -l +ffmpeg -i anim.gif frames/f%d.png # add -vf "fps=10,scale=640:-1" to shrink a large GIF +ls frames | wc -l # number of frames ``` -The last command prints the number of frames. Use it as the last number below (30 here): - ```latex -\usepackage{graphicx} \usepackage{animate} -... -\animategraphics[autoplay,loop,width=0.5\textwidth]{10}{frames/f}{1}{30} +\animategraphics[autoplay,loop,width=0.5\textwidth]{10}{frames/f}{1}{30} % 30 = number of frames ``` -For a large GIF, shrink it while splitting, for example -`ffmpeg -i anim.gif -vf "fps=10,scale=640:-1" frames/f%d.png`, and keep the `frames` folder beside -the `.tex` file. +
+ +### Videos -**Videos inside the slide.** TeXora comes with its own LaTeX package, `texoravideo`, and finds it by -itself when it compiles; there is no package to install or copy. **GIFs play by themselves. MP4 -playback uses VLC or ffmpeg installed on your computer**: with ffmpeg the clip plays inside the slide, -with VLC in VLC's own window. TeXora contains no video decoder and never downloads or installs one. +TeXora includes the LaTeX package `texoravideo` and finds it when compiling. GIFs play by themselves; +MP4 and other formats play through ffmpeg or VLC installed on the computer. TeXora contains no video +decoder and never downloads or installs one. ```latex \usepackage{texoravideo} @@ -372,138 +396,153 @@ with VLC in VLC's own window. TeXora contains no video decoder and never downloa ... \includevideo[width=0.5\textwidth]{clip.mp4} \includevideo[height=5cm][loop,autoplay]{media/wave.gif} -\includevideo[width=\textwidth][poster=cover.png,posterat=25]{talk.mp4} ``` -- The first optional argument goes to `\includegraphics` as it is. The second takes `autoplay`, `loop`, - `posterat=` (where the poster is taken from; default the first frame) and `poster=`. -- The video must be in the `.tex` file's folder, or in a folder inside it (any name). If it is in a - folder, write the folder name too: `{videos/clip.mp4}`. Otherwise TeXora shows "Video not found". -- Before LaTeX runs, TeXora makes one poster per video in a `texora-video` folder beside the - presentation, again only when the clip changes; if a video is used with different `posterat` - values, the first counts. `texora-video/index.json` keeps what was found, so the - PDF still plays when opened later. Every PDF viewer shows the poster; only TeXora plays the clip. -- Click to play, click again to pause; another slide stops it, and overlay steps of the same slide keep - it playing. GIFs work the same way, with no splitting. -- GIFs always play. MP4 and other formats play when ffmpeg or VLC is installed; ffmpeg also makes - their posters. Choose the player in **Settings > Video** (Auto, ffmpeg, VLC or Off); each has a path - field and a **Test** button. -- No player installed: the clip says "This video needs VLC or ffmpeg installed on your computer.", with - **Get VLC** (videolan.org), **Get ffmpeg** (ffmpeg.org/download.html) and, on macOS and Linux, - **Copy install command** (`brew install ffmpeg`, or `sudo apt install ffmpeg`). TeXora copies the - command; you run it yourself. -- A missing file, a file that is not a video, or a path outside the presentation's folder (an absolute - path, `..`, a link leading out, a web address) shows a message over the poster and under Problems. - Names may have spaces and accents, but not `%` or `#`. -- ffmpeg and VLC run as separate programs, with a list of arguments and never through a shell; TeXora - ends ffmpeg when you leave the slide. Sound is not played yet. -- ffmpeg reads a clip with `-nostdin -protocol_whitelist file` and real video formats only, so a file - that is really a playlist or concat list cannot reach other files or the web. VLC gets the full path - after `--`, and only real video files. Which program runs comes only from your Settings: a - presentation or anything in its folder can never set it or add arguments. - -**Videos in your video player.** Use Beamer's `\movie` (the `multimedia` package) or media9's `\includemedia`. Each shows a -play button in the presenter view. Click it and the video opens in your computer's video player, -which you can move to the projector. The player may start paused, so press play there. +
+Options, players, sound and safety +
+ +**Options.** The first optional argument goes to `\includegraphics`. The second takes: + +| Option | Effect | +| -------------------- | ------------------------------------------------------------------- | +| `autoplay` | Starts when the slide is shown | +| `loop` | Restarts at the end | +| `mute` | Plays without sound (in the slide and in VLC) | +| `posterat=` | Takes the poster from that point of the clip (default: first frame) | +| `poster=` | Uses an image as the poster | + +**Files.** The video must be in the `.tex` file's folder or a folder inside it, written with its folder: +`{videos/clip.mp4}`. Names may contain spaces and accents, but not `%` or `#`. Before compiling, +TeXora makes one poster per video in a `texora-video` folder, updated only when the clip changes, so +every PDF viewer shows the poster; only TeXora plays the clip. + +**Playback.** Click to play or pause; another slide stops the clip, while overlay steps of the same +slide keep it playing. **Settings > Video** chooses the player (Auto, ffmpeg, VLC or Off), each with a +path field and a **Test** button. ffmpeg plays inside the slide; VLC plays in its own window. Without +a player, the clip shows "This video needs VLC or ffmpeg installed on your computer." with **Get VLC**, +**Get ffmpeg** and, on macOS and Linux, **Copy install command**. TeXora only copies the command; it +never runs it. + +**Sound.** With ffmpeg, the sound plays through ffplay, part of every ffmpeg install. It starts, +pauses and loops with the picture and stops on leaving the slide. The picture follows the sound's own +clock, so the two stay in sync (within about 5 ms in tests). **Settings > Video > Play sound** turns +sound on or off. GIFs have no sound. With VLC only (no ffmpeg), VLC plays the sound itself in its own +window; **Play sound** and `mute` apply there too. + +**Problems.** A missing file, a file that is not a video, or a path outside the presentation's folder +(absolute paths, `..`, links leading out, web addresses) shows a message over the poster and under +Problems. + +**Safety.** + +- ffmpeg, ffplay and VLC run as separate programs with an argument list, never through a shell, and + end when the slide changes. +- ffmpeg and ffplay read only local files (`-protocol_whitelist file`) in real video formats, so a + playlist or concat list disguised as a video cannot reach other files or the web. +- VLC receives the full path after `--`, and only files whose content is a video. +- The program and its arguments come only from Settings. A presentation, or any file in its folder, + cannot set them. + +
+ +
+Clips that open in an external video player (\movie, media9) +
+ +Beamer's `\movie` (`multimedia` package) and media9's `\includemedia` show a play button in the +presenter view. A click opens the clip in the system's video player, which can be moved to the +projector; some players start paused. ```latex \usepackage{multimedia} -... \movie[width=4cm,height=2.25cm]{\fbox{Play}}{clip.mp4} ``` -- A clip set to start by itself (`activate=pageopen` in media9) opens when its slide is shown while - the audience window is open. Otherwise, click it. -- Keep a `\movie` file in the same folder as the presentation. Clips packed into the PDF by media9 are - unpacked by TeXora. -- Write `\movie` without `externalviewer`. `\movie[externalviewer]` and `\href{run:...}` links are not - opened yet, and links to local files (`\href{file:...}`) are not opened. +- A media9 clip set to `activate=pageopen` opens when its slide is shown while the audience window is + open. +- Keep a `\movie` file in the presentation's folder. Clips embedded by media9 are extracted by TeXora. +- `\movie[externalviewer]`, `\href{run:...}` and `\href{file:...}` links are not opened. - These clips do not play inside the slide; use `\includevideo` for that. -### Presenting to the room - -- **F5** opens the audience window. With a second display it goes fullscreen there; on one display, - press **F11** to make it fullscreen. -- **B** blanks the screen, **W** shows a whiteboard, and **F** freezes the room on one slide while you - look ahead. -- Ink, the laser pointer and zoom are shown to the room as you use them. - -### Contents, bookmarks and search +
-The **Contents** sidebar lists the sections of your talk, each in its own colour, with your bookmarks and -questions above them. Click any entry to go there; **Back to where I was** returns. +### Presenting -![The contents sidebar](screenshots/contents.png) +- **F5** opens the audience window, fullscreen on a second display; on a single display, **F11** + makes it fullscreen. +- **B** blanks the screen, **W** shows a whiteboard, **F** freezes the audience view. +- Ink, the laser pointer and zoom appear on the audience screen as they are used. -### Analytics +### Contents, analytics and settings -Every rehearsal is timed slide by slide. **Analytics** shows the total time, the time on each slide -compared with your previous run, what stands out, and where questions came up. **Save as CSV** keeps -the numbers. +- **Contents** (**T**) lists the talk's sections in colour, with bookmarks and questions; **Back to + where I was** returns to the previous position. +- **Analytics** (**Y**) times every rehearsal slide by slide, compares it with the previous run and + exports CSV. +- **Settings** covers text size, the LaTeX engine, required packages, video, notes, updates and every + keyboard shortcut. +- The **?** menu has **Documentation**, **System check**, **Command-line tool**, **Keyboard + shortcuts**, **Check for updates** and **About TeXora**. -![Analytics: time on each slide](screenshots/analytics.png) +
+Updates +
-### Settings +When a new version is published, a notice appears in the lower right corner with **See what's new**, +**Later** and **Skip this version**, and a dot appears on the **?** button. The update box links the +package for the current system and the release page; installing over the existing copy keeps the +settings. **? > Check for updates** checks at any time; **Settings > Updates** turns automatic checks +off. See [CHANGELOG.md](CHANGELOG.md) for the changes in each version. -**Settings** has sections you can open and close: text size, the LaTeX engine, the packages your file -needs, where your notes are saved, updates, and every keyboard shortcut, which you can change. - -![The settings sidebar](screenshots/settings.png) - -### Help menu - -The **?** button holds **Documentation** (a short guide inside the app), **System check** (what this -computer has for TeXora), **Command-line tool** (the path of your copy, with examples), **Keyboard -shortcuts**, **Check for updates** and **About TeXora**. - -### Updates - -When a new version is published, TeXora shows a notice in the lower right corner by itself, with -**See what's new**, **Later** and **Skip this version**, and a dot on the **?** button. The update box -offers the package for your computer and the release page; install it over your copy and your settings -stay. **? > Check for updates** asks at any time. Turn the automatic look off in **Settings > Updates**. -TeXora 1.0.0 shows the dot on **?** only. See [CHANGELOG.md](CHANGELOG.md) for what changed in each -version. +
## Keyboard shortcuts -All can be changed in Settings. On macOS **Cmd** is used; on Windows and Linux, **Ctrl**. - -| Action | Keys | Action | Keys | -|---|---|---|---| -| Next / previous step | Right, Space / Left | Next / previous slide | Shift+Right / Shift+Left | -| First / last slide | Home / End | Go to slide | G | -| Audience window | F5 | Fullscreen | F11 | -| Black / white screen | B / W | Freeze audience | F | -| Overview | O | Split view | S | -| LaTeX studio | Cmd/Ctrl+E | Save source | Cmd/Ctrl+S | -| Large slide | N | Back | Backspace | -| Start or pause timer | P | Stop and reset timer | R | -| Set talk duration | U | Bookmark slide | M | -| Mark a question | Q | Contents | T | -| Search | Cmd/Ctrl+F | Analytics | Y | -| Pointer / pen / highlighter | V / D / H | Eraser / laser | X / L | -| Zoom to area | Z | Zoom in / out / fit | + / - / 0 | -| Undo ink / clear ink | Cmd/Ctrl+Z / C | Compile LaTeX | Cmd/Ctrl+B | -| Comment / uncomment lines (studio) | Cmd/Ctrl+/ | Comment / uncomment only | Cmd/Ctrl+] / Cmd/Ctrl+[ | -| Edit notes | E | Save notes | Cmd/Ctrl+Enter | -| Check required packages | Cmd/Ctrl+K | Open file | Cmd/Ctrl+O | -| Home | Cmd/Ctrl+L | Close tab | Cmd/Ctrl+W | -| Settings | Cmd/Ctrl+, | Cancel | Esc | +On macOS, **Cmd** is used; on Windows and Linux, **Ctrl**. All shortcuts can be changed in Settings. +In the LaTeX studio, single-key shortcuts are inactive while editing. + +
+All default shortcuts +
+ +| Action | Keys | Action | Keys | +| --------------------------- | ------------------- | ----------------------- | ------------------------ | +| Next / previous step | Right, Space / Left | Next / previous slide | Shift+Right / Shift+Left | +| First / last slide | Home / End | Go to slide | G | +| Audience window | F5 | Fullscreen | F11 | +| Black / white screen | B / W | Freeze audience | F | +| Overview | O | Split view | S | +| Large slide | N | Back | Backspace | +| Start or pause timer | P | Stop and reset timer | R | +| Set talk duration | U | Bookmark slide | M | +| Mark a question | Q | Contents | T | +| Search | Cmd/Ctrl+F | Analytics | Y | +| Pointer / pen / highlighter | V / D / H | Eraser / laser | X / L | +| Zoom to area | Z | Zoom in / out / fit | + / - / 0 | +| Undo ink / clear ink | Cmd/Ctrl+Z / C | Edit notes / save notes | E / Cmd/Ctrl+Enter | +| LaTeX studio | Cmd/Ctrl+E | Compile LaTeX | Cmd/Ctrl+B | +| Save source | Cmd/Ctrl+S | Check required packages | Cmd/Ctrl+K | +| Toggle comment (studio) | Cmd/Ctrl+/ | Comment / uncomment | Cmd/Ctrl+] / Cmd/Ctrl+[ | +| Open file | Cmd/Ctrl+O | Home | Cmd/Ctrl+L | +| Close tab | Cmd/Ctrl+W | Settings | Cmd/Ctrl+, | +| Cancel | Esc | | | + +
## Command line ```sh -TeXora talk.pdf # open a presentation -TeXora --self-test # check this copy works (exit code 0 means it passed) -TeXora --help # every option +TeXora talk.pdf # open a presentation (PDF or .tex) +TeXora --self-test # check this copy; exit code 0 means it passed +TeXora --help # all options ``` -**? > Command-line tool** in the app shows the exact path of your copy. +**? > Command-line tool** shows the path of the installed copy. ## Building from source -Needs [Rust](https://rustup.rs) (stable). The PDF engine (PDFium) is downloaded on the first build. +Requires [Rust](https://rustup.rs) (stable). The PDF engine (PDFium) is downloaded on the first build. ```sh git clone https://github.com/khalidt/TeXora.git @@ -513,21 +552,25 @@ cargo build --release cargo test ``` -## Project layout +
+Project layout +
+ +| Path | Content | +| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| `src/` | The application, in Rust with [egui](https://github.com/emilk/egui) and [PDFium](https://pdfium.googlesource.com/pdfium/) | +| `assets/` | Icon, Home picture, fonts, sample lecture, templates and the `texoravideo` LaTeX package | +| `scripts/` | Packaging, installer, release and icon scripts | +| `installer/` | Windows installer (Inno Setup) | +| `.github/workflows/` | Continuous tests and the release workflow | +| `screenshots/` | Pictures used in this README | -| Path | What it holds | -|---|---| -| `src/` | The app, in Rust with [egui](https://github.com/emilk/egui) and [PDFium](https://pdfium.googlesource.com/pdfium/). | -| `assets/` | App icon (`assets/icon.png`), Home picture, fonts and the sample lecture. | -| `scripts/` | Packaging, installer, release and icon scripts. | -| `installer/` | The Windows installer (Inno Setup). | -| `.github/workflows/` | Continuous tests and the release workflow. | -| `screenshots/` | The pictures in this README. | +
## Licence -Copyright 2026 Khalid Alkhaldi. Licensed under [PolyForm Noncommercial 1.0.0](LICENSE) -(): free to use, change and share for any -non-commercial purpose, including personal use, study, teaching, research and non-profit work. Commercial -use needs the author's permission. The app icon and Home picture are the author's artwork and are not -covered by the licence. See [CREDITS.md](CREDITS.md) for the libraries and fonts used. +Copyright 2026 Khalid Alkhaldi. Licensed under [PolyForm Noncommercial 1.0.0](LICENSE): free to use, +modify and share for any non-commercial purpose, including personal use, study, teaching, research and +non-profit work. Commercial use requires the author's permission. The app icon and Home picture are the +author's artwork and are not covered by the licence. Libraries and fonts are listed in +[CREDITS.md](CREDITS.md) and [THIRD-PARTY-LICENSES.md](THIRD-PARTY-LICENSES.md). diff --git a/assets/guide.md b/assets/guide.md index efdcdb8..c572f7c 100644 --- a/assets/guide.md +++ b/assets/guide.md @@ -70,7 +70,8 @@ To edit the current slide's notes, press the notes button beside the pointer, or Open a `.tex` file, then press **Cmd/Ctrl+E**, the studio button in the toolbar, or **View > LaTeX studio**. The source is on the left, the slide and its notes on the right, and the compile messages along the bottom. -- Slides rebuild shortly after you stop typing. Turn this off with the **Live** box. +- Typing never rebuilds by itself: press **Compile** (Cmd/Ctrl+B), or **Save** (Cmd/Ctrl+S) with **Rebuild on save** on. +- The keyboard stays with the editor, even after you click a button or the slide. - **Compile** (Cmd/Ctrl+B) builds now; **Save** (Cmd/Ctrl+S) saves the source. - Double-click a slide to find its source. Moving the cursor shows the matching slide (**Follow cursor**). - **Cmd/Ctrl+/** comments out the current or selected lines, or uncomments them if they all are. **Cmd/Ctrl+]** comments and **Cmd/Ctrl+[** uncomments. Change these in Settings. @@ -85,7 +86,7 @@ TeXora needs TeX Live, MacTeX or MiKTeX installed to compile. It picks pdfLaTeX, Animations made with the LaTeX **animate** package play on the slide, as in Adobe Acrobat. Those set to `autoplay` start when their slide is shown and stop when you move on; `loop` and `palindrome` work too, at the animation's own speed. Click an animation to play or pause it. In the presenter view, the bar under it has first, previous, play/pause, next and last frame buttons, and the audience sees the same frame. -Videos and GIFs can also play **inside the slide**. GIFs play by themselves; **MP4 playback uses VLC or ffmpeg installed on your computer** (ffmpeg plays inside the slide, VLC in its own window; choose in Settings > Video, which has a Test button). TeXora contains no video decoder and never installs one; when a video needs a player and none is found, it says so, with Get VLC, Get ffmpeg and Copy install command. Write `\usepackage{texoravideo}` and `\includevideo[width=0.5\textwidth]{clip.mp4}` (TeXora finds the package by itself). A second optional argument takes `autoplay`, `loop`, `posterat=25` or `poster=cover.png`. The video must be in the `.tex` file's folder or a folder inside it; if it is in a folder, write the folder name too, as in `{videos/clip.mp4}`. When compiling, TeXora makes one poster per video in a `texora-video` folder, so every PDF viewer shows the poster; in TeXora a click plays or pauses the clip and another slide stops it. Files that are not videos, files outside the presentation's folder, and videos not found show a message over the poster. +Videos and GIFs can also play **inside the slide**. GIFs play by themselves; **MP4 playback uses VLC or ffmpeg installed on your computer** (ffmpeg plays inside the slide, VLC in its own window; choose in Settings > Video, which has a Test button). TeXora contains no video decoder and never installs one; when a video needs a player and none is found, it says so, with Get VLC, Get ffmpeg and Copy install command. A video's sound plays with it through ffplay, which comes with ffmpeg; with VLC only, VLC plays the sound in its own window (Settings > Video > Play sound; the `mute` option keeps one clip silent, in VLC too). Write `\usepackage{texoravideo}` and `\includevideo[width=0.5\textwidth]{clip.mp4}` (TeXora finds the package by itself). A second optional argument takes `autoplay`, `loop`, `posterat=25` or `poster=cover.png`. The video must be in the `.tex` file's folder or a folder inside it; if it is in a folder, write the folder name too, as in `{videos/clip.mp4}`. When compiling, TeXora makes one poster per video in a `texora-video` folder, so every PDF viewer shows the poster; in TeXora a click plays or pauses the clip and another slide stops it. Files that are not videos, files outside the presentation's folder, and videos not found show a message over the poster. Video clips added with `\movie` (multimedia) or `\includemedia` (media9) show a play button on your screen. Click the clip to play it in your computer's video player; clips set to start by themselves open when their slide is shown while the audience window is open. Keep a `\movie` file in the same folder as the presentation. diff --git a/assets/templates/video.tex b/assets/templates/video.tex index 076f5a2..9bf2449 100644 --- a/assets/templates/video.tex +++ b/assets/templates/video.tex @@ -117,7 +117,7 @@ \{media/sample-video.mp4\} \end{semiverbatim} \begin{itemize} - \item \textbf{Click} to play, click again to pause. + \item \textbf{Click} to play, click again to pause. Its sound plays too. \item \code{posterat=30}: the poster is the picture 30\,\% of the way in. \end{itemize} \end{column} @@ -176,6 +176,7 @@ \code{loop} & starts again at the end \\ \code{posterat=25} & poster from 25\,\% of the way in (default: first frame) \\ \code{poster=cover.png} & your own poster picture \\ + \code{mute} & plays the clip without its sound \\ \bottomrule \end{tabular} \end{frame} @@ -264,8 +265,8 @@ \end{enumerate} \par\bigskip \begin{block}{Good to know} - GIFs play by themselves; MP4 playback uses VLC or ffmpeg installed on your computer. Sound is not - played yet. With ffmpeg, clips play on your screen and the audience's at the same time. + GIFs play by themselves; MP4 playback uses VLC or ffmpeg installed on your computer. With ffmpeg, + clips play on your screen and the audience's at the same time, with their sound. \end{block} \end{frame} \note{Thank the audience and invite questions.} diff --git a/assets/templates/video/sample-video.mp4 b/assets/templates/video/sample-video.mp4 index a61b782..05d58ba 100644 Binary files a/assets/templates/video/sample-video.mp4 and b/assets/templates/video/sample-video.mp4 differ diff --git a/screenshots/analytics.png b/screenshots/analytics.png index 3ad6a2e..124947f 100644 Binary files a/screenshots/analytics.png and b/screenshots/analytics.png differ diff --git a/screenshots/audience.png b/screenshots/audience.png index 9004e17..60f2225 100644 Binary files a/screenshots/audience.png and b/screenshots/audience.png differ diff --git a/screenshots/contents.png b/screenshots/contents.png index 7812ef8..257f7c4 100644 Binary files a/screenshots/contents.png and b/screenshots/contents.png differ diff --git a/screenshots/home.png b/screenshots/home.png index e879dcb..9b27df8 100644 Binary files a/screenshots/home.png and b/screenshots/home.png differ diff --git a/screenshots/large-slide.png b/screenshots/large-slide.png index bbf876c..95b5db4 100644 Binary files a/screenshots/large-slide.png and b/screenshots/large-slide.png differ diff --git a/screenshots/notes-edit.png b/screenshots/notes-edit.png index 1d48886..1369629 100644 Binary files a/screenshots/notes-edit.png and b/screenshots/notes-edit.png differ diff --git a/screenshots/overview.png b/screenshots/overview.png index 4d5aded..6418009 100644 Binary files a/screenshots/overview.png and b/screenshots/overview.png differ diff --git a/screenshots/presenter.png b/screenshots/presenter.png index 786835a..7da6493 100644 Binary files a/screenshots/presenter.png and b/screenshots/presenter.png differ diff --git a/screenshots/settings.png b/screenshots/settings.png index e57b99a..2b6a7f3 100644 Binary files a/screenshots/settings.png and b/screenshots/settings.png differ diff --git a/screenshots/split.png b/screenshots/split.png index df3e23d..3db5e85 100644 Binary files a/screenshots/split.png and b/screenshots/split.png differ diff --git a/screenshots/studio.png b/screenshots/studio.png index 0037692..7f64d2d 100644 Binary files a/screenshots/studio.png and b/screenshots/studio.png differ diff --git a/src/app.rs b/src/app.rs index 1208975..b9df18e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -201,6 +201,8 @@ pub struct App { pub syscheck_open: bool, /// The last text copied from that box, for the test report. pub cli_copied: Option, + /// In a test run, what the editor put on the clipboard (kept off the real clipboard). + pub test_clip: Option, pub update_open: bool, pub update_rx: Option>, pub update_result: Option, @@ -363,7 +365,7 @@ impl App { let st = Settings::load(); ctx.set_zoom_factor(st.ui_scale); // Which installed video tool (if any) plays videos that are not GIFs. - crate::video::configure(&st.video_player, &st.ffmpeg_path, &st.vlc_path); + crate::video::configure(&st.video_player, &st.ffmpeg_path, &st.vlc_path, st.video_sound); let mut app = App { tabs: vec![Tab::blank(1)], active: 0, @@ -393,6 +395,7 @@ impl App { template_picker: None, syscheck_open: false, cli_copied: None, + test_clip: None, update_open: false, update_rx: None, update_result: None, @@ -522,6 +525,10 @@ impl App { // ---------- files ---------- pub fn open_path(&mut self, path: &Path) { + // A short path typed in a terminal ("talk.tex") becomes a full one, so LaTeX, the package check + // and the recent list all find the file's folder. + let full = std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()); + let path = full.as_path(); let ext = path.extension().map(|e| e.to_string_lossy().to_lowercase()).unwrap_or_default(); self.st.recent.retain(|p| p != path); self.st.recent.insert(0, path.to_path_buf()); @@ -579,7 +586,7 @@ impl App { fn read_source(&self, path: &Path) -> Option { let text = notes::read_text(path)?; - // One untouched copy, byte for byte, since live editing saves as you type. + // One untouched copy, byte for byte, made the first time TeXora opens the file. let bak = path.with_extension("tex.texora-backup"); if !bak.exists() { let _ = std::fs::copy(path, &bak); @@ -999,15 +1006,6 @@ impl App { } } - // Live editing: save and rebuild shortly after typing stops. - let live = self.st.live_edit; - if let Some(s) = &self.src { - if s.dirty && live && s.last_edit.elapsed().as_secs_f32() > 1.5 && !self.compiling { - self.save_source(); - self.start_compile(); - } - } - // Files changed by another program (your editor, or a build elsewhere). if self.tex_checked.elapsed().as_secs_f32() > 1.0 { self.tex_checked = Instant::now(); @@ -1881,6 +1879,16 @@ impl App { pub fn screenshot_tick(&mut self, ctx: &Context) { let Some(path) = self.shot.clone() else { return }; + // A test run leaves the real clipboard alone and notes what would have been copied. + ctx.output_mut(|o| { + o.commands.retain(|c| match c { + egui::OutputCommand::CopyText(t) => { + self.test_clip = Some(t.clone()); + false + } + _ => true, + }) + }); self.frames_drawn += 1; ctx.request_repaint(); let settled = self.src.as_ref().map(|s| !s.dirty).unwrap_or(true); @@ -1956,6 +1964,17 @@ impl App { } } "t" => raw.events.push(egui::Event::Text(arg.to_string())), + // Shift with a key (to select), and the clipboard: copy, cut, and paste of the given text. + "S" => { + if let Some(key) = egui::Key::from_name(arg) { + for pressed in [true, false] { + raw.events.push(egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::SHIFT }); + } + } + } + "c" => raw.events.push(egui::Event::Copy), + "x" => raw.events.push(egui::Event::Cut), + "p" => raw.events.push(egui::Event::Paste(arg.replace("\\n", "\n"))), "z" => { let dy = arg.parse().unwrap_or(0.0); raw.events.push(egui::Event::MouseWheel { @@ -1983,7 +2002,7 @@ impl App { pub fn script_report(&self) -> String { let ink: usize = self.side.ink.values().map(Vec::len).sum(); format!( - "slide={} frame={} step={} tool={:?} screen={:?} frozen={:?} zoom={} ink={} laser={} timer={} audience={} swap={} history={} view={:?} questions={} slides={} tabs={:?} active={} bookmarks={:?} asked={:?} about={} update={:?} notice={:?} saved={:?} layout={:?} level={:.2} elapsed={:.1} target={} left={:?} missing={} warn={} status={:?} note={:?} cli={} copied={:?} syscheck={} packages={} recent={} toast={} skipped={:?} draft={:?} line={} log_open={} wrap={} follow={} anims={:?} videos={:?}", + "slide={} frame={} step={} tool={:?} screen={:?} frozen={:?} zoom={} ink={} laser={} timer={} audience={} swap={} history={} view={:?} questions={} slides={} tabs={:?} active={} bookmarks={:?} asked={:?} about={} update={:?} notice={:?} saved={:?} layout={:?} level={:.2} elapsed={:.1} target={} left={:?} missing={} warn={} status={:?} note={:?} cli={} copied={:?} syscheck={} packages={} recent={} toast={} skipped={:?} draft={:?} line={} log_open={} wrap={} follow={} anims={:?} videos={:?} clip={:?} avsync={:?}", self.cur + 1, self.frame() + 1, self.deck.slides.get(self.cur).map(|s| s.step + 1).unwrap_or(0), @@ -2038,10 +2057,19 @@ impl App { self.players .iter() .map(|p| { - let s = p.shared.lock().map(|s| (s.playing, (s.at * 10.0).round() / 10.0, s.error.clone())).unwrap_or_default(); + let s = p.shared.lock().map(|s| (s.playing, (s.at * 10.0).round() / 10.0, if s.sound { None } else { Some("silent".to_string()) }.or(s.error.clone()))).unwrap_or_default(); (p.frame_no, p.path.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(), s.0, s.1, s.2) }) .collect::>(), + self.test_clip, + // Each clip with sound: name, frames measured, mean and worst picture-minus-sound in ms. + self.players + .iter() + .filter_map(|p| { + let s = p.shared.lock().ok()?; + (s.sync.frames > 0).then(|| (p.path.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(), s.sync.frames, s.sync.mean_ms().round(), s.sync.worst_ms.round())) + }) + .collect::>(), ) } diff --git a/src/settings.rs b/src/settings.rs index 1f981d5..0c3f0f2 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -240,7 +240,6 @@ pub struct Settings { pub keys: Vec<(Action, Vec)>, pub engine: Engine, pub auto_compile: bool, - pub live_edit: bool, pub recent: Vec, pub ink_color: [u8; 3], pub laser_color: [u8; 3], @@ -259,6 +258,8 @@ pub struct Settings { /// Where ffmpeg and VLC are, when not found by themselves; empty means "find it". pub ffmpeg_path: String, pub vlc_path: String, + /// Videos play their sound (through ffplay, which comes with ffmpeg). + pub video_sound: bool, /// Look for a newer version when TeXora starts. pub check_updates: bool, /// A newer version the speaker chose to skip: its update notice is not shown again. @@ -274,7 +275,6 @@ impl Default for Settings { keys: default_keys(), engine: Engine::Auto, auto_compile: true, - live_edit: true, recent: vec![], ink_color: [214, 40, 40], laser_color: [235, 30, 30], @@ -286,6 +286,7 @@ impl Default for Settings { video_player: "auto".to_string(), ffmpeg_path: String::new(), vlc_path: String::new(), + video_sound: true, check_updates: true, skipped_update: String::new(), last_template: String::new(), diff --git a/src/ui_panels.rs b/src/ui_panels.rs index 6b8ab61..2ea4541 100644 --- a/src/ui_panels.rs +++ b/src/ui_panels.rs @@ -308,7 +308,6 @@ impl App { engine_combo(ui, &mut self.st.engine); }); ui.checkbox(&mut self.st.auto_compile, "Rebuild when the source changes"); - ui.checkbox(&mut self.st.live_edit, "Live editing: save and rebuild as you type"); }); // Tools > Check required packages opens this section. let force = std::mem::take(&mut self.show_packages).then_some(true); diff --git a/src/ui_studio.rs b/src/ui_studio.rs index 7f0f24b..b4fef1a 100644 --- a/src/ui_studio.rs +++ b/src/ui_studio.rs @@ -107,7 +107,6 @@ impl App { if labelled_button(ui, Icon::Check, "Check packages", false).clicked() { self.run(Action::CheckPackages, &ctx); } - ui.checkbox(&mut self.st.live_edit, "Live").on_hover_text("Save and rebuild shortly after you stop typing"); ui.checkbox(&mut self.st.auto_compile, "Rebuild on save"); ui.checkbox(&mut self.follow_cursor, "Follow cursor").on_hover_text("Show the slide for the line you are on"); if ui.checkbox(&mut self.st.editor_wrap, "Wrap text").on_hover_text("Wrap long lines at the editor's width instead of scrolling sideways").changed() { @@ -362,6 +361,21 @@ impl App { if want_sync { self.sync_from_cursor(); } + self.keep_editor_focus(ui.ctx(), id); + } + + /// In the studio the keyboard stays with the editor. A click on a button, a checkbox or the slide + /// used to leave it with nothing, so the next letters ran presenter shortcuts instead of typing: + /// B blacked out the slide and the arrows changed slides. Another text box keeps the keyboard while + /// it has it, and nothing is taken while a menu or list is open or the mouse button is held. + fn keep_editor_focus(&self, ctx: &egui::Context, id: egui::Id) { + if self.capture.is_some() || ctx.input(|i| i.pointer.any_down()) || egui::Popup::is_any_open(ctx) { + return; + } + match ctx.memory(|m| m.focused()) { + Some(f) if f == id || TextEdit::load_state(ctx, f).is_some() => {} + _ => ctx.memory_mut(|m| m.request_focus(id)), + } } fn preview_panel(&mut self, ui: &mut Ui) { diff --git a/src/ui_video.rs b/src/ui_video.rs index ccd2e62..083e65c 100644 --- a/src/ui_video.rs +++ b/src/ui_video.rs @@ -29,6 +29,33 @@ pub struct Shared { /// Seconds into the clip of the frame on show, and the clip's length. pub at: f64, pub duration: f64, + /// Whether the clip's sound plays too (it has sound, sound is on and ffplay is installed). + pub sound: bool, + /// How far the picture is from the sound, measured each time a frame goes on show. + pub sync: SyncStats, +} + +/// Picture minus sound, in milliseconds, over the frames shown while both played. Above zero the +/// picture is ahead of the sound (the sound is late). +#[derive(Default, Clone, Copy, Debug)] +pub struct SyncStats { + pub frames: u32, + pub sum_ms: f64, + pub worst_ms: f64, +} + +impl SyncStats { + pub fn add(&mut self, ms: f64) { + self.frames += 1; + self.sum_ms += ms; + if ms.abs() > self.worst_ms.abs() { + self.worst_ms = ms; + } + } + + pub fn mean_ms(&self) -> f64 { + if self.frames == 0 { 0.0 } else { self.sum_ms / self.frames as f64 } + } } pub struct Player { @@ -44,13 +71,13 @@ pub struct Player { } impl Player { - pub fn start(id: u64, frame_no: usize, gen: u64, path: PathBuf, name: String, repeat: bool, ctx: Context) -> Player { + pub fn start(id: u64, frame_no: usize, gen: u64, path: PathBuf, name: String, repeat: bool, mute: bool, ctx: Context) -> Player { let shared = Arc::new(Mutex::new(Shared::default())); let (tx, rx) = mpsc::channel(); let (s, p) = (shared.clone(), path.clone()); std::thread::Builder::new() .name("texora-video".into()) - .spawn(move || run(&p, &name, repeat, &s, &rx, &ctx)) + .spawn(move || run(&p, &name, repeat, mute, &s, &rx, &ctx)) .ok(); Player { id, frame_no, gen, path, shared, tx, rgba: None } } @@ -75,8 +102,9 @@ impl Drop for Player { } } -/// The player's thread: waits while paused, and while playing shows each frame at its time. -fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, rx: &mpsc::Receiver, ctx: &Context) { +/// The player's thread: waits while paused, and while playing shows each frame at its time. The clip's +/// sound (through ffplay) starts, stops and starts again with the picture, from the same place. +fn run(path: &std::path::Path, name: &str, repeat: bool, mute: bool, shared: &Mutex, rx: &mpsc::Receiver, ctx: &Context) { let set = |f: &dyn Fn(&mut Shared)| { if let Ok(mut s) = shared.lock() { f(&mut s); @@ -93,11 +121,17 @@ fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, }; let duration = stream.info().duration; set(&|s| s.duration = duration); + let mut sound = video::SoundPlayer::for_clip(path, stream.info(), mute); + let has_sound = sound.is_some(); + set(&|s| s.sound = has_sound); let (mut playing, mut ended) = (false, false); let mut held: Option = None; let mut waiting: Option = None; - // The clip time `base` was on show at the instant `origin`. + // Without sound, the clip time `base` was on show at the instant `origin`. With sound, the picture + // follows the sound's own clock instead, which ffplay reports; `started` is when the sound was + // asked to start, and `no_clock` is set when ffplay never reported a time. let (mut origin, mut base, mut last) = (Instant::now(), 0.0f64, 0.0f64); + let (mut started, mut no_clock, mut dropped) = (Instant::now(), false, 0u32); loop { let cmd = match waiting.take() { Some(c) => Some(c), @@ -111,6 +145,9 @@ fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, Some(Cmd::Stop) => return, Some(Cmd::Pause) => { playing = false; + if let Some(s) = sound.as_mut() { + s.stop(); + } set(&|s| s.playing = false); continue; } @@ -120,7 +157,10 @@ fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, (held, last, ended) = (None, 0.0, false); } playing = true; - (origin, base) = (Instant::now(), last); + (origin, base, started, no_clock) = (Instant::now(), last, Instant::now(), false); + if let Some(s) = sound.as_mut() { + s.play_from(base); + } set(&|s| (s.playing, s.ended) = (true, false)); } None => {} @@ -131,17 +171,44 @@ fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, let Some(f) = held.take().or_else(|| stream.next_frame()) else { if repeat && last > 0.0 { stream.seek(0.0); - (origin, base, last) = (Instant::now(), 0.0, 0.0); + (origin, base, last, started, no_clock) = (Instant::now(), 0.0, 0.0, Instant::now(), false); + if let Some(s) = sound.as_mut() { + s.play_from(0.0); + } continue; } + if let Some(s) = sound.as_mut() { + s.stop(); + } (playing, ended) = (false, true); set(&|s| (s.playing, s.ended) = (false, true)); continue; }; let now = Instant::now(); - let due = origin + Duration::from_secs_f64((f.at - base).max(0.0)); - if due > now { - match rx.recv_timeout(due - now) { + let heard = if no_clock { None } else { sound.as_ref().and_then(|s| s.clock()) }; + // Seconds until this frame is due: by the sound when it plays, otherwise by the computer's clock. + let ahead = match heard { + Some(h) => f.at - h, + None if sound.is_some() && !no_clock => { + if started.elapsed() < Duration::from_secs(2) { + // ffplay takes a moment to start; the picture waits for the sound rather than run ahead. + match rx.recv_timeout(Duration::from_millis(5)) { + Ok(c) => waiting = Some(c), + Err(mpsc::RecvTimeoutError::Disconnected) => return, + Err(mpsc::RecvTimeoutError::Timeout) => {} + } + held = Some(f); + continue; + } + // No report from ffplay: the picture keeps its own time from here. + no_clock = true; + (origin, base) = (now, f.at); + 0.0 + } + None => (f.at - base) - now.duration_since(origin).as_secs_f64(), + }; + if ahead > 0.0 { + match rx.recv_timeout(Duration::from_secs_f64(ahead)) { Ok(c) => { // Answer at once; this frame waits for its turn. held = Some(f); @@ -151,12 +218,22 @@ fn run(path: &std::path::Path, name: &str, repeat: bool, shared: &Mutex, Err(mpsc::RecvTimeoutError::Disconnected) => return, Err(mpsc::RecvTimeoutError::Timeout) => {} } - } else if now - due > Duration::from_millis(400) { + } else if heard.is_some() && ahead < -0.05 && dropped < 5 { + // Behind the sound: skip this frame to catch up (but still show one now and then). + dropped += 1; + last = f.at; + continue; + } else if heard.is_none() && ahead < -0.4 { // Far behind (the computer was busy): carry on from here rather than race. (origin, base) = (now, f.at); } + dropped = 0; last = f.at; + let heard = if no_clock { None } else { sound.as_ref().and_then(|s| s.clock()) }; if let Ok(mut s) = shared.lock() { + if let Some(h) = heard { + s.sync.add((f.at - h) * 1000.0); + } s.at = f.at; s.frame = Some(f); s.seq += 1; @@ -303,7 +380,7 @@ impl App { fn start_player(&mut self, ctx: &Context, frame_no: usize, v: &PageVideo) -> Option { let file = v.file.clone()?; self.player_seq += 1; - self.players.push(Player::start(self.player_seq, frame_no, self.gen, file, v.link.path.clone(), v.link.repeat, ctx.clone())); + self.players.push(Player::start(self.player_seq, frame_no, self.gen, file, v.link.path.clone(), v.link.repeat, v.link.mute, ctx.clone())); Some(self.players.len() - 1) } @@ -320,7 +397,8 @@ impl App { self.status = if self.is_screenshot() { format!("Would play {} in VLC.", v.link.path) } else { - match video::open_in_vlc(&vlc, file, v.link.repeat) { + let silent = v.link.mute || !video::tools().sound; + match video::open_in_vlc(&vlc, file, v.link.repeat, silent) { Ok(()) => format!("{} is playing in VLC.", v.link.path), Err(e) => format!("VLC could not be started: {e}"), } @@ -430,13 +508,26 @@ impl App { video::Backend::None => video::NEEDS_PLAYER.to_string(), }; ui.label(RichText::new(using).size(12.5).color(LEAF_DARK)); + ui.add_space(4.0); + if ui.checkbox(&mut self.st.video_sound, "Play sound").on_hover_text("Videos play their sound too. A clip with the mute option stays silent.").changed() { + changed = true; + } + let vlc = matches!(video::backend(), video::Backend::Vlc(_)); + let sound_note = match (&found.ffplay, self.st.video_sound) { + (_, false) => "Videos play without sound.".to_string(), + // VLC plays both the picture and the sound in its own window; ffplay is not needed. + (_, true) if vlc => "Sound plays in VLC, with the picture, in VLC's own window.".to_string(), + (Some(p), true) => format!("Sound plays through ffplay ({}), which comes with ffmpeg.", p.display()), + (None, true) => "No sound inside the slide: ffplay, which comes with ffmpeg, was not found. Install ffmpeg, or choose VLC, which plays sound in its own window.".to_string(), + }; + ui.label(RichText::new(sound_note).size(12.5).color(MUTED)); if matches!(video::backend(), video::Backend::None) || found.ffmpeg.is_none() { if let Some(said) = install_buttons(ui) { self.status = said; } } if changed { - video::configure(&self.st.video_player, &self.st.ffmpeg_path, &self.st.vlc_path); + video::configure(&self.st.video_player, &self.st.ffmpeg_path, &self.st.vlc_path, self.st.video_sound); self.save_layout(); } } diff --git a/src/video.rs b/src/video.rs index d583d89..83a0570 100644 --- a/src/video.rs +++ b/src/video.rs @@ -63,6 +63,8 @@ pub struct Info { pub height: u32, /// Seconds; 0 when unknown (a GIF before it has been played through). pub duration: f64, + /// Whether the clip has a sound track (a GIF never has). + pub has_audio: bool, } /// One picture, RGBA. @@ -150,12 +152,16 @@ pub struct Tools { pub choice: Choice, pub ffmpeg: Option, pub vlc: Option, + /// ffplay, which comes with ffmpeg, plays a clip's sound beside the picture ffmpeg gives. + pub ffplay: Option, + /// Settings > Video > Play sound. + pub sound: bool, } static TOOLS: RwLock> = RwLock::new(None); /// Takes the Settings: the choice, and the paths typed in (empty means "find it"). -pub fn configure(choice: &str, ffmpeg_path: &str, vlc_path: &str) { +pub fn configure(choice: &str, ffmpeg_path: &str, vlc_path: &str, sound: bool) { let pick = |typed: &str, find: fn() -> Option| { let t = typed.trim(); if t.is_empty() { @@ -164,7 +170,9 @@ pub fn configure(choice: &str, ffmpeg_path: &str, vlc_path: &str) { Some(PathBuf::from(t)).filter(|p| p.is_file()) } }; - let t = Tools { choice: Choice::from_setting(choice), ffmpeg: pick(ffmpeg_path, find_ffmpeg), vlc: pick(vlc_path, find_vlc) }; + let ffmpeg = pick(ffmpeg_path, find_ffmpeg); + let ffplay = find_ffplay(ffmpeg.as_deref()); + let t = Tools { choice: Choice::from_setting(choice), ffmpeg, vlc: pick(vlc_path, find_vlc), ffplay, sound }; if let Ok(mut g) = TOOLS.write() { *g = Some(t); } @@ -174,7 +182,7 @@ pub fn tools() -> Tools { if let Some(t) = TOOLS.read().ok().and_then(|g| g.clone()) { return t; } - configure("auto", "", ""); + configure("auto", "", "", true); TOOLS.read().ok().and_then(|g| g.clone()).unwrap_or_default() } @@ -217,6 +225,14 @@ pub fn find_ffmpeg() -> Option { search_dirs().into_iter().map(|d| d.join(&name)).find(|p| p.is_file()) } +/// ffplay, which comes with ffmpeg: beside the ffmpeg in use first (the same install), then the usual +/// places. +pub fn find_ffplay(ffmpeg: Option<&Path>) -> Option { + let name = exe("ffplay"); + let beside = ffmpeg.and_then(|f| f.parent()).map(|d| d.join(&name)).filter(|p| p.is_file()); + beside.or_else(|| search_dirs().into_iter().map(|d| d.join(&name)).find(|p| p.is_file())) +} + /// VLC installed on this computer, if any. pub fn find_vlc() -> Option { let mut places: Vec = vec![]; @@ -338,7 +354,9 @@ pub fn ffmpeg_input_args(path: &Path, start: Option) -> Result, } /// The arguments that open a clip in VLC: its full path, after `--` so it is never read as an option. -pub fn vlc_args(path: &Path, repeat: bool) -> Result, String> { +/// `silent`: the clip's `mute` option, or Settings > Video > Play sound off. VLC plays the sound +/// itself, so without ffmpeg (and ffplay) a clip opened in VLC is still heard. +pub fn vlc_args(path: &Path, repeat: bool, silent: bool) -> Result, String> { if !path.is_absolute() { return Err("TeXora only passes full paths to VLC.".into()); } @@ -346,6 +364,9 @@ pub fn vlc_args(path: &Path, repeat: bool) -> Result, String> { if repeat { a.push("--loop".into()); } + if silent { + a.push("--no-audio".into()); + } a.push("--".into()); a.push(plain(path)); Ok(a) @@ -353,12 +374,12 @@ pub fn vlc_args(path: &Path, repeat: bool) -> Result, String> { /// Opens a clip in VLC's own window. No shell is involved. Only a real video file is handed over (see /// `video_magic`): VLC would also play a playlist, which can point anywhere. -pub fn open_in_vlc(vlc: &Path, path: &Path, repeat: bool) -> Result<(), String> { +pub fn open_in_vlc(vlc: &Path, path: &Path, repeat: bool, silent: bool) -> Result<(), String> { if !head(path).is_ok_and(|h| video_magic(&h)) { return Err("it is not a video file VLC may open.".into()); } let mut c = tool_command(vlc); - c.args(vlc_args(path, repeat)?).stdout(Stdio::null()).stderr(Stdio::null()); + c.args(vlc_args(path, repeat, silent)?).stdout(Stdio::null()).stderr(Stdio::null()); c.spawn().map(|_| ()).map_err(|e| e.to_string()) } @@ -454,6 +475,7 @@ pub struct Probe { pub height: u32, pub fps: f64, pub duration: f64, + pub has_audio: bool, } /// Reads what `ffmpeg -i ` writes about a file. None when it has no video stream. @@ -487,7 +509,8 @@ pub fn parse_probe(text: &str) -> Option { // ffmpeg turns a phone video upright as it decodes it, so its size is then the other way round. let turned = text.lines().any(|l| l.contains("rotation of") && (l.contains("90.00") || l.contains("270.00"))); let (width, height) = if turned { (size.1, size.0) } else { size }; - Some(Probe { width, height, fps, duration: duration.unwrap_or(0.0) }) + let has_audio = text.lines().any(|l| l.contains("Stream #") && l.contains("Audio:")); + Some(Probe { width, height, fps, duration: duration.unwrap_or(0.0), has_audio }) } /// Asks ffmpeg what a file holds. @@ -522,7 +545,7 @@ impl FfmpegStream { pub fn open(ffmpeg: &Path, path: &Path, from: f64) -> Result { let p = probe(ffmpeg, path)?; let size = read_size(p.width, p.height); - let info = Info { kind: Kind::External, width: size.0, height: size.1, duration: p.duration }; + let info = Info { kind: Kind::External, width: size.0, height: size.1, duration: p.duration, has_audio: p.has_audio }; let mut s = FfmpegStream { info, ffmpeg: ffmpeg.to_path_buf(), path: path.to_path_buf(), fps: p.fps, size, child: None, start: 0.0, n: 0 }; s.start_at(from)?; Ok(s) @@ -580,6 +603,144 @@ impl Stream for FfmpegStream { } } +// ---------- sound ---------- + +/// The arguments that play a clip's sound with ffplay from `start` seconds: no window (`-nodisp`), no +/// picture or subtitles, and the same safety as for ffmpeg: local files only, real video formats only, +/// the file as `file:`. ffplay ends by itself at the end of the sound (`-autoexit`). +pub fn ffplay_args(path: &Path, start: f64) -> Result, Problem> { + if !path.is_absolute() { + return Err(Problem::Refused("TeXora only passes full paths to ffplay.".into())); + } + // -stats: ffplay reports where the sound is, which the picture follows. + let mut a: Vec = ["-hide_banner", "-loglevel", "error", "-stats", "-nodisp", "-autoexit", "-vn", "-sn", "-protocol_whitelist", "file", "-format_whitelist", FFMPEG_FORMATS].iter().map(|s| s.to_string()).collect(); + a.push("-ss".into()); + a.push(format!("{:.3}", start.max(0.0))); + // -ss alone lands on the picture's key frame before `start`, seconds early; the trim drops the + // sound before `start`, so it starts exactly where the picture does. + if start > 0.0 { + a.push("-af".into()); + a.push(format!("atrim=start={start:.3}")); + } + a.push("-i".into()); + a.push(ffmpeg_input(path)); + Ok(a) +} + +/// Plays a clip's sound beside its picture, through ffplay (which comes with ffmpeg). TeXora decodes +/// no sound itself: ffplay is a separate program from the person's own ffmpeg install. It is started +/// when the clip plays, from the clip's position, and ended on pause, at the end and when the slide +/// changes, so the sound always follows the picture. +pub struct SoundPlayer { + ffplay: PathBuf, + path: PathBuf, + child: Option, + /// The sound's own clock, read from what ffplay reports while it plays: a new one for each start, + /// so a stopped ffplay can never move the clock of the next. + clock: std::sync::Arc>, +} + +/// Where the sound is, as ffplay reports it about every 30 ms (the time heard now, its output delay +/// taken into account). Between reports it is carried on with the computer's clock; each report +/// nudges the estimate, so the 10 ms rounding of the reports evens out. +#[derive(Default)] +pub struct SoundClock { + /// Clip seconds minus `since` seconds, once ffplay has reported a time. + offset: Option, + since: Option, +} + +impl SoundClock { + pub fn report(&mut self, clip: f64, now: Instant) { + let since = *self.since.get_or_insert(now); + let off = clip - now.duration_since(since).as_secs_f64(); + self.offset = Some(match self.offset { + // A jump (a new start, or the sound held up) is taken at once; small differences are evened out. + Some(o) if (off - o).abs() < 0.05 => o + (off - o) * 0.2, + _ => off, + }); + } + + pub fn at(&self, now: Instant) -> Option { + Some(self.offset? + now.duration_since(self.since?).as_secs_f64()) + } +} + +/// The sound time in one line of ffplay's report (" 12.34 M-A: ..."), when it has one yet. +pub fn parse_ffplay_clock(line: &str) -> Option { + let (t, rest) = line.trim_start().split_once(char::is_whitespace)?; + if !rest.trim_start().starts_with("M-A") { + return None; + } + t.parse::().ok().filter(|v| v.is_finite()) +} + +impl SoundPlayer { + /// A sound player for a clip, when it has a sound track, sound is on and ffplay is installed. + pub fn for_clip(path: &Path, info: &Info, mute: bool) -> Option { + let t = tools(); + if mute || !t.sound || !info.has_audio || info.kind != Kind::External { + return None; + } + Some(SoundPlayer { ffplay: t.ffplay?, path: path.to_path_buf(), child: None, clock: Default::default() }) + } + + /// Plays from `seconds` into the clip, ending any sound already playing. + pub fn play_from(&mut self, seconds: f64) { + self.stop(); + let Ok(args) = ffplay_args(&self.path, seconds) else { return }; + let mut c = tool_command(&self.ffplay); + c.args(args).stdout(Stdio::null()).stderr(Stdio::piped()); + self.clock = Default::default(); + self.child = c.spawn().ok(); + // ffplay writes where the sound is to its error output, each report ending in a carriage return. + if let Some(err) = self.child.as_mut().and_then(|c| c.stderr.take()) { + let clock = self.clock.clone(); + let _ = std::thread::Builder::new().name("ffplay-clock".into()).spawn(move || { + let mut line = Vec::new(); + for b in BufReader::new(err).bytes() { + let Ok(b) = b else { break }; + if b == b'\r' || b == b'\n' { + if let Some(t) = parse_ffplay_clock(&String::from_utf8_lossy(&line)) { + if let Ok(mut c) = clock.lock() { + c.report(t, Instant::now()); + } + } + line.clear(); + } else if line.len() < 200 { + line.push(b); + } + } + }); + } + } + + /// Seconds into the clip of the sound heard now, once ffplay has started playing it. + pub fn clock(&self) -> Option { + self.clock.lock().ok()?.at(Instant::now()) + } + + pub fn stop(&mut self) { + if let Some(mut c) = self.child.take() { + let _ = c.kill(); + let _ = c.wait(); + } + } + + /// Whether ffplay is playing now (it ends by itself at the end of the sound). + #[cfg(test)] + pub fn playing(&mut self) -> bool { + self.child.as_mut().is_some_and(|c| matches!(c.try_wait(), Ok(None))) + } +} + +impl Drop for SoundPlayer { + /// The sound goes with the clip: another slide ends it. + fn drop(&mut self) { + self.stop(); + } +} + // ---------- GIF ---------- pub struct GifStream { @@ -593,7 +754,7 @@ pub struct GifStream { impl GifStream { pub fn open(path: &Path) -> Result { - let mut s = GifStream { info: Info { kind: Kind::Gif, width: 0, height: 0, duration: 0.0 }, path: path.to_path_buf(), frames: None, at: 0.0, pending: None }; + let mut s = GifStream { info: Info { kind: Kind::Gif, width: 0, height: 0, duration: 0.0, has_audio: false }, path: path.to_path_buf(), frames: None, at: 0.0, pending: None }; s.restart()?; Ok(s) } @@ -705,7 +866,9 @@ mod tests { #[test] fn ffmpeg_output_is_read() { let text = "Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/x/test.mp4':\n Duration: 00:00:04.00, start: 0.000000, bitrate: 941 kb/s\n Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 937 kb/s, 30 fps, 30 tbr, 15360 tbn (default)\n"; - assert_eq!(parse_probe(text), Some(Probe { width: 640, height: 360, fps: 30.0, duration: 4.0 })); + assert_eq!(parse_probe(text), Some(Probe { width: 640, height: 360, fps: 30.0, duration: 4.0, has_audio: false })); + let with_sound = format!("{text} Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 124 kb/s (default)\n"); + assert!(parse_probe(&with_sound).unwrap().has_audio); let phone = " Duration: 00:01:02.50, start: 0.000000\n Stream #0:0: Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709), 1920x1080, 29.97 fps, 29.97 tbr\n displaymatrix: rotation of -90.00 degrees\n"; let p = parse_probe(phone).unwrap(); assert_eq!((p.width, p.height, p.duration), (1080, 1920, 62.5)); @@ -734,10 +897,100 @@ mod tests { assert!(ffmpeg_input_args(Path::new("clip.mp4"), None).is_err(), "only full paths"); // VLC: the full path after "--", so a name starting with "-" is never an option. let named = talk.join("--extraintf=http.mp4"); - let v = vlc_args(&named, true).unwrap(); + let v = vlc_args(&named, true, false).unwrap(); assert_eq!(v, vec!["--play-and-exit".to_string(), "--loop".to_string(), "--".to_string(), plain(&named)]); assert!(!v[3].starts_with('-'), "a full path never starts with '-'"); - assert!(vlc_args(Path::new("--extraintf=http.mp4"), false).is_err(), "only full paths"); + assert!(vlc_args(Path::new("--extraintf=http.mp4"), false, false).is_err(), "only full paths"); + // VLC plays the sound itself; a muted clip, or sound turned off, gets none. + let quiet = vlc_args(&named, false, true).unwrap(); + assert_eq!(quiet, vec!["--play-and-exit".to_string(), "--no-audio".to_string(), "--".to_string(), plain(&named)]); + } + + #[test] + fn ffplay_arguments_are_safe() { + let clip = std::env::temp_dir().join("talk").join("-x clip.mp4"); + let a = ffplay_args(&clip, 1.5).unwrap(); + let at = |s: &str| a.iter().position(|x| x == s).unwrap(); + for o in ["-nodisp", "-autoexit", "-vn"] { + assert!(a.contains(&o.to_string()), "{o}"); + } + assert_eq!(a[at("-protocol_whitelist") + 1], "file"); + assert_eq!(a[at("-format_whitelist") + 1], FFMPEG_FORMATS); + assert_eq!(a[at("-ss") + 1], "1.500"); + assert_eq!(a.last().unwrap(), &format!("file:{}", plain(&clip))); + assert!(ffplay_args(Path::new("clip.mp4"), 0.0).is_err(), "only full paths"); + } + + /// With the real ffplay: the sound starts with the clip, from where it is, and stops on pause. + #[test] + fn sound_plays_and_stops_with_the_clip() { + let (Some(ff), Some(_)) = (find_ffmpeg(), find_ffplay(find_ffmpeg().as_deref())) else { return }; + let s = FfmpegStream::open(&ff, &clip("test.mp4"), 0.0).unwrap(); + assert!(s.info().has_audio, "the test clip has a 440 Hz tone"); + if !tools().sound { + return; + } + assert!(SoundPlayer::for_clip(&clip("test.mp4"), s.info(), true).is_none(), "mute: no sound"); + let mut gif = GifStream::open(&clip("test.gif")).unwrap(); + gif.next_frame(); + assert!(SoundPlayer::for_clip(&clip("test.gif"), gif.info(), false).is_none(), "a GIF has no sound"); + let mut p = SoundPlayer::for_clip(&clip("test.mp4"), s.info(), false).expect("sound"); + let asked = Instant::now(); + p.play_from(1.0); + std::thread::sleep(Duration::from_millis(600)); + assert!(p.playing(), "ffplay plays the sound"); + // ffplay reports where the sound is, starting from exactly where it was asked to. A busy + // computer can take a while to start it, so the first report is waited for. + while p.clock().is_none() && asked.elapsed() < Duration::from_secs(3) { + std::thread::sleep(Duration::from_millis(20)); + } + let heard = p.clock().expect("ffplay reports its sound clock"); + let most = 1.05 + asked.elapsed().as_secs_f64(); + assert!((0.95..most).contains(&heard), "sound clock {heard} after starting at 1.0"); + p.stop(); + assert!(!p.playing(), "and stops on pause"); + // Played from near the end, it ends by itself with the clip. + p.play_from(3.8); + let start = Instant::now(); + while p.playing() && start.elapsed() < Duration::from_secs(6) { + std::thread::sleep(Duration::from_millis(100)); + } + assert!(!p.playing(), "ffplay ends at the end of the sound"); + } + + #[test] + fn the_sound_clock_is_read_from_ffplay() { + assert_eq!(parse_ffplay_clock(" 12.34 M-A: 0.000 fd= 0 aq= 16KB vq= 0KB sq= 0B "), Some(12.34)); + assert_eq!(parse_ffplay_clock(" -0.02 M-A: 0.000 fd= 0"), Some(-0.02)); + assert_eq!(parse_ffplay_clock(" nan M-A: nan fd= 0"), None, "no time before the sound starts"); + assert_eq!(parse_ffplay_clock(" nan : 0.000 fd= 0"), None); + assert_eq!(parse_ffplay_clock("[aac @ 0x1] error"), None); + // Reports rounded to 10 ms even out, and the clock runs on between them. + let t0 = Instant::now(); + let mut c = SoundClock::default(); + assert!(c.at(t0).is_none()); + for i in 0..40 { + let now = t0 + Duration::from_millis(30 * i); + let exact = 5.0 + 0.030 * i as f64; + c.report((exact * 100.0).round() / 100.0, now); + } + let later = t0 + Duration::from_millis(30 * 39 + 15); + let want = 5.0 + 0.030 * 39.0 + 0.015; + assert!((c.at(later).unwrap() - want).abs() < 0.006, "clock {} vs {want}", c.at(later).unwrap()); + // A jump (a new place in the clip) is taken at once. + c.report(9.0, later); + assert!((c.at(later).unwrap() - 9.0).abs() < 1e-6); + } + + #[test] + fn the_sound_starts_exactly_where_the_picture_does() { + let clip = std::path::PathBuf::from(plain(&std::env::temp_dir().join("clip.mp4"))); + let a = ffplay_args(&clip, 20.0).unwrap(); + let at = a.iter().position(|x| x == "-af").expect("a trim after a seek"); + assert_eq!(a[at + 1], "atrim=start=20.000"); + assert!(at < a.iter().position(|x| x == "-i").unwrap(), "options come before the file"); + assert!(!ffplay_args(&clip, 0.0).unwrap().contains(&"-af".to_string()), "nothing to trim from the start"); + assert!(a.contains(&"-stats".to_string()), "ffplay reports its clock"); } #[test] @@ -750,7 +1003,7 @@ mod tests { assert!(video_magic(&head(&clip("test.mp4")).unwrap())); assert!(video_magic(&head(&clip("hevc.mp4")).unwrap())); assert!(!video_magic(&head(&clip("test.txt")).unwrap())); - assert!(open_in_vlc(Path::new("/nonexistent/vlc"), &hls, false).unwrap_err().contains("not a video")); + assert!(open_in_vlc(Path::new("/nonexistent/vlc"), &hls, false, false).unwrap_err().contains("not a video")); } /// With the real ffmpeg: files that are really a concat list or an HLS playlist, named `.mp4`, are diff --git a/src/video_prep.rs b/src/video_prep.rs index 9d3d154..20ff1a7 100644 --- a/src/video_prep.rs +++ b/src/video_prep.rs @@ -638,7 +638,7 @@ mod tests { let odd = resolve(&dir, "--ffmpeg=%2Fbin%2Fsh").unwrap(); let input = video::ffmpeg_input_args(&odd, None).unwrap().last().unwrap().clone(); assert!(input.starts_with("file:") && !input.starts_with("file:-") && input.ends_with("--ffmpeg=%2Fbin%2Fsh"), "{input}"); - let v = video::vlc_args(&odd, false).unwrap(); + let v = video::vlc_args(&odd, false, false).unwrap(); assert_eq!(v[1], "--"); assert!(!v[2].starts_with('-') && v[2].ends_with("--ffmpeg=%2Fbin%2Fsh"), "{}", v[2]); }