FFMpeg Object
Please login to see this picture.
Description
Talking about the ADS...Tired about the uncontrollable gap before playing? Don't want the micro-stuttering when VSync is on? Want to play other formats like mp4? Need to protect your precious cut scenes? Then try this object!
Special thanks to @SelfReflection31 (From Github) and @Ruthoranium (From Discord), who help a lot to polishing this extension.
This object is based on cross platform lib, FFMpeg & SDL, in theory there is not too difficult to bring it to other platforms like Android.
Please login to see this link.
Please login to see this link.
Please login to see this link.
Free and open source
If you find some issues or have a new idea, you can modify the source code directly, and don't need to wait for author to make an update.
Prop & A/C/E List
## Properties
- Options
- Stretch
- *Stretch to fit object size*
- Play after load
- *Auto start play when a file is loaded*
- Loop
- *Loop video*
- *When playing finishes, extension will seek back to time stamp 0, and may need some time to rebuild codec context and restart playing*
- Accurate seek
- *To avoid display issues usually we should seek to a keyframe, but it may not that accurate. If enable this option, after seeking extension will decode frames until reaches the given time stamp, and will be time-consuming*
- *To make this work, make sure you use seek with flag `AVSEEK_FLAG_BACKWARD`. Seek action will use this flag as default so it's transparent to users, but I still note it here as we have an action which allows you to set seek flags...*
- Cache
- Cache decrypted data over frames
- Currently reading decrypt file didn't use a stream (it's provided by another class and FFMpeg only has a memory reader), so it may cost some time to decrypt. With this on extension will cache these file in memory over frames instead of reloading
- Queue
- *Data is split into packet in FFMpeg, and usually it needs several packets to decode one frame. For audio, it's played in another thread and use a callback to ask for more data, so the decoded packets are cached in a queue, and won't add new ones if cached data exceeds this limit. However, some formats with higher resolution may need more data to decode, which may exceed the limit (e.g., aida_alpha.mov), then the application will keep waiting forever. In this case, extend this limit will solve it.*
- *Note that when decoding, extension will firstly try filling up the queue. Usually it's fast but if the queue size is too big it may be time-consuming, and causes lag when seeking.*
- Hardware Decode
- Hardware Device
- *set the device you want object to use. object will try using the device you set, if not supported, it will try using other hardware devices. if all devices are not supported, it will fallback to software decode*
- Force No Audio
- *Don't play audio and sync with external clock*
- *This is a legacy feature for single instance SDL backend, kept for compatibility*
## Action
- Open Video
- *If open failed, extension will keep previous frame*
- *If key is not empty, extension will treat it as an encrypted file. Decode a normal file in encrypted way usually will crash. You can encrypt files by another extension.*
- *Encrypt & decrypt are based on AES so without your key no one can get your file, unless they dump it from memory.*
- Open Video To
- *Open video to a given timestamp*
- Close Video
- Play Video
- Pause Video
- Set Volume
- *volume is kept when opening another video*
- Set Loop
- *loop state is kept when opening another video*
- Set Force No Audio
- *see props*
- Set Audio Tempo
- *tempo = 2.0 -> play video in 2X speed*
- Set Accurate Seek
- see Properties->Accurate Seek
- Set Video Position
- *seek to the given time, in ms*
- Set Video Position With Flag
- *similar as above, but can let you set seek flag*
- *depend on the flag you use, first param is used in different ways*
```C
#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes
#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes
#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number
```
- Set Size
- *set object size*
- Set Queue Size
- *see Properties->Queue*
- Set Hardware Decode Device
- *see Properties->Hardware Decode Device and the table below*
| Device Name | AVHWDeviceType |
| ------------ | ----------------------------- |
| NONE | AV_HWDEVICE_TYPE_NONE |
| VDPAU | AV_HWDEVICE_TYPE_VDPAU |
| CUDA | AV_HWDEVICE_TYPE_CUDA |
| VAAPI | AV_HWDEVICE_TYPE_VAAPI |
| DXVA2 | AV_HWDEVICE_TYPE_DXVA2 |
| QSV | AV_HWDEVICE_TYPE_QSV |
| VIDEOTOOLBOX | AV_HWDEVICE_TYPE_VIDEOTOOLBOX |
| D3D11VA | AV_HWDEVICE_TYPE_D3D11VA |
| DRM | AV_HWDEVICE_TYPE_DRM |
| OPENCL | AV_HWDEVICE_TYPE_OPENCL |
| MEDIACODEC | AV_HWDEVICE_TYPE_MEDIACODEC |
| VULKAN | AV_HWDEVICE_TYPE_VULKAN |
- Cache Video
- *decrypt given file then cache it in memory*
- Erase Cached Video
- *erase cached given file*
- *the file is using now won't be erased*
- *input an empty file name will erase all cached file*
## Condition
- Video Open
- Video Play
- Video Loop
- Video Finish
- Video Hardware Decode
- *object is using hardware decode*
- Wanted Hardware Decode
- *you set object to use hardware decode*
- On Video Finish
- *immediate event, triggered when video finish playing.*
- On Video Open Failed
- *immediate event, triggered when video failed to open.*
## Expression
- Get Video Name
- Get Video Position
- Get Video Duration
- Get Volume
- Get Audio Tempo
- Get Video Open State
- Get Video Play State
- Get Video Loop State
- Get Video Finish State
- Get Current Video Frame Pointer
- Get Grabbed Video Frame Pointer
- *You can get the cSurface pointer of current frame / frame with given time stamp. Pass it to another extension then do anything you like.*
- *Note the target extension should build in /MD, aka use the same heap. Or it may crash due to access violation. See: <https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170>*
- Get Hardware Decode State
- Get Actual Hardware Device
- *get the device object is using*
- Get Wanted Hardware Device
- *get the device you set*
Display More
============
Enjoy!
X)