Skip to content

Refactor and enhance FFmpeg integration with tests and features - #54

Merged
phial3 merged 50 commits into
dromara:rsmpegfrom
phial3:dev
Aug 10, 2026
Merged

phial3 merged 50 commits into
dromara:rsmpegfrom
phial3:dev

Conversation

@phial3

@phial3 phial3 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

phial3 added 20 commits August 7, 2026 15:29
error[E0308]: mismatched types
  --> src\swctx.rs:97:9
   |
90 |     let sws_ctx = SwsContext::get_context(
   |                   ----------------------- arguments to this function are incorrect
97 |         flags,
   |         ^^^^^ expected `u32`, found `i32`
error[E0308]: mismatched types
expected `u32`, found `i32`
…void dual-FFmpeg heap corruption

The runner image may ship system FFmpeg dev libraries that, together with the
downloaded BtbN FFmpeg (different soname), get linked into the test binary. This
causes AVFrame allocated by one libavutil and freed by another, triggering heap
corruption (SIGABRT) in frame audio tests on ffmpeg 7.1/8.1.
- codec: replace pure println with real assertions (non-empty supported
  formats), deduplicate via helper functions
- pixel: assert best pix fmt belongs to candidates, loss non-negative,
  zero loss for same-format conversion
- colors: assert HSV output stays in valid ranges instead of printing
- frame: remove debug println output, assert AAC encoder exposes formats
…les/tests

- Accept impl Into<Option<T>> for with_codec_name/with_filters/with_options
- Have DecoderBuilder::build and Decoder::new_video/new_audio return
  DecoderWrapper<StreamReader> that owns the reader
- Make Encoder::encode return Result<()> and discard the produced packet
- Drop redundant Some() wrappers across examples, tests and README
Make MediaFrame.format private and add video_format()/audio_format()
accessors that return Option<PixelFormat>/Option<SampleFormat> based on
media_type, removing the ambiguous bare-i32 format field from the public
API. Update decoding example and README to print a readable format name.
…at panic

Add decode_raw, audio, seek, and metadata examples demonstrating the raw
frame path, audio encode/decode, seeking, and metadata getters. Fix
StreamReader/StreamWriter builders to skip the format hint when unset
(maybe_format) instead of panicking on unwrap, allowing FFmpeg to infer
the format. Rename test input file to /tmp/test.mp4 across examples,
tests, and README.
…d fix FFmpeg 8 sink options

- Add DrawText::time_text() for dynamic time watermark (%{localtime} etc.)
- Add video denoise/enhancement filters: hqdn3d, nlmeans, gamma, saturation, vibrance, deblock
- Add audio denoise convenience and common video filters (yadif, pad, subtitles, setdar/setsar, hue)
- Replace FilterFactory with top-level fifo/split/setpts/trim functions
- Make compressor return Result instead of panicking
- Fix FFmpeg 8 filter sink init by using alloc_filter_context + opt_set + init_str
- Add unit tests for filter spec generation and add filter_demo example
…ocess real video

- Add Delogo builder supporting multiple regions, band and show options
- Document delogo constraint that logo area must keep >= band margin from frame edge
- Rework filter_demo to decode a real video through a filter chain
  (scale/crop/delogo/hqdn3d/saturation) and save processed frames as PNG
- Add unit tests for delogo spec generation
…ld methods

- Add Decoder::decode_frame() and DecoderWrapper::decode_frame() returning
  MediaFrame<u8>, avoiding the verbose decode::<u8>() in the common path
- Document differences between build/build_wrapped/build_from_reader and
  clarify why seek is only available on DecoderWrapper
- Clarify that decoded video frames are always converted to YUV420P before
  filtering (source pix_fmt is handled, not a correctness bug)
- Update decoding/seek/filter_demo examples to use decode_frame()
…s, colormap

- Add colors::color_delta_e() (CIEDE2000 via palette) for perceptually uniform
  color difference, useful for quality assessment and watermark removal eval
- Add colors::colormap_lookup() and grayscale_to_colormap() (via colorous) for
  pseudo-color visualization of grayscale/heat/depth frames
- Add MediaFrame::convert_rgb_to_yuv_with_matrix() to explicitly select
  BT.601/BT.709/BT.2020 matrix; keep automatic resolution-based selection
- Extract shared RGB24 validation into private check_rgb24_supported()
- Add unit tests and a color_professional example (registered in Cargo.toml)
…h_fps

- Add EncoderWrapper::write_frame() that auto-maintains pts for both video
  (by frame rate) and audio (by sample count/sample rate), so callers no
  longer need to set_pts manually; encode() remains for full control
- Add EncoderBuilder::with_fps(f32) converting a float fps via av_d2q;
  keep the default time_base (TIME_BASE) to stay consistent with pkt_time_base
- Add EncoderBuilder::preset_h264_yuv420p() convenience preset
- Bump default FRAME_RATE to 30 and add FPS_MAX const for fps conversion
- Fix new_video doc params and Decoder::decode doc example
- Add quick_write example demonstrating writer-free encoding
- Add ScaleAlgorithm enum covering all 11 sws_flags algorithm bits
  (FastBilinear/Bilinear/Bicubic/Experimental/Point/Area/BicubicLinear/
  Gaussian/Sinc/Lanczos/Spline), defaulting to Bicubic
- Add swctx::scale_with_flags() and parameterize setup_scaler; keep
  scale()/scale_frame() default behavior unchanged
- Add DecoderBuilder::with_scale_algorithm() and export ScaleAlgorithm,
  applying the algorithm to the decoded native -> YUV420P conversion
@phial3
phial3 merged commit 72f1e01 into dromara:rsmpeg Aug 10, 2026
18 of 20 checks passed
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