Skip to content

Commit

Permalink
Add sound capture settings
Browse files Browse the repository at this point in the history
ref: #105
  • Loading branch information
dz0ny authored and phw committed Dec 11, 2021
1 parent b4957d1 commit 2c0bcd6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 5 deletions.
4 changes: 4 additions & 0 deletions data/com.uploadedlobster.peek.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
<default>true</default>
<summary>Whether to capture the mouse cursor</summary>
</key>
<key name="recording-capture-sound" type="b">
<default>true</default>
<summary>Whether to capture sound from default PULSE input device</summary>
</key>
<key name="persist-window-geometry" type="(iiii)">
<default>(-1,-1,500,300)</default>
<summary>Size and position of the last open main window</summary>
Expand Down
20 changes: 20 additions & 0 deletions src/recording/ffmpeg-screen-recorder.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ namespace Peek.Recording {
args.append_val ("ffmpeg");
// args.append_val ("-loglevel");
// args.append_val ("debug");

if (config.capture_sound) {
if (config.output_format == OutputFormat.MP4){
args.append_val ("-f");
args.append_val ("pulse");
args.append_val ("-i");
args.append_val ("default");
args.append_val ("-acodec");
args.append_val ("mp3");
}
if (config.output_format == OutputFormat.WEBM){
args.append_val ("-f");
args.append_val ("pulse");
args.append_val ("-i");
args.append_val ("default");
args.append_val ("-acodec");
args.append_val ("vorbis");
}
}

args.append_val ("-f");
args.append_val ("x11grab");
args.append_val ("-show_region");
Expand Down
17 changes: 12 additions & 5 deletions src/recording/gnome-shell-dbus-recorder.vala
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,18 @@ namespace Peek.Recording {
}

if (config.output_format == OutputFormat.WEBM) {
pipeline.append ("vp9enc min_quantizer=10 max_quantizer=50 cq_level=13 cpu-used=5 deadline=1000000 threads=%T ! ");
pipeline.append ("queue ! webmmux");
pipeline.append ("videoconvert ! queue ! videorate ! vp9enc min_quantizer=10 max_quantizer=50 cq_level=13 cpu-used=5 deadline=1000000 threads=%T ! queue ! ");
if (config.capture_sound) {
pipeline.append ("mux. pulsesrc ! queue ! audioconvert ! vorbisenc ! ");
}
pipeline.append ("queue ! mux. webmmux name=mux");
} else if (config.output_format == OutputFormat.MP4) {
pipeline.append ("x264enc speed-preset=fast threads=%T ! ");
pipeline.append ("video/x-h264, profile=baseline ! ");
pipeline.append ("queue ! mp4mux");
pipeline.append ("videoconvert ! queue ! videorate ! x264enc speed-preset=fast threads=%T ! ");
pipeline.append ("video/x-h264, profile=baseline ! queue !");
if (config.capture_sound) {
pipeline.append ("mux. pulsesrc ! queue ! audioconvert ! lamemp3enc ! ");
}
pipeline.append ("queue ! mux. mp4mux name=mux");
} else {
// We could use lossless x264 here, but x264enc is part of
// gstreamer1.0-plugins-ugly and not always available.
Expand All @@ -207,6 +213,7 @@ namespace Peek.Recording {
}

debug ("Using GStreamer pipeline %s", pipeline.str);
debug ("Debug with gst-launch-1.0 --gst-debug=3 ximagesrc %s ! filesink location=screencast", pipeline.str);
return pipeline.str;
}

Expand Down
1 change: 1 addition & 0 deletions src/recording/recording-config.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Peek.Recording {
public int framerate { get; set; default = DEFAULT_FRAMERATE; }
public int downsample { get; set; default = DEFAULT_DOWNSAMPLE; }
public bool capture_mouse { get; set; default = true; }
public bool capture_sound { get; set; default = true; }
public bool gifski_enabled { get; set; default = false; }
public int gifski_quality { get; set; default = DEFAULT_GIFSKI_QUALITY; }
}
Expand Down
7 changes: 7 additions & 0 deletions src/ui/preferences-dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ namespace Peek.Ui {
[GtkChild]
private Gtk.CheckButton recording_capture_mouse;

[GtkChild]
private Gtk.CheckButton recording_capture_sound;


public PreferencesDialog () {
Object ();
Expand Down Expand Up @@ -124,6 +127,10 @@ namespace Peek.Ui {
recording_capture_mouse, "active",
SettingsBindFlags.DEFAULT);

settings.bind ("recording-capture-sound",
recording_capture_sound, "active",
SettingsBindFlags.DEFAULT);

on_interface_open_file_manager_toggled (interface_open_file_manager);
on_gifski_toggled (recording_gifski_enabled);

Expand Down
15 changes: 15 additions & 0 deletions ui/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,21 @@ Author: Philipp Wolfer <[email protected]>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="recording_capture_sound">
<property name="label" translatable="yes">Capture sound from default PULSE device</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down

0 comments on commit 2c0bcd6

Please sign in to comment.