Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
360 commits
Select commit Hold shift + click to select a range
a4452e4
chore: debug print
pinlin168 Feb 21, 2019
a6f254a
improve MoviePlayer seeking and looping
pinlin168 Feb 22, 2019
8632070
MovieInput support trimming duration
pinlin168 Feb 23, 2019
41cded9
fix(MoviePlayer): fix seeking and refactor
pinlin168 Feb 23, 2019
303c79f
fix MoviePlayer retain cycle
pinlin168 Feb 25, 2019
2fd2cf5
fix MoviePlayer seeking choppy
pinlin168 Mar 2, 2019
cb5034f
fix MoviePlayer playAfterSeeking is not working
pinlin168 Mar 3, 2019
6a7dfd6
MovieOutput add startTime output callback
pinlin168 Mar 12, 2019
bad1705
chore: migration to swift 5.0
pinlin168 Mar 26, 2019
641c551
fix(camera): fix sampleBuffer delegate and upgrade project settings
pinlin168 Mar 27, 2019
94e78e0
make MovieOutput.startRecording sync-able
pinlin168 Apr 1, 2019
de6614e
fix MoviePlayer time observers are not triggered correctly
pinlin168 Apr 2, 2019
415e233
improve(player): expose player volume as public
sunday37zhiyi Apr 3, 2019
d6890c6
guard player status is readyToPlay and remove some debug log
pinlin168 Apr 11, 2019
a91f735
MoviePlayer support reusable with new playerItem
pinlin168 Apr 13, 2019
461c65a
fix MoviePlayer cannot stop
pinlin168 Apr 13, 2019
7572f93
Change base class of MoviePlayer to AVPlayer
pinlin168 Apr 15, 2019
5a2869e
Clean up CoreVideoTexture cache after rendering every frame to save m…
pinlin168 Apr 18, 2019
da5cd15
fix MovieOutput crash when activateAudioTrack
pinlin168 Apr 21, 2019
d53d4f2
Update config to compile FilterShowcase
RoCry Apr 15, 2019
fa96042
Try reuse buffer for crop filter
RoCry Apr 22, 2019
62fb8ca
Refactor ResizeCrop
RoCry Apr 23, 2019
851c845
Export newFramebufferAvailable in OperationGroup
RoCry Apr 23, 2019
0241dda
Merge pull request #11 from RoCry/roy-refactor
pinlin168 Apr 23, 2019
3ec5270
update MovieOutput audio start logic
pinlin168 Apr 24, 2019
8bb29f6
improve(MovieOutput): add recordedDuration, waitEncodingForLiveVideo …
pinlin168 May 1, 2019
0e18657
improve(Camera): fix force unwrap crash
pinlin168 May 1, 2019
a62303c
Fix crash when calling OpenGL when app is not foreground
pinlin168 May 5, 2019
d92934b
improve MoviePlayer
pinlin168 May 5, 2019
8a0fbd5
make Framebuffer lock public
pinlin168 May 9, 2019
0dc039e
fix ResizeCrop cannot use cropSize as final output size
pinlin168 May 10, 2019
c76c36e
fix MoviePlayer framebuffer was retained unexpectedly
pinlin168 May 10, 2019
22a882a
fix(MovieOutput): calling activateAudioTrack crashed when writing
pinlin168 May 13, 2019
85e5134
fix MovieOutput didn’t save startFrameTime in newFrameAvailable
pinlin168 May 22, 2019
034342a
improve(MoviePlayer): make shader prepare code to async
pinlin168 May 22, 2019
75c8959
fix AVAssetWriter error when cancelWriting/startWriting operations ar…
pinlin168 May 24, 2019
a30ac07
improve(MovieInput): support exporting without using OpenGL
pinlin168 Jun 13, 2019
5a31aaa
improve(camera): add metadataObjectTypes as param to camera init method
jandyx Jun 14, 2019
c5a5d62
fix(player): resume ability in MoviePlayer
sunday37zhiyi Jun 25, 2019
f402397
Merge pull request #15 from sunday37zhiyi/zhiyi-player
pinlin168 Jun 25, 2019
2c6c073
improve(debug): add a debug extension for framebuffer to export to UI…
pinlin168 Jul 4, 2019
c667ba5
improve: change yuvCOnversionShader to lazy loading
pinlin168 Jul 10, 2019
702dbf4
improve(MoviePlayer): add videoOrientation
pinlin168 Jul 11, 2019
53fec4f
improve(movie_player): improve code style and guard stopping not release
pinlin168 Aug 19, 2019
4127ecc
fix MoviePlayer framebuffer orientation is wrong when it is not portrait
pinlin168 Aug 21, 2019
87e92d4
Merge pull request #18 from RoCry/pinlin-fix-movieplayer
pinlin168 Aug 21, 2019
518727e
refactor: extract YUV framebuffer generating logic to FramebufferGene…
pinlin168 Aug 21, 2019
4dbdc6f
feat: add framebuffer convertToPixelBuffer
pinlin168 Aug 22, 2019
76c6982
feat(video-streaming): add streaming ability to output file.
Sep 2, 2019
5345795
improve: use video track preferredTransform for assetwriter when tran…
pinlin168 Sep 3, 2019
bf2fdf5
Merge pull request #21 from RoCry/pinlin-improve-transcoding
cunzhegao Sep 3, 2019
ab9c753
feat(frame-rate): drop frame if maxFPS is provided and exceed.
Sep 4, 2019
421514f
Merge pull request #22 from RoCry/feat-drop-frame
pinlin168 Sep 4, 2019
60e5497
improve(MovieInput): support video that original orientation is not p…
pinlin168 Sep 11, 2019
af17824
fix(movie-input): fix drop frame logic
Sep 4, 2019
2cd6563
chore(drop-frame): add note.
Sep 11, 2019
cfa45e5
Merge pull request #23 from RoCry/feat-drop-frame
cunzhegao Sep 11, 2019
3feafff
improve(transcoding): parallelize asset reader thread and render thre…
pinlin168 Sep 10, 2019
24818bd
improve(MovieInput): support pause and resume
pinlin168 Sep 10, 2019
f866f4b
Merge pull request #25 from RoCry/pinlin-improve-movieinput
pinlin168 Sep 16, 2019
b2ffe23
Merge pull request #24 from RoCry/pinlin-improve-transcoding
pinlin168 Sep 16, 2019
00ab883
fix(MovieOutput): fix audio sample buffer is not released correctly
pinlin168 Sep 18, 2019
110622c
fix(transcoding): fix audio is missing the last part
pinlin168 Sep 20, 2019
bf6bedb
fix: revert commit 110622c, using a better fix for audio missing last…
pinlin168 Sep 20, 2019
0b001a5
improve: support using AVPlayerLayer with MoviePlayer
pinlin168 Sep 23, 2019
437497d
feat(camera): support specifying device type
pinlin168 Sep 25, 2019
56e308c
fix(device): find matching device below iOS 13
RoCry Sep 27, 2019
807915b
improve(MovieInput): add some debug log
pinlin168 Oct 9, 2019
c8e7d6f
improve(movie-input): cancel associated movie output when canceling m…
Oct 10, 2019
f753f32
Merge pull request #29 from RoCry/improve-task-canceling
pinlin168 Oct 10, 2019
5580ac2
fix(movie-output): fix audio buffer thread issue.
Oct 10, 2019
cad134d
Merge pull request #30 from RoCry/fix-audio-thread-crash
cunzhegao Oct 10, 2019
7170f52
refactor: make public destroy frame buffer and image buffer.
Oct 14, 2019
4bb078d
chore(frame-buffer): hide frame buffer setter.
Oct 15, 2019
8f4efa8
improve(render-view): destroy frame buffer on bounds and frame size c…
Oct 16, 2019
69a43a8
Merge pull request #33 from RoCry/feat-album-story
pinlin168 Oct 16, 2019
10ffe10
chore: resolve some compiler warnings
Cokile Oct 16, 2019
f1da5e3
improve(MovieOutput): change critical path log to debugLog
pinlin168 Nov 3, 2019
4c8de6d
improve: MovieOutput log change to print, fix example project compile…
pinlin168 Nov 8, 2019
e6347bd
fix(movieplayer): fix possible crash when stop MoviePlayer
pinlin168 Nov 19, 2019
d4585cd
fix(movieplayer): fix seeking timing and add log for invalid playeritem
pinlin168 Nov 27, 2019
0262438
Merge pull request #35 from RoCry/pinlin
pinlin168 Nov 27, 2019
a4a3be0
feat: change to queueplayer, and update loop logic
pinlin168 Nov 28, 2019
58b2506
fix(player): fix playerItem observer is not correct
pinlin168 Nov 30, 2019
5a32973
improve(player): extract same code and add more log
pinlin168 Dec 3, 2019
e0ea452
fix(player): replace doesn't seek to the beginning, update log and as…
pinlin168 Dec 4, 2019
f67cec2
fix(player): move all time observer operations into main thread
pinlin168 Dec 5, 2019
0f1a939
fix(player): improve looping logic
pinlin168 Dec 5, 2019
c930352
Merge pull request #36 from RoCry/pinlin-feat-queueplayer
pinlin168 Dec 9, 2019
754e9f6
improve(player): support video output for normal video
pinlin168 Dec 8, 2019
a4aff55
debug: add log for printing filter pipeline
pinlin168 Dec 10, 2019
f9335e8
fix(player): fix observation crash on iOS 10
pinlin168 Dec 10, 2019
b8ca577
fix(player): fix looping is not correctly stopped after replacing
pinlin168 Dec 10, 2019
782f825
Merge pull request #37 from RoCry/pinlin-feat-queueplayer-part2
pinlin168 Dec 10, 2019
e8e8671
fix(player): change timeObserver callback timing to after rendering
pinlin168 Dec 11, 2019
a2a0883
fix(player): change timeObserver callback timing to after rendering, …
pinlin168 Dec 11, 2019
a3d1fe1
fix(player): fix replaceCurrentItem/insertItem is not working when pl…
pinlin168 Dec 11, 2019
0741580
Merge pull request #38 from RoCry/pinlin-fix
cunzhegao Dec 12, 2019
ac991d1
fix(player): improve playToEnd insert items logic
pinlin168 Dec 13, 2019
5c46f49
fix(player): improve playToEnd insert items logic, continue
pinlin168 Dec 14, 2019
b9b20a5
fix(player): fix OOM crash due to player item duration too short, cha…
pinlin168 Dec 18, 2019
5321683
improve(player): improve seeking time accuracy
pinlin168 Dec 19, 2019
0812534
fix(camera): fix possible frame dropping caused by retain too much sa…
pinlin168 Dec 19, 2019
dfca730
Merge pull request #39 from RoCry/pinlin
pinlin168 Dec 19, 2019
a87b8a0
improve(player): change to use CMTime for accuracy, and improve loopi…
pinlin168 Dec 23, 2019
2b3ea61
Merge pull request #40 from RoCry/pinlin
pinlin168 Dec 23, 2019
39f5e5b
improve(player): fix seeking cannot render frame
pinlin168 Dec 31, 2019
f80ffd1
improve(player): fix seeking not working if playerItem status haven't…
pinlin168 Dec 31, 2019
004073f
fix(transcoding): fix audio buffer infinitely waiting
pinlin168 Jan 6, 2020
7cfc525
Merge pull request #41 from RoCry/pinlin-fix-audio-waiting
pinlin168 Jan 7, 2020
be055fc
chore: update MoviePlayer log
pinlin168 Jan 8, 2020
e4f1a0c
improve(MovieOutput): support video buffer cache
pinlin168 Jan 12, 2020
88287ee
improve(MovieOutput): support video sample buffer cache
pinlin168 Jan 12, 2020
36d3c06
chore: update access level
pinlin168 Jan 13, 2020
9fcc183
refactor(MovieOutput): change to use MovieOutputState for more concre…
pinlin168 Jan 13, 2020
f4baac1
Merge pull request #42 from RoCry/pinlin-improve
pinlin168 Jan 13, 2020
64f8b57
chore: disable debug log and fix possible leak
pinlin168 Jan 13, 2020
6e3d11f
fix(MovieOutput): fix unexpected retain by Objc-c exception and resul…
pinlin168 Jan 14, 2020
c858e40
improve(MovieOutput): make sure all buffers are drained when finished…
pinlin168 Jan 14, 2020
721a82a
Merge pull request #43 from RoCry/pinlin-improve
pinlin168 Jan 14, 2020
56e837d
fix: possible crash when quickly change filters chain
pinlin168 Jan 15, 2020
6fb6758
improve(MoviePlayer): retry playing when inconsistent state detected
pinlin168 Jan 16, 2020
74e4187
improve(MovieOutput): exposure url property
pinlin168 Jan 16, 2020
23b997e
fix(MovieOutput): fix exception when finished writing
pinlin168 Jan 21, 2020
3a207ad
chore(MovieOutput): improve logging
pinlin168 Feb 4, 2020
f8274cb
improve(movieoutput): add more log for dropping frames
pinlin168 Feb 11, 2020
125458f
improve(movieoutput): keep only useful log
pinlin168 Feb 11, 2020
36eac01
fix(transcoding): fix transcode only task not emit progress.
cunzhegao Feb 24, 2020
c073921
Merge pull request #45 from RoCry/kubrick-fix-transcode-progress
pinlin168 Feb 24, 2020
fc40ff0
feat(lut): support CPU LUT filter when transcoding
pinlin168 Feb 24, 2020
ca7f85c
chore: add more player log
pinlin168 Feb 26, 2020
62c63ef
improve(MoviePlayer): fix movieplayer pending items are not remove co…
pinlin168 Mar 3, 2020
a474c53
chore: fix sample projects compile error
pinlin168 Mar 6, 2020
e21b693
improve(MovieOutput): make optimizeForNetworkUse optional and add mor…
pinlin168 Mar 6, 2020
32e5070
Merge pull request #48 from RoCry/pinlin
pinlin168 Mar 7, 2020
16509e8
fix(player): fix player keep replaying.
cunzhegao Mar 12, 2020
a9ed243
fix(player): fix player looping broken.
cunzhegao Mar 12, 2020
dbd23a5
Merge pull request #50 from RoCry/kubrick-fix-rich-editor
cunzhegao Mar 13, 2020
e4e6792
improve(MovieOutput): change MovieOutput render context to shared
pinlin168 Mar 18, 2020
b1fae9b
fix(preview): fix preview playing wrong item.
cunzhegao Mar 19, 2020
03fb0d3
Merge pull request #52 from RoCry/kubrick-fix-preview
pinlin168 Mar 20, 2020
4550719
improve(MovieOutput): better match lock and unlock for PixelBuffer ba…
pinlin168 Mar 25, 2020
a2a6502
improve(MovieOutput): change audio encode to async when encoding live…
pinlin168 Mar 26, 2020
f54a021
improve(MoviePlayer): clean framebuffer cache after player dismiss
pinlin168 Mar 26, 2020
1d791fc
fix(MoviePlayer): add more log and fix inserting is not working after…
pinlin168 Mar 26, 2020
a9e7a4a
Merge pull request #53 from RoCry/pinlin-improve
pinlin168 Mar 26, 2020
6d66fe4
fix(MoviePlayer): fix ANR when accessing currentTime when player noti…
pinlin168 Apr 8, 2020
e232c87
fix(MovieOutput): fix strange brightness blinking at the beginning of…
pinlin168 Apr 20, 2020
6f9acf9
fix(MovieOutput): fix can't stop video recording correctly and improv…
pinlin168 Apr 24, 2020
689174f
improve: add thread safety assert for target operations
pinlin168 Apr 27, 2020
24eac19
improve: add assertion for checking thread safety when accessing sour…
pinlin168 Apr 27, 2020
ddac43b
Merge pull request #55 from RoCry/pinlin
pinlin168 Apr 28, 2020
41dda5d
fix(output): skip when create texture failed
RoCry Apr 28, 2020
08efea6
Merge pull request #56 from RoCry/fix-roy
pinlin168 Apr 28, 2020
a579f0e
fix(audio): correctly throws when fail to active audio target.
cunzhegao May 6, 2020
f475688
improve: specify a different dispatch queue label for MovieOutput
pinlin168 Apr 3, 2020
8bb0260
improve: introduce executeStartTime and alreadyExecuteTime for Serial…
pinlin168 Apr 3, 2020
197facb
improve: introduce MovieCache and move cache management code from Mov…
pinlin168 Apr 3, 2020
6fc2919
fix: try catch possible crash
pinlin168 May 7, 2020
2693f4a
fix: add missing commit
pinlin168 May 13, 2020
5c48607
improve(MovieCaceh): improve new state from stoped to cancel
pinlin168 May 14, 2020
3863152
improve(buffercache): avoid duplicated add buffer to cache
pinlin168 May 22, 2020
3a10a6a
fix(transcoding): fix audio encoding not cancel after reader cancel.
cunzhegao May 29, 2020
596f87a
fix(framebuffer): fix random crash when force unwrap weak value
pinlin168 Jun 3, 2020
76688c5
fix(framebuffer): fix framebuffer cache accessing crash
pinlin168 Jun 3, 2020
5934843
improve(movieplayer): move copyPixelBuffer to displaylink to avoid co…
pinlin168 Jun 3, 2020
05dc039
feat(picture): support export with alpha for PictureOutput
RoCry Jun 8, 2020
99963df
feat: GaussianBlur support luminance threshold
pinlin168 Jun 10, 2020
a278f4c
feat: add show case entry for soft focus and luminance gaussian blur
pinlin168 Jun 10, 2020
2b515f6
chore: update project
pinlin168 Jun 10, 2020
9b68b54
chore: disable thread checking in demo app
pinlin168 Jun 10, 2020
0a3e4bc
fix: fix possible crash when setting shader parameters
pinlin168 Jul 1, 2020
45ab56e
fix(fast-forward): fix pitch issue when fast-forward.
cunzhegao Jul 6, 2020
3bf6cdc
fix(fast-forward): fix restart when fast forward.
cunzhegao Jul 8, 2020
07bc31e
feat(pipeline): basic debug print
RoCry Jul 8, 2020
06a1c6e
improve(context): expose some context property for PixelBufferOutput
cunzhegao Jul 9, 2020
f97b610
improve(MovieCache): make MovieCache api more reenterable
pinlin168 Jul 16, 2020
4f2f33f
improve(MovieOutput): make startRecording reenterable
pinlin168 Jul 16, 2020
4aa290c
chore: change property scope
pinlin168 Jul 21, 2020
b3aa3db
improve: update MovieCache state transition and update property scope
pinlin168 Jul 28, 2020
bd17a48
fix(MovieCache): fix MovieOutput is not started correctly in some cases
pinlin168 Aug 4, 2020
6a6e2ec
fix(MoviePlayer): fix didPlayToEnd is not accurate when currentItem i…
pinlin168 Aug 5, 2020
646d89b
improve(MoviePlayer): remove currentTime call in log since it might s…
pinlin168 Aug 14, 2020
51dfa01
improve(MovieCache): improve state machine and add property
pinlin168 Aug 18, 2020
d516ab9
improve(MovieCache): add completion callback for stopCaching
pinlin168 Aug 26, 2020
2c9cc47
fix(MovieOutput): fix possible crash if movie output was canceled
pinlin168 Aug 26, 2020
9a0e106
improve(MovieCache): improve stopWriting callback and state machine
pinlin168 Aug 31, 2020
be1910b
improve(camera): improve deviceType setting logic together with locat…
pinlin168 Aug 31, 2020
ef2ccab
improve: expose MovieOutput.startFrameTime and change MovieCache stop…
pinlin168 Sep 4, 2020
c9afe4d
improve(MovieCache): state machine for edge case
pinlin168 Sep 13, 2020
c26a498
improve(transcoding): reduce memory usage by wrapping auto release po…
pinlin168 Sep 13, 2020
804f826
improve(MovieOutput): add videoID and improve logging
pinlin168 Sep 13, 2020
99aa0c3
improve(MovieCache): use videoID to identify which MovieOutput should…
pinlin168 Sep 15, 2020
7f7e21a
chore(MovieCache): improve logging
pinlin168 Sep 15, 2020
1b2d99c
fix: fix compile error on simulator
pinlin168 Sep 16, 2020
edcd1c3
tweak(Camera): disable P3 color by default since it cannot be support…
pinlin168 Sep 21, 2020
88fe2a7
fix(RenderView): fix possible stuck when release in main thread
pinlin168 Sep 22, 2020
3aad160
chore: add debug log for frame dropping
pinlin168 Oct 12, 2020
b5d0302
fix(MovieOutput): fix encoding failed with -16364 error when appendin…
pinlin168 Oct 14, 2020
b7703b2
fix(MovieCache): should not cancel recording if there is already a mo…
pinlin168 Oct 19, 2020
9d7576f
improve: use CACurrentMediaTime for better time percision
pinlin168 Oct 27, 2020
a78fb26
improve: extract ResizeCrop frame calculation logic and support direc…
pinlin168 Nov 1, 2020
42ad85a
chore: change framebuffer cache warning count to 10
pinlin168 Nov 1, 2020
ccd5274
improve(PictureInput): better image orientation processing
pinlin168 Nov 13, 2020
b236841
improve(FrameBufferCache): allow more type of framebuffer to unlock a…
pinlin168 Nov 17, 2020
b3970e0
improve(PictureInput): support resize when input image from disk
pinlin168 Nov 17, 2020
9c141cf
fix(MovieOutput): fix empty buffer in audio track.
cunzhegao Nov 17, 2020
b408435
improve(PictureInput): better orientation logic
pinlin168 Nov 18, 2020
3b9e060
fix(MovieOutput): should not align AV when no audio is recorded
pinlin168 Nov 18, 2020
8db116a
fix(MovieOutput): semaphore didn't signal when pixel pool was released
pinlin168 Nov 19, 2020
54ea85c
fix(orientation): fix unsupported video orientation
cunzhegao Nov 23, 2020
0f1557d
fix(camera): fix preview frame size is wrong on iOS 12
pinlin168 Dec 2, 2020
d69e321
improve(camera): limit max size of camera output buffer
pinlin168 Dec 3, 2020
1136938
chore: update debug information
pinlin168 Dec 4, 2020
aed6d61
fix(gapless): should consider seeking when call seek item method.
cunzhegao Dec 10, 2020
fb052b2
feat(framebuffer): can control should return to cache
Cokile Dec 9, 2020
bafff3a
fix(moviePlayer): fix seek will play previous frames
Cokile Dec 17, 2020
acd9524
feat(renderView): add api for cropFrame
Cokile Dec 22, 2020
958ae74
improve(player): return correct current item.
cunzhegao Dec 31, 2020
a52a739
improve(MoviePlayer): allow seeking when is paused
pinlin168 Dec 22, 2020
dc1839e
improve: can manually control captureSession configuration
pinlin168 Jan 11, 2021
7d784d4
improve(Camera): can disable stabilization
pinlin168 Jan 19, 2021
766ba90
fix(renderView): resolve main thread checker issue
Cokile Jan 20, 2021
994c237
chore: improve code style by lint
pinlin168 Jan 31, 2021
f629396
improve(input): create picture input with extra transforms
Cokile Feb 5, 2021
1541ebb
fix: fix camera doesn't stop sometimes
pinlin168 Mar 8, 2021
9155a6e
chore: lint code style
pinlin168 Mar 12, 2021
c1967f8
improve(movie-player): remove init thread check.
cunzhegao Mar 3, 2021
4c8cffd
chore(player): adjust for streaming.
cunzhegao Mar 25, 2021
0f91c02
feat: add inputTime
RoCry Mar 25, 2021
2cd3e63
improve: make sure LUT intensity is always within valid range
pinlin168 Apr 12, 2021
a58e321
improve(picture): add a PictureInput init method for only display ima…
Apr 14, 2021
3f44c94
improve(PictureInput): support UIImage that associated with CIImage s…
pinlin168 Apr 18, 2021
bdfa5dc
improve: add more render info and make PictureInput to print debug in…
pinlin168 Apr 27, 2021
e7477f7
chore: add debugRenderInfo for OperationGroup
pinlin168 Apr 27, 2021
ae1ef5b
improve(PictureInput): fix scaled image might have a white line on edges
pinlin168 Apr 27, 2021
a0189d2
chore: update code style by lint
pinlin168 Apr 28, 2021
fc9210d
improve(PictureInput): better API for CIImage processes
pinlin168 May 7, 2021
1ab9446
improve(MoviePlayer): support using CIImage to process video frame
pinlin168 May 10, 2021
a414bca
chore: add a new API for SerialDispatch with sync as parameter
pinlin168 May 10, 2021
200907a
improve(MoviePlayer): improve CIImage extend rect precision
pinlin168 May 10, 2021
ef2782a
improve(MovieInput): support process steps on decoded frame
pinlin168 May 11, 2021
99a7abf
improve: skip trival process step
pinlin168 May 11, 2021
c8ff521
fix(MoviePlayer): orientation and size
pinlin168 May 11, 2021
0a8f5cf
improve: update code style and comments
pinlin168 May 12, 2021
a357e94
improve: separate CIContext for GPU and CPU for better performance
pinlin168 May 12, 2021
bdb68a0
chore: update code style with lint
pinlin168 May 13, 2021
b8fb7ea
fix(framebuffer): use correct orientation for CIImage process
pinlin168 May 15, 2021
7f82c51
delete unused PictureInput init because already has a generic Picture…
May 14, 2021
c4130f5
improve(player): cache asset duration.
cunzhegao Jun 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions GPUImage2.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Pod::Spec.new do |s|
s.name = 'GPUImage2'
s.version = '0.1.0'
s.license = 'BSD'
s.summary = 'An open source iOS framework for GPU-based image and video processing.'
s.homepage = 'https://github.com/BradLarson/GPUImage2'
s.author = { 'Brad Larson' => 'contact@sunsetlakesoftware.com' }

s.source = { :git => 'https://github.com/RoCry/GPUImage2' }

s.source_files = 'framework/Source/**/*.{h,m,swift}'
s.resources = 'framework/Source/Operations/Shaders/*.{fsh}'
s.requires_arc = true
s.xcconfig = { 'CLANG_MODULES_AUTOLINK' => 'YES', 'OTHER_SWIFT_FLAGS' => "$(inherited) -DGLES"}

s.ios.deployment_target = '10.0'
s.ios.exclude_files = 'framework/Source/Mac', 'framework/Source/Linux', 'framework/Source/Operations/Shaders/ConvertedShaders_GL.swift'
s.frameworks = ['OpenGLES', 'CoreMedia', 'QuartzCore', 'AVFoundation']

end
108 changes: 100 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ There are a few different ways to approach filtering an image. The easiest are t
```swift
let testImage = UIImage(named:"WID-small.jpg")!
let toonFilter = SmoothToonFilter()
let filteredImage = testImage.filterWithOperation(toonFilter)
let filteredImage = try! testImage.filterWithOperation(toonFilter)
```

for a more complex pipeline:
Expand All @@ -161,7 +161,7 @@ for a more complex pipeline:
let testImage = UIImage(named:"WID-small.jpg")!
let toonFilter = SmoothToonFilter()
let luminanceFilter = Luminance()
let filteredImage = testImage.filterWithPipeline{input, output in
let filteredImage = try! testImage.filterWithPipeline{input, output in
input --> toonFilter --> luminanceFilter --> output
}
```
Expand All @@ -173,7 +173,7 @@ Both of these convenience methods wrap several operations. To feed a picture int
```swift
let toonFilter = SmoothToonFilter()
let testImage = UIImage(named:"WID-small.jpg")!
let pictureInput = PictureInput(image:testImage)
let pictureInput = try! PictureInput(image:testImage)
let pictureOutput = PictureOutput()
pictureOutput.imageAvailableCallback = {image in
// Do something with image
Expand All @@ -186,24 +186,116 @@ In the above, the imageAvailableCallback will be triggered right at the processI

### Filtering and re-encoding a movie ###

To filter an existing movie file, you can write code like the following:
To filter and playback an existing movie file, you can write code like the following:

```swift

do {
let bundleURL = Bundle.main.resourceURL!
let movieURL = URL(string:"sample_iPod.m4v", relativeTo:bundleURL)!
movie = try MovieInput(url:movieURL, playAtActualSpeed:true)
let bundleURL = Bundle.main.resourceURL!
let movieURL = URL(string:"sample_iPod.m4v", relativeTo:bundleURL)!

let audioDecodeSettings = [AVFormatIDKey:kAudioFormatLinearPCM]

movie = try MovieInput(url:movieURL, playAtActualSpeed:true, loop:true, audioSettings:audioDecodeSettings)
speaker = SpeakerOutput()
movie.audioEncodingTarget = speaker

filter = SaturationAdjustment()
movie --> filter --> renderView

movie.start()
speaker.start()
} catch {
fatalError("Could not initialize rendering pipeline: \(error)")
print("Couldn't process movie with error: \(error)")
}
```

where renderView is an instance of RenderView that you've placed somewhere in your view hierarchy. The above loads a movie named "sample_iPod.m4v" from the application's bundle, creates a saturation filter, and directs movie frames to be processed through the saturation filter on their way to the screen. start() initiates the movie playback.

To filter an existing movie file and save the result to a new movie file you can write code like the following:


```swift
let bundleURL = Bundle.main.resourceURL!
// The movie you want to reencode
let movieURL = URL(string:"sample_iPod.m4v", relativeTo:bundleURL)!

let documentsDir = FileManager().urls(for:.documentDirectory, in:.userDomainMask).first!
// The location you want to save the new video
let exportedURL = URL(string:"test.mp4", relativeTo:documentsDir)!

let asset = AVURLAsset(url:movieURL, options:[AVURLAssetPreferPreciseDurationAndTimingKey:NSNumber(value:true)])

guard let videoTrack = asset.tracks(withMediaType:.video).first else { return }
let audioTrack = asset.tracks(withMediaType:.audio).first

// If you would like passthrough audio instead, set both audioDecodingSettings and audioEncodingSettings to nil
let audioDecodingSettings:[String:Any] = [AVFormatIDKey:kAudioFormatLinearPCM] // Noncompressed audio samples

do {
movieInput = try MovieInput(asset:asset, videoComposition:nil, playAtActualSpeed:false, loop:false, audioSettings:audioDecodingSettings)
}
catch {
print("ERROR: Unable to setup MovieInput with error: \(error)")
return
}

try? FileManager().removeItem(at: exportedURL)

let videoEncodingSettings:[String:Any] = [
AVVideoCompressionPropertiesKey: [
AVVideoExpectedSourceFrameRateKey:videoTrack.nominalFrameRate,
AVVideoAverageBitRateKey:videoTrack.estimatedDataRate,
AVVideoProfileLevelKey:AVVideoProfileLevelH264HighAutoLevel,
AVVideoH264EntropyModeKey:AVVideoH264EntropyModeCABAC,
AVVideoAllowFrameReorderingKey:videoTrack.requiresFrameReordering],
AVVideoCodecKey:AVVideoCodecH264]

var acl = AudioChannelLayout()
memset(&acl, 0, MemoryLayout<AudioChannelLayout>.size)
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo
let audioEncodingSettings:[String:Any] = [
AVFormatIDKey:kAudioFormatMPEG4AAC,
AVNumberOfChannelsKey:2,
AVSampleRateKey:AVAudioSession.sharedInstance().sampleRate,
AVChannelLayoutKey:NSData(bytes:&acl, length:MemoryLayout<AudioChannelLayout>.size),
AVEncoderBitRateKey:96000
]

do {
movieOutput = try MovieOutput(URL:exportedURL, size:Size(width:Float(videoTrack.naturalSize.width), height:Float(videoTrack.naturalSize.height)), fileType:AVFileType.mp4.rawValue, liveVideo:false, videoSettings:videoEncodingSettings, videoNaturalTimeScale:videoTrack.naturalTimeScale, audioSettings:audioEncodingSettings)
}
catch {
print("ERROR: Unable to setup MovieOutput with error: \(error)")
return
}

filter = SaturationAdjustment()

if(audioTrack != nil) { movieInput.audioEncodingTarget = movieOutput }
movieInput.synchronizedMovieOutput = movieOutput
movieInput --> filter --> movieOutput

movieInput.completion = {
self.movieOutput.finishRecording {
self.movieInput.audioEncodingTarget = nil
self.movieInput.synchronizedMovieOutput = nil
print("Encoding finished")
}
}

movieOutput.startRecording() { started, error in
if(!started) {
print("ERROR: MovieOutput unable to start writing with error: \(String(describing: error))")
return
}
self.movieInput.start()
print("Encoding started")
}
```

The above loads a movie named "sample_iPod.m4v" from the application's bundle, creates a saturation filter, and directs movie frames to be processed through the saturation filter on their way to the new file. In addition it writes the audio in AAC format to the new file.

### Writing a custom image processing operation ###

The framework uses a series of protocols to define types that can output images to be processed, take in an image for processing, or do both. These are the ImageSource, ImageConsumer, and ImageProcessingOperation protocols, respectively. Any type can comply to these, but typically classes are used.
Expand Down
6 changes: 3 additions & 3 deletions examples/Linux-OpenGL/SimpleVideoFilter/Source/main.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import GPUImage

// For now, GLUT initialization is done in the render window, so that must come first in sequence
let renderWindow = GLUTRenderWindow(width:1280, height:720, title:"Simple Video Filter")
let camera = V4LCamera(size:Size(width:1280.0, height:720.0))
let renderWindow = GLUTRenderWindow(width: 1280, height: 720, title: "Simple Video Filter")
let camera = V4LCamera(size: Size(width: 1280.0, height: 720.0))
let edgeDetection = SobelEdgeDetection()

camera --> edgeDetection --> renderWindow

camera.startCapture()
renderWindow.loopWithFunction(camera.grabFrame)
renderWindow.loopWithFunction(camera.grabFrame)
10 changes: 5 additions & 5 deletions examples/Linux-RPi/SimpleVideoFilter/Source/main.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import GPUImage

// For now, rendering requires the window to be created first
let renderWindow = RPiRenderWindow(width:1280, height:720)
let camera = V4LCamera(size:Size(width:1280.0, height:720.0))
let renderWindow = RPiRenderWindow(width: 1280, height: 720)
let camera = V4LCamera(size: Size(width: 1280.0, height: 720.0))
let edgeDetection = SobelEdgeDetection()

camera --> edgeDetection --> renderWindow

var terminate:Int = 0
var terminate: Int = 0

camera.startCapture()
while (terminate == 0) {
while terminate == 0 {
camera.grabFrame()
}
}
6 changes: 2 additions & 4 deletions examples/Mac/FilterShowcase/FilterShowcase/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!

var windowController:FilterShowcaseWindowController?
var windowController: FilterShowcaseWindowController?

func applicationDidFinishLaunching(_ aNotification: Notification) {
self.windowController = FilterShowcaseWindowController(windowNibName:"FilterShowcaseWindowController")
self.windowController = FilterShowcaseWindowController(windowNibName: "FilterShowcaseWindowController")
self.windowController?.showWindow(self)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ import GPUImage

enum FilterSliderSetting {
case disabled
case enabled(minimumValue:Float, maximumValue:Float, initialValue:Float)
case enabled(minimumValue: Float, maximumValue: Float, initialValue: Float)
}

typealias FilterSetupFunction = (Camera, ImageProcessingOperation, RenderView) -> ImageSource?

enum FilterOperationType {
case singleInput
case blend
case custom(filterSetupFunction:FilterSetupFunction)
case custom(filterSetupFunction: FilterSetupFunction)
}

protocol FilterOperationInterface {
var filter: ImageProcessingOperation { get }
var secondInput:ImageSource? { get }
var secondInput: ImageSource? { get }
var listName: String { get }
var titleName: String { get }
var sliderConfiguration: FilterSliderSetting { get }
var filterOperationType: FilterOperationType { get }
var sliderConfiguration: FilterSliderSetting { get }
var filterOperationType: FilterOperationType { get }

func configureCustomFilter(_ secondInput:ImageSource?)
func updateBasedOnSliderValue(_ sliderValue:Float)
func configureCustomFilter(_ secondInput: ImageSource?)
func updateBasedOnSliderValue(_ sliderValue: Float)
}

class FilterOperation<FilterClass: ImageProcessingOperation>: FilterOperationInterface {
lazy var internalFilter:FilterClass = {
lazy var internalFilter: FilterClass = {
return self.filterCreationFunction()
}()
let filterCreationFunction:() -> FilterClass
var secondInput:ImageSource?
let listName:String
let titleName:String
let sliderConfiguration:FilterSliderSetting
let filterOperationType:FilterOperationType
let sliderUpdateCallback: ((FilterClass, Float) -> ())?
init(filter:@escaping () -> FilterClass, listName: String, titleName: String, sliderConfiguration: FilterSliderSetting, sliderUpdateCallback:((FilterClass, Float) -> ())?, filterOperationType: FilterOperationType) {
var secondInput: ImageSource?
let listName: String
let titleName: String
let sliderConfiguration: FilterSliderSetting
let filterOperationType: FilterOperationType
let sliderUpdateCallback: ((FilterClass, Float) -> Void)?
init(filter:@escaping () -> FilterClass, listName: String, titleName: String, sliderConfiguration: FilterSliderSetting, sliderUpdateCallback: ((FilterClass, Float) -> Void)?, filterOperationType: FilterOperationType) {
self.listName = listName
self.titleName = titleName
self.sliderConfiguration = sliderConfiguration
Expand All @@ -50,12 +50,11 @@ class FilterOperation<FilterClass: ImageProcessingOperation>: FilterOperationInt
return internalFilter
}

func configureCustomFilter(_ secondInput:ImageSource?) {
func configureCustomFilter(_ secondInput: ImageSource?) {
self.secondInput = secondInput
}

func updateBasedOnSliderValue(_ sliderValue:Float) {
func updateBasedOnSliderValue(_ sliderValue: Float) {
sliderUpdateCallback?(internalFilter, sliderValue)
}
}

Loading