Skip to content

Let apps check export settings before exporting - #1133

Merged
jonoomph merged 4 commits into
developfrom
validate-export-options
Oct 21, 2026
Merged

jonoomph merged 4 commits into
developfrom
validate-export-options

Conversation

@jonoomph

@jonoomph jonoomph commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

This adds a few ways for apps to ask libopenshot what FFmpeg can export, so OpenShot can catch invalid export settings before an export starts, instead of failing partway in.

  • Describe encoders and formats: GetEncoderInfo(), GetFormatInfo(), GetEncoders(), and IsCodecSupportedByFormat() return JSON about what each encoder accepts (sample rates, channel layouts, pixel formats, quality modes, hardware, lossless, intra-only, image) and which codecs a format can hold.
  • List every export format: GetFormats() returns one entry per file extension the writer can export to, matching how the writer picks a format from the file name.
  • Test settings without writing a file: Test() is called instead of Open(), after the same options an export sets. It opens the encoders (including hardware encoders) and writes the header to memory, so the format and codecs reject exactly what a real export would. FFmpeg's own explanation is returned as JSON (i.e. "mp3: Exactly one MP3 audio stream is required") instead of printed.
  • Fix a crash: Close() no longer writes a trailer when the header failed, which crashed.

Builds against FFmpeg 4.x through 7.x, with version guards for older APIs.

Used by OpenShot/openshot-qt#6217.

Add static FFmpegWriter queries that report what an encoder accepts
(sample rates, channel layouts, pixel formats, quality options, and
whether it is lossless or hardware), describe output formats, list
encoders a format can hold, and check format/codec compatibility.
Formats are matched by file extension like the writer, then by name.
…failed header

FFmpegWriter::Test() opens the encoders (including hardware encoders) and
writes the header to memory, so the container rejects anything it would
reject during a real export. FFmpeg's messages are returned as JSON instead
of printed. Close() no longer writes a trailer when the header failed,
which crashed.
GetFormats() returns one entry per file extension that selects its format
(the way the writer picks one), with its default codecs. GetEncoderInfo()
also reports whether an encoder writes single image files.
@jonoomph

Copy link
Copy Markdown
Member Author

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.42169% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.16%. Comparing base (7976991) to head (dd00d37).

Files with missing lines Patch % Lines
src/FFmpegWriter.cpp 93.72% 18 Missing ⚠️
tests/FFmpegCapabilities.cpp 99.21% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1133      +/-   ##
===========================================
+ Coverage    73.91%   74.16%   +0.24%     
===========================================
  Files          275      275              
  Lines        36995    37407     +412     
===========================================
+ Hits         27344    27742     +398     
- Misses        9651     9665      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@jonoomph
jonoomph merged commit 2d80ac1 into develop Oct 21, 2026
20 checks passed
@jonoomph
jonoomph deleted the validate-export-options branch October 21, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant