PAM Native Media
Start here
Section titled “Start here”Every PAM Native product runs on the PAM runtime. Install and verify PAM first, create a Native application, and add this package through PAM Composer:
curl -fsSL https://github.com/push-in/pam/releases/latest/download/install.sh | shpam doctorpam init my-app --template nativecd my-apppam composer require pushinbr/pam-native-mediapam doctorpam native devpushinbr/pam-native-media 0.5 works on files in the PAM sandbox
(FileReference::$path) and never loads media bytes into PHP. Android uses
Media3 Transformer 1.10.1, CameraX 1.6.1 and ExifInterface; iOS uses
AVFoundation and ImageIO with the same presets and geometry. Requires PAM
Native >=1.0.35 <2.0.0.
use Pam\Native\Media\{ImageFormat, ImageResult, Media, ResizeMode, Thumbnail, TranscodeResult, VideoPreset};
// Upload-ready MP4: H.264 Main / AAC-LC, bounded size, 2 s keyframes, fast start.$task = Media::transcode('captures/clip.mov') ->to('outbox/clip.mp4') ->preset(VideoPreset::Chat720p) ->progress(fn (float $p) => $this->encoding = $p) ->run(fn (TranscodeResult $video) => $this->send($video->path), fn (string $error) => $this->fail($error));
// Zé Chat's outbox rule: EXIF-oriented, longest side ≤ 1920 px, never upscaled, WebP 82.Media::image($file->path) ->resize(1920, 1920, ResizeMode::Contain) ->onlyScaleDown() ->format(ImageFormat::Webp, 82) ->save('outbox/photo.webp', fn (ImageResult $r) => $this->attach($r->path, $r->width, $r->height));
Media::thumbnails([Thumbnail::make('captures/clip.mov', 'thumbs/clip.jpg')->size(320, 320)->at(1000)], fn (array $results) => null);VideoPreset: Compact480p, Chat720p, Chat1080p, Adaptive (1080p up
to 3 min, then 720p). Presets never upscale, keep orientation, tone-map HDR to
SDR and normalize audio. Background Transfer
can run the same transcoder inside a durable upload.
Embedded camera
Section titled “Embedded camera”use Pam\Native\Media\{CameraCapture, CameraEventKind, CameraFacing, CameraMode, CameraView};
return CameraView::make() ->facing(CameraFacing::Back) ->mode(CameraMode::Photo) ->captureRevision($photoRevision) // each bump takes one photo ->onEvent(fn (CameraEventKind $kind, ?CameraCapture $capture, string $message) => null) ->toElement();Each mode binds only the outputs it needs. Request camera (and microphone for
video) first. Android merges CAMERA and RECORD_AUDIO; iOS merges
NSCameraUsageDescription and NSMicrophoneUsageDescription.