Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for merging video segments #44

Open
eonist opened this issue Oct 2, 2019 · 13 comments
Open

Add support for merging video segments #44

eonist opened this issue Oct 2, 2019 · 13 comments

Comments

@eonist
Copy link
Owner

eonist commented Oct 2, 2019

support merging video segments: https://www.raywenderlich.com/188034/how-to-play-record-and-merge-videos-in-ios-and-swift

@blurtime
Copy link
Collaborator

blurtime commented Oct 4, 2019

Unfortunately, I don't have much time to help you right now due to lots of studying. Nonetheless, I just saw you made a bunch of commits and found this issue. If only portrait is needed, please check out this question I answered myself using the very same tutorial. It works great for me! And might save you a bit of time ;)

@eonist
Copy link
Owner Author

eonist commented Oct 4, 2019

Which answer and question? For merging videos ?

@eonist
Copy link
Owner Author

eonist commented Oct 4, 2019

No worries. Feedback is also help, and doesn’t require you to unfocused in school ;)

@blurtime
Copy link
Collaborator

blurtime commented Oct 4, 2019

Sorry, seems like Alzheimer's is already kicking in 😂 here's the link: https://stackoverflow.com/questions/57083151/change-preferredtransform-of-assetvideotrack-to-solve-mirroring-issue-when-mergi

@blurtime
Copy link
Collaborator

Hi @eonist, how are you doing? I recently managed to start coding again and I want to finally finish one of my projects. I tried solving the issue of switching the camera while recording as shown here but couldn't make it work. As far as I am concerned I see two options.
One of them is to use Mutli Cam Session which IMO is a little overkill (more or less literally burns your GPU).
The second option is that we separate the audio entirely and record it as one separate file, then record a number of videos and keep track of the time when one was stopped and the next one was started and merge all of this together keeping the time in mind and filling the small stops of the video with a black screen (which for portrait mode is very easy). I could code this easily (link in the answer above). What would you think of this?

@eonist
Copy link
Owner Author

eonist commented Jun 21, 2020

Hi, Man. Doing great. One of my projects got funded the last 6 months so having fun with that: https://passbook.co

You mean support for merging multiple lense recordings, or support for merging many clips together in post prod?

@blurtime
Copy link
Collaborator

That's awesome. Just checked out the website. It's a pretty cool idea to use the kinetic movement :D
I am not sure I understand correctly cause they sound like the same to me.
What I would suggest:

  1. User starts pressing recordbutton: Audio is recorded (separately) and the video using the current device input (say back/rear camera)
  2. If the user stops -> merge audio and video and we have a normal clip like now
  3. If the user wants to switch the camera while recording, though, we continue recording the audio (since it's separate) but stop recording the video. Then we quickly switch the device input (in this case to the front camera) and start recording the next part of the video with the front camera.
  4. This could go back and forth indefinitely now.
  5. Once the user lifts his thumb from the record button both audio and current video stop recording.
  6. All file names should be kept in an array.

After that, I use the duration of the audio and each video to merge them such that there should be no lag. If we suppose that changing the camera always takes the same time on the same device, we can do the following:

  • audio duration - (video1.duration + video2.duration + ...) = total duration of camera flipping
  • divide this by (the number of videos - 1) = duration of one camera flip (on average)
  • merge such that clips always "one flip duration" apart).

What would you think of this?

@blurtime
Copy link
Collaborator

And I keep seeing this sample buffer function when doing research on this topic:
https://stackoverflow.com/questions/30216976/why-does-switching-cameras-stop-my-avcapturesession-to-moviefileoutput

@eonist
Copy link
Owner Author

eonist commented Jun 21, 2020

I think.

  1. start recording rear cam
  2. switch to front cam, start record front cam (when initiated stop back-cam)
  3. store clips in a folder with date as name then merge chronologically

If this doesn't work? please fill me in 🙏

@blurtime
Copy link
Collaborator

blurtime commented Aug 6, 2020

Hi @eonist, hope you're enjoying summer!
Unfortunately, something happened in June and I didn't have time to finish my idea. However, I managed to do it now, and at least the video saving and merging works. Although I am not sure how useful it will be for this library since I had to rewrite a whole bunch of code and I am using another library to deal with the file stuff. It wasn't easy but it's definitely doable. I don't have to lift my finger and get a merged video! :D Now only audio is missing but that hopefully won't be too much of a bother. I'll see if I can maybe give you a usable version of the video merger since I have learned quite a bit about it and maybe also how I rewrote a bunch of stuff in the CamView files soon.
Just wanted to keep you posted :)

EDIT: Another idea that would be pretty cool for sure would be filters. Any experience coding something along those lines?

@eonist
Copy link
Owner Author

eonist commented Aug 6, 2020

  • Has a bunch of stuff on merging video: https://www.raywenderlich.com/10857372-how-to-play-record-and-merge-videos-in-ios-and-swift#toc-anchor-005
  • I'm working on a VideoProcessor ATM for my startup. Basically turn an mp4 file into images, and images into mp4. (Will open-source tomorrow)
  • On filters: Depends how far you want to take it. You can do live filter preview. or post filter. the later would be easier. the former often involves metal etc. But there are a bunch of tutorials on it so you don't have to re-invent the wheel to add it etc.
  • What I suggest is that you make your video-merger-module open source. and then we can link to it from the HybridCam repo or something?

@blurtime
Copy link
Collaborator

blurtime commented Aug 6, 2020

Thank you for your resources, I'll look into them ASAP. Sounds like an exciting project, I'll check if I might find use in it for my project :)
The most important thing is essentially the answer on SO to the question I posed myself. But sure, I can do that :D

@eonist
Copy link
Owner Author

eonist commented Aug 7, 2020

If you open source the module, you can get feedback from other peers on it etc. Sometimes feedback can unlock big performance gains etc. Its easy to miss small details when you go into lower level coding. closer to c, c++ etc

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

No branches or pull requests

2 participants