Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ To build and install the Arch package:
| Space | Record / pause / resume; play / pause while editing |
| Enter or Ctrl+Enter | Stop the take and edit it |
| Esc | Confirm discarding the clip and start over |
| M | Mirror the picture |
| Q | Quit (asks first if the take is still recording or unsaved) |
| ? | Keyboard help |

The shutter button records and stops; the round button beside it pauses and resumes.
The shutter button records and stops; the round button beside it pauses and resumes. **Mirror** flips the picture so it moves like a mirror. A take keeps the choice it started with: it plays mirrored in the editor and saves mirrored, so what you save matches what you saw. Saving a mirrored take always re-encodes it.

While editing, the timeline shows your take as one or more clips, each framed with a handle at both ends. Whatever falls outside every clip is cut.

Expand All @@ -61,11 +62,11 @@ Handles catch on pause marks, neighbouring clips, and the playhead. Playback pla

## Storage and settings

Takes are recorded into the application's XDG data directory, normally `~/.local/share/omacom/monologue/recordings/`, one folder per take. Saving an unedited clip copies the original without re-encoding; an edited clip is re-encoded from its clips (H.264 CRF 18, AAC) into a hidden temporary file beside the destination, then renamed into place. Saving into Monologue's own recordings folder is refused.
Takes are recorded into the application's XDG data directory, normally `~/.local/share/omacom/monologue/recordings/`, one folder per take. Saving an unedited clip copies the original without re-encoding; an edited or mirrored clip is re-encoded from its clips (H.264 CRF 18, AAC) into a hidden temporary file beside the destination, then renamed into place. Saving into Monologue's own recordings folder is refused.

A take lives only as long as you're working on it: starting a new recording or quitting deletes it. If you haven't saved it since your last change, Monologue asks first, and offers to save. If Monologue is killed or crashes with a take open, the next launch reopens that take in the editor if it was last written less than an hour ago (its edits and pause marks are not kept); an older one is deleted. A take that can't be played back is deleted. Each take holds a lock while in use, so a second Monologue window never mistakes it for an interrupted one.

Device IDs and the last save directory live in the application's Qt settings, normally `~/.config/omacom/monologue.conf`. The theme is read from `~/.local/state/omarchy/current/theme/colors.toml`, as in Omacut. No Omarchy config is changed.
Device IDs, the mirror choice, and the last save directory live in the application's Qt settings, normally `~/.config/omacom/monologue.conf`. The theme is read from `~/.local/state/omarchy/current/theme/colors.toml`, as in Omacut. No Omarchy config is changed.

A disconnected source or encoder error stops the take and preserves its files. An unfinalized MP4 after a crash or power loss may not be playable. Maximum resolution is never silently reduced: if the device or encoder cannot sustain it, Monologue reports the problem.

Expand Down
1 change: 1 addition & 0 deletions src/EditBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Item {
x: Math.round(index * slot); width: Math.round((index + 1) * slot) - x; height: track.height
sourceSize.height: track.height
fillMode: Image.PreserveAspectCrop
mirror: backend.takeMirrored
asynchronous: true; cache: false
source: index < backend.thumbnails.ready ? "image://thumbs/" + backend.thumbnails.revision + "/" + index : ""
}
Expand Down
31 changes: 27 additions & 4 deletions src/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ ApplicationWindow {
Shortcut { sequence: "Z"; context: Qt.WindowShortcut; autoRepeat: false; enabled: win.editing; onActivated: editBar.toggleZoom() }
Shortcut { sequence: "Ctrl+Z"; context: Qt.WindowShortcut; enabled: win.editing && backend.canUndo; onActivated: backend.undo() }
Shortcut { sequences: ["Ctrl+Shift+Z", "Ctrl+Y"]; context: Qt.WindowShortcut; enabled: win.editing && backend.canRedo; onActivated: backend.redo() }
Shortcut { sequence: "M"; context: Qt.WindowShortcut; autoRepeat: false; enabled: !win.finished && !win.busy && !win.overlayOpen && !backend.takeActive && !cameraChoice.popup.visible && !microphoneChoice.popup.visible; onActivated: backend.mirrorPreview = !backend.mirrorPreview }
Shortcut { sequence: "Q"; context: Qt.WindowShortcut; autoRepeat: false; enabled: !win.overlayOpen; onActivated: win.closeSafely() }
Shortcut { sequence: "?"; context: Qt.WindowShortcut; enabled: !win.overlayOpen; onActivated: helpDialog.open() }

Expand All @@ -162,6 +163,7 @@ ApplicationWindow {
microphone: "M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z M5.5 11a6.5 6.5 0 0 0 13 0 M12 17.5V21",
chevron: "M6 9l6 6 6-6",
back: "M4 12a8 8 0 1 0 2.4-5.7 M4 4v4.5h4.5",
mirror: "M12 3v18 M9 7L4 17h5z M15 7l5 10h-5z",
play: "M8 4.5v15l12.5-7.5z",
pause: "M7 4.5h2a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z M15 4.5h2a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-13a1 1 0 0 1 1-1z"
})
Expand Down Expand Up @@ -195,7 +197,7 @@ ApplicationWindow {
font.pixelSize: 13; font.weight: Font.DemiBold
focusPolicy: Qt.TabFocus
implicitHeight: 42
readonly property color foreground: button.progress >= 0 ? win.textColor : button.primary ? win.accentForeground : button.flat && !button.hovered ? win.dimColor : win.textColor
readonly property color foreground: button.progress >= 0 ? win.textColor : button.primary ? win.accentForeground : button.checked ? win.accent : button.flat && !button.hovered ? win.dimColor : win.textColor
contentItem: Item {
implicitWidth: label.implicitWidth; implicitHeight: label.implicitHeight
Row {
Expand Down Expand Up @@ -330,9 +332,19 @@ ApplicationWindow {
Rectangle {
Layout.fillWidth: true; Layout.fillHeight: true; Layout.minimumHeight: 120
color: "black"; clip: true
VideoOutput { id: liveVideo; anchors.fill: parent; visible: !win.finished; fillMode: VideoOutput.PreserveAspectFit; focus: true }
// Mirroring flips the picture on screen; the recording keeps the camera's own orientation until it's saved.
VideoOutput {
id: liveVideo; objectName: "liveVideo"
anchors.fill: parent; visible: !win.finished; fillMode: VideoOutput.PreserveAspectFit; focus: true
transform: Scale { origin.x: liveVideo.width / 2; xScale: backend.mirrorPreview ? -1 : 1 }
}
// Hold the last frame at the end of the file rather than clearing to black.
VideoOutput { id: clipVideo; objectName: "clipVideo"; endOfStreamPolicy: VideoOutput.KeepLastFrame; anchors.fill: parent; visible: win.finished; fillMode: VideoOutput.PreserveAspectFit }
VideoOutput {
id: clipVideo; objectName: "clipVideo"; endOfStreamPolicy: VideoOutput.KeepLastFrame
anchors.fill: parent; visible: win.finished; fillMode: VideoOutput.PreserveAspectFit
// A take recorded mirrored plays mirrored, as it will be saved.
transform: Scale { origin.x: clipVideo.width / 2; xScale: backend.takeMirrored ? -1 : 1 }
}
MouseArea { anchors.fill: parent; onClicked: { liveVideo.forceActiveFocus(); if (win.finished) win.togglePlayback() } }
Column {
anchors.centerIn: parent; width: Math.min(400, parent.width-40); spacing: 16
Expand Down Expand Up @@ -487,6 +499,17 @@ ApplicationWindow {
RowLayout {
Layout.fillWidth: true; Layout.preferredWidth: 1; spacing: 8
Item { Layout.fillWidth: true }
ActionButton {
objectName: "mirrorButton"
visible: !win.finished; flat: true
iconPath: win.icons.mirror; text: "Mirror"
checked: backend.mirrorPreview
enabled: !win.busy && !backend.dialogOpen && !backend.takeActive
Accessible.name: "Mirror"
ToolTip.visible: hovered; ToolTip.text: (backend.mirrorPreview ? "Stop mirroring" : "Mirror") + " the picture (M). Takes save as you see them."
// Clicked, not toggled: ActionButton's Return/Enter handling emits clicked().
onClicked: { backend.mirrorPreview = !backend.mirrorPreview; liveVideo.forceActiveFocus() }
}
ActionButton {
objectName: "saveButton"
readonly property bool saving: backend.state === "saving"
Expand Down Expand Up @@ -598,7 +621,7 @@ ApplicationWindow {
spacing: 40
ShortcutList {
Layout.alignment: Qt.AlignTop; heading: "Recording"
rows: [["Space", "Record / pause / resume"], ["Enter", "Stop and edit"], ["Esc", "Discard and start over"], ["Q", "Quit"], ["?", "Show shortcuts"]]
rows: [["Space", "Record / pause / resume"], ["Enter", "Stop and edit"], ["Esc", "Discard and start over"], ["M", "Mirror the picture"], ["Q", "Quit"], ["?", "Show shortcuts"]]
}
ShortcutList {
Layout.alignment: Qt.AlignTop; heading: "Editing"
Expand Down
20 changes: 17 additions & 3 deletions src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Backend::Backend(FilePicker *picker, bool activateHardware, QObject *parent)
m_root = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/recordings";
m_cameraId=m_settings.value("camera/id").toString();
m_audioId=m_settings.value("microphone/id").toString();
m_mirrorPreview=m_settings.value("preview/mirror",false).toBool();
m_capture.setVideoSink(&m_sink);
connect(&m_sink,&QVideoSink::videoFrameChanged,this,&Backend::receiveVideo);
if(m_activateHardware) {
Expand All @@ -53,6 +54,13 @@ Backend::~Backend() {
releaseSources();
if(m_export) { m_export->disconnect(this); m_export->kill(); m_export->waitForFinished(); QFile::remove(m_exportPartial); }
}
void Backend::setMirrorPreview(bool mirror) {
// A take keeps the choice it started with; it decides how the take saves.
if(mirror==m_mirrorPreview || m_writer) return;
m_mirrorPreview=mirror;
m_settings.setValue("preview/mirror",mirror);
emit mirrorPreviewChanged();
}
int Backend::cameraIndex() const { return indexOf(m_cameras,m_cameraId); }
int Backend::microphoneIndex() const { return indexOf(m_microphones,m_audioId); }
bool Backend::ready() const { return m_state=="ready" && m_cameraHealthy && (!audioEnabled() || m_audioHealthy); }
Expand Down Expand Up @@ -250,6 +258,10 @@ void Backend::startTake() {
m_clipFileName="Monologue-"+QDateTime::currentDateTime().toString("yyyy-MM-dd-HHmmss")+".mp4";
m_clipPath=directory+"/"+m_clipFileName;
m_interruption.clear(); m_duration=0;
// Remembered beside the take, so a recovered take still saves the way it was framed.
m_takeMirrored=m_mirrorPreview;
// Without the marker the take still records and saves mirrored; only recovering it after a crash would not.
if(m_takeMirrored && !QFile(directory+"/.mirrored").open(QIODevice::WriteOnly)) qWarning("Could not mark the take as mirrored.");
readAudio();
m_writer=new Writer(this);
connect(m_writer,&Writer::finished,this,&Backend::writerFinished,Qt::QueuedConnection);
Expand Down Expand Up @@ -362,7 +374,8 @@ void Backend::writeTo(const QString &destination) {
if(!takes.isEmpty() && (folder==takes || folder.startsWith(takes+"/"))) {
m_message="Could not save: choose a folder outside Monologue's working files."; emit changed(); return;
}
if(edit::untouched(m_edit,m_duration)) copyTo(destination);
// A mirrored take is flipped on the way out, so it can't be copied as recorded.
if(edit::untouched(m_edit,m_duration) && !m_takeMirrored) copyTo(destination);
else exportTo(destination);
}
void Backend::copyTo(const QString &destination) {
Expand Down Expand Up @@ -412,7 +425,7 @@ void Backend::exportTo(const QString &destination) {
m_export->deleteLater(); m_export=nullptr;
saved(destination,"ffmpeg could not be started.");
});
m_export->start("ffmpeg",media::exportArgs(m_clipPath,m_exportPartial,edit::kept(m_edit),m_clipAudio));
m_export->start("ffmpeg",media::exportArgs(m_clipPath,m_exportPartial,edit::kept(m_edit),m_clipAudio,m_takeMirrored));
}
void Backend::saved(const QString &destination,const QString &error) {
if(!error.isEmpty() && !m_exportPartial.isEmpty()) QFile::remove(m_exportPartial);
Expand Down Expand Up @@ -517,7 +530,7 @@ void Backend::deleteTake() {
m_takeLock.reset();
QDir(m_root+"/"+m_takeId).removeRecursively();
}
m_takeId.clear(); m_clipPath.clear(); m_clipFileName.clear();
m_takeId.clear(); m_clipPath.clear(); m_clipFileName.clear(); m_takeMirrored=false;
resetEdit({},{}); m_thumbnails.clear();
}
void Backend::recoverTake() {
Expand All @@ -528,6 +541,7 @@ void Backend::recoverTake() {
for(const auto &name:QDir(entry.filePath()).entryList({"*.mp4"},QDir::Files))
if(!name.endsWith(".finalizing.mp4")) clip=name;
m_takeId=entry.fileName();
m_takeMirrored=QFile::exists(entry.filePath()+"/.mirrored");
// Only a recent take is worth reopening; anything older is just left over.
const QFileInfo file(entry.filePath()+"/"+clip);
if(clip.isEmpty() || file.lastModified().secsTo(QDateTime::currentDateTime())>=3600) { deleteTake(); continue; }
Expand Down
9 changes: 9 additions & 0 deletions src/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Backend : public QObject {
Q_PROPERTY(bool canRedo READ canRedo NOTIFY editChanged)
// The finished take has not been saved as it is now edited.
Q_PROPERTY(bool unsaved READ unsaved NOTIFY editChanged)
// Mirror the picture. New takes record this choice and are flipped when saved.
Q_PROPERTY(bool mirrorPreview READ mirrorPreview WRITE setMirrorPreview NOTIFY mirrorPreviewChanged)
// The take was recorded with a mirrored preview, so it plays and saves mirrored to match.
Q_PROPERTY(bool takeMirrored READ takeMirrored NOTIFY changed)
Q_PROPERTY(QObject *thumbnails READ thumbnails CONSTANT)
public:
explicit Backend(QObject *parent = nullptr);
Expand Down Expand Up @@ -74,6 +78,9 @@ class Backend : public QObject {
bool canUndo() const { return !m_undo.isEmpty(); }
bool canRedo() const { return !m_redo.isEmpty(); }
bool unsaved() const;
bool mirrorPreview() const { return m_mirrorPreview; }
void setMirrorPreview(bool mirror);
bool takeMirrored() const { return m_takeMirrored; }
Thumbnails *thumbnails() { return &m_thumbnails; }
edit::Clips currentEdit() const { return m_edit; }
Q_INVOKABLE void setPreview(QObject *sink);
Expand Down Expand Up @@ -104,6 +111,7 @@ class Backend : public QObject {
void devicesChanged();
void meterChanged();
void editChanged();
void mirrorPreviewChanged();
void safeToClose();
void overwriteRequested(const QString &path);
private:
Expand Down Expand Up @@ -170,5 +178,6 @@ class Backend : public QObject {
qint64 m_clipUntil = 0, m_peakUntil = 0, m_signalAt = 0;
double m_duration = 0, m_level = -60, m_peak = -60, m_pendingPeak = 0, m_fps = 30;
bool m_cameraHealthy = false, m_audioHealthy = false, m_dialogOpen = false;
bool m_mirrorPreview = false, m_takeMirrored = false;
bool m_hasSaved = false, m_discardAfter = false, m_restartAfter = false, m_probing = false;
};
5 changes: 3 additions & 2 deletions src/mediautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,16 @@ media::Probe media::probe(const QString &path) {
if (!result.ok) result.error = "The recording could not be finalized as a playable H.264 MP4.";
return result;
}
QStringList media::exportArgs(const QString &source, const QString &destination, const QList<edit::Range> &kept, bool audio) {
QStringList media::exportArgs(const QString &source, const QString &destination, const QList<edit::Range> &kept, bool audio, bool mirror) {
QStringList args{"-nostdin", "-v", "error", "-y", "-progress", "pipe:1", "-nostats"};
QString graph;
// One seeking input per kept range decodes only what survives the cut.
for (int i = 0; i < kept.size(); ++i) {
args << "-ss" << QString::number(kept[i].start, 'f', 3) << "-t" << QString::number(kept[i].length(), 'f', 3) << "-i" << source;
graph += QString("[%1:v:0]").arg(i) + (audio ? QString("[%1:a:0]").arg(i) : QString());
}
graph += QString("concat=n=%1:v=1:a=%2[v]").arg(kept.size()).arg(audio ? 1 : 0) + (audio ? "[a]" : "");
graph += QString("concat=n=%1:v=1:a=%2").arg(kept.size()).arg(audio ? 1 : 0) + (mirror ? "[joined]" : "[v]") + (audio ? "[a]" : "");
if (mirror) graph += ";[joined]hflip[v]";
args << "-filter_complex" << graph << "-map" << "[v]";
if (audio) args << "-map" << "[a]" << "-c:a" << "aac" << "-b:a" << "192k";
args << "-c:v" << "libx264" << "-preset" << "veryfast" << "-crf" << "18" << "-pix_fmt" << "yuv420p"
Expand Down
3 changes: 2 additions & 1 deletion src/mediautils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ QString normalizeMp4(const QString &path, double fps);
struct Probe { bool ok = false; QString error; QSize size; double duration = 0; bool audio = false; };
Probe probe(const QString &path);
// Re-encodes the kept ranges of a recording into one MP4, reporting progress on stdout.
QStringList exportArgs(const QString &source, const QString &destination, const QList<edit::Range> &kept, bool audio);
// mirror flips the picture horizontally, for takes recorded with a mirrored preview.
QStringList exportArgs(const QString &source, const QString &destination, const QList<edit::Range> &kept, bool audio, bool mirror = false);
QImage thumbnail(const QString &path, double time, int height, const std::atomic<bool> *cancel);
}
Loading