You can set how much the PS4 will record in advance by doing the following:
Press SHARE, press OPTION, then select "Length of Video Clip". You can set the following lengths:
- 30 Seconds
- 1 Minute
- 3 Minutes
- 5 Minutes
- 10 Minutes
- 15 Minutes
Unfortunately, these values must be set before you choose to share a video. In other words, if you choose "1 Minute" and realize that the cool part started 2 minutes ago, that part will be lost by the time you press SHARE. Because of this, I'd recommend leaving this at "15 Minutes" (or setting it to that value) and instead go for the alternative.
Once the video is recorded, you can easily cut whatever it is you need using any video editing tool. Luckily, the PS4 has an official one made specifically for it, called SHAREfactory. You'll have to download it first, as it is not installed by default (at least not in the day-zero PS4s, as SHAREfactory wasn't available until several months after the PS4 launched). Its usage is relatively straightforward, so I won't explain it here.
Once you're satisfied with your work, press OPTION and select "EXPORT TO GALLERY". You might notice an option called "SAVE PROJECT". Since SHAREfactory doesn't modify video files, saving the project won't give you the video you're expecting. To get the video, you need to export it instead. Exporting takes time, so be patient.
You still might want to save the project, though, as you might encounter a situation where you might want to further modify your video by cutting even more content, or restoring already cut parts. Just remember to export the project once you're done, so your PS4 can create the requested (edited) video file.