Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,13 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FFMpegAVCodec : NSObject
+ (FFMpegAVCodec * _Nullable)findForId:(int)codecId preferHardwareAccelerationCapable:(bool)preferHardwareAccelerationCapable;
- (void *)impl;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,34 @@
#import <Foundation/Foundation.h>
#import <FFMpegBinding/FFMpegAVSampleFormat.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, FFMpegAVCodecContextReceiveResult)
{
FFMpegAVCodecContextReceiveResultError,
FFMpegAVCodecContextReceiveResultNotEnoughData,
FFMpegAVCodecContextReceiveResultSuccess,
};
@class FFMpegAVCodec;
@class FFMpegAVFrame;
@interface FFMpegAVCodecContext : NSObject
- (instancetype)initWithCodec:(FFMpegAVCodec *)codec;
- (void *)impl;
- (int32_t)channels;
- (int32_t)sampleRate;
- (FFMpegAVSampleFormat)sampleFormat;
- (bool)open;
- (bool)sendEnd;
- (void)setupHardwareAccelerationIfPossible;
- (FFMpegAVCodecContextReceiveResult)receiveIntoFrame:(FFMpegAVFrame *)frame;
- (void)flushBuffers;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,69 @@
#import <Foundation/Foundation.h>
#import <CoreMedia/CoreMedia.h>
NS_ASSUME_NONNULL_BEGIN
@class FFMpegAVIOContext;
@class FFMpegPacket;
typedef enum FFMpegAVFormatStreamType {
FFMpegAVFormatStreamTypeVideo,
FFMpegAVFormatStreamTypeAudio
} FFMpegAVFormatStreamType;
typedef struct FFMpegFpsAndTimebase {
CMTime fps;
CMTime timebase;
} FFMpegFpsAndTimebase;
typedef struct FFMpegStreamMetrics {
int32_t width;
int32_t height;
double rotationAngle;
uint8_t *extradata;
int32_t extradataSize;
} FFMpegStreamMetrics;
typedef struct FFMpegAVIndexEntry {
int64_t pos;
int64_t timestamp;
bool isKeyframe;
int32_t size;
} FFMpegAVIndexEntry;
extern int FFMpegCodecIdH264;
extern int FFMpegCodecIdHEVC;
extern int FFMpegCodecIdMPEG4;
extern int FFMpegCodecIdVP9;
extern int FFMpegCodecIdVP8;
extern int FFMpegCodecIdAV1;
@class FFMpegAVCodecContext;
@interface FFMpegAVFormatContext : NSObject
- (instancetype)init;
- (void)setIOContext:(FFMpegAVIOContext *)ioContext;
- (bool)openInputWithDirectFilePath:(NSString * _Nullable)directFilePath;
- (bool)findStreamInfo;
- (void)seekFrameForStreamIndex:(int32_t)streamIndex pts:(int64_t)pts positionOnKeyframe:(bool)positionOnKeyframe;
- (void)seekFrameForStreamIndex:(int32_t)streamIndex byteOffset:(int64_t)byteOffset;
- (bool)readFrameIntoPacket:(FFMpegPacket *)packet;
- (NSArray<NSNumber *> *)streamIndicesForType:(FFMpegAVFormatStreamType)type;
- (bool)isAttachedPicAtStreamIndex:(int32_t)streamIndex;
- (int)codecIdAtStreamIndex:(int32_t)streamIndex;
- (double)duration;
- (int64_t)startTimeAtStreamIndex:(int32_t)streamIndex;
- (int64_t)durationAtStreamIndex:(int32_t)streamIndex;
- (int)numberOfIndexEntriesAtStreamIndex:(int32_t)streamIndex;
- (bool)fillIndexEntryAtStreamIndex:(int32_t)streamIndex entryIndex:(int32_t)entryIndex outEntry:(FFMpegAVIndexEntry * _Nonnull)outEntry;
- (bool)codecParamsAtStreamIndex:(int32_t)streamIndex toContext:(FFMpegAVCodecContext *)context;
- (FFMpegFpsAndTimebase)fpsAndTimebaseForStreamIndex:(int32_t)streamIndex defaultTimeBase:(CMTime)defaultTimeBase;
- (FFMpegStreamMetrics)metricsForStreamAtIndex:(int32_t)streamIndex;
- (void)forceVideoCodecId:(int)videoCodecId;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,39 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, FFMpegAVFrameColorRange) {
FFMpegAVFrameColorRangeRestricted,
FFMpegAVFrameColorRangeFull
};
typedef NS_ENUM(NSUInteger, FFMpegAVFramePixelFormat) {
FFMpegAVFramePixelFormatYUV,
FFMpegAVFramePixelFormatYUVA
};
typedef NS_ENUM(NSUInteger, FFMpegAVFrameNativePixelFormat) {
FFMpegAVFrameNativePixelFormatUnknown,
FFMpegAVFrameNativePixelFormatVideoToolbox
};
@interface FFMpegAVFrame : NSObject
@property (nonatomic, readonly) int32_t width;
@property (nonatomic, readonly) int32_t height;
@property (nonatomic, readonly) uint8_t * _Nullable * _Nonnull data;
@property (nonatomic, readonly) int * _Nonnull lineSize;
@property (nonatomic, readonly) int64_t pts;
@property (nonatomic, readonly) int64_t duration;
@property (nonatomic, readonly) FFMpegAVFrameColorRange colorRange;
@property (nonatomic, readonly) FFMpegAVFramePixelFormat pixelFormat;
- (instancetype)init;
- (instancetype)initWithPixelFormat:(FFMpegAVFramePixelFormat)pixelFormat width:(int32_t)width height:(int32_t)height;
- (void *)impl;
- (FFMpegAVFrameNativePixelFormat)nativePixelFormat;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,17 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define FFMPEG_AVSEEK_SIZE 0x10000
extern int FFMPEG_CONSTANT_AVERROR_EOF;
@interface FFMpegAVIOContext : NSObject
- (instancetype _Nullable)initWithBufferSize:(int32_t)bufferSize opaqueContext:(void * const _Nullable)opaqueContext readPacket:(int (* _Nullable)(void * _Nullable opaque, uint8_t * _Nullable buf, int buf_size))readPacket writePacket:(int (* _Nullable)(void * _Nullable opaque, uint8_t const * _Nullable buf, int buf_size))writePacket seek:(int64_t (*)(void * _Nullable opaque, int64_t offset, int whence))seek isSeekable:(bool)isSeekable;
- (void *)impl;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
//
// FFMpegAVSampleFormat.h
// FFMpeg
//
// Created by Peter Iakovlev on 11/12/2018.
// Copyright © 2018 Telegram Messenger LLP. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef enum FFMpegAVSampleFormat {
FFMPEG_AV_SAMPLE_FMT_NONE = -1,
FFMPEG_AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
FFMPEG_AV_SAMPLE_FMT_S16, ///< signed 16 bits
FFMPEG_AV_SAMPLE_FMT_S32, ///< signed 32 bits
FFMPEG_AV_SAMPLE_FMT_FLT, ///< float
FFMPEG_AV_SAMPLE_FMT_DBL, ///< double
FFMPEG_AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar
FFMPEG_AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar
FFMPEG_AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar
FFMPEG_AV_SAMPLE_FMT_FLTP, ///< float, planar
FFMPEG_AV_SAMPLE_FMT_DBLP, ///< double, planar
FFMPEG_AV_SAMPLE_FMT_S64, ///< signed 64 bits
FFMPEG_AV_SAMPLE_FMT_S64P, ///< signed 64 bits, planar
FFMPEG_AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
} FFMpegAVSampleFormat;
NS_ASSUME_NONNULL_END
@@ -0,0 +1,14 @@
#import <Foundation/Foundation.h>
#import <FFMpegBinding/FFMpegGlobals.h>
#import <FFMpegBinding/FFMpegAVCodecContext.h>
#import <FFMpegBinding/FFMpegAVIOContext.h>
#import <FFMpegBinding/FFMpegAVFormatContext.h>
#import <FFMpegBinding/FFMpegAVSampleFormat.h>
#import <FFMpegBinding/FFMpegSWResample.h>
#import <FFMpegBinding/FFMpegAVFrame.h>
#import <FFMpegBinding/FFMpegPacket.h>
#import <FFMpegBinding/FFMpegAVCodec.h>
#import <FFMpegBinding/FFMpegRemuxer.h>
#import <FFMpegBinding/FFMpegLiveMuxer.h>
#import <FFMpegBinding/FrameConverter.h>
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FFMpegGlobals : NSObject
+ (void)initializeGlobals;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FFMpegLiveMuxer : NSObject
+ (bool)remux:(NSString * _Nonnull)path to:(NSString * _Nonnull)outPath offsetSeconds:(double)offsetSeconds;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,15 @@
#import <Foundation/Foundation.h>
#import <CoreVideo/CoreVideo.h>
NS_ASSUME_NONNULL_BEGIN
@interface FFMpegOpusTrimmer : NSObject
+ (bool)trim:(NSString * _Nonnull)path
to:(NSString * _Nonnull)outputPath
start:(double)start
end:(double)end;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class FFMpegAVCodecContext;
@interface FFMpegPacket : NSObject
@property (nonatomic, readonly) int64_t pts;
@property (nonatomic, readonly) int64_t dts;
@property (nonatomic, readonly) int64_t duration;
@property (nonatomic, readonly) int32_t streamIndex;
@property (nonatomic, readonly) int32_t size;
@property (nonatomic, readonly) uint8_t *data;
@property (nonatomic, readonly) bool isKeyframe;
- (void *)impl;
- (int32_t)sendToDecoder:(FFMpegAVCodecContext *)codecContext;
- (void)reuse;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface FFMpegRemuxer : NSObject
+ (bool)remux:(NSString * _Nonnull)path to:(NSString * _Nonnull)outPath;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>
#import <FFMpegBinding/FFMpegAVSampleFormat.h>
NS_ASSUME_NONNULL_BEGIN
@class FFMpegAVFrame;
@interface FFMpegSWResample : NSObject
- (instancetype)initWithSourceChannelCount:(NSInteger)sourceChannelCount sourceSampleRate:(NSInteger)sourceSampleRate sourceSampleFormat:(enum FFMpegAVSampleFormat)sourceSampleFormat destinationChannelCount:(NSInteger)destinationChannelCount destinationSampleRate:(NSInteger)destinationSampleRate destinationSampleFormat:(enum FFMpegAVSampleFormat)destinationSampleFormat;
- (NSData * _Nullable)resample:(FFMpegAVFrame *)frame;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>
#import <CoreVideo/CoreVideo.h>
NS_ASSUME_NONNULL_BEGIN
@class FFMpegAVFrame;
@interface FFMpegVideoWriter : NSObject
- (bool)setupWithOutputPath:(NSString *)outputPath width:(int)width height:(int)height bitrate:(int64_t)bitrate framerate:(int32_t)framerate;
- (bool)encodeFrame:(FFMpegAVFrame *)frame;
- (bool)finalizeVideo;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,8 @@
#ifndef FrameConverter_h
#define FrameConverter_h
#import <Foundation/Foundation.h>
void fillDstPlane(uint8_t * _Nonnull dstPlane, uint8_t * _Nonnull srcPlane1, uint8_t * _Nonnull srcPlane2, size_t srcPlaneSize);
#endif /* FrameConverter_h */