OpenShot / openshot-qt

OpenShot Video Editor is an award-winning free and open-source video editor for Linux, Mac, and Windows, and is dedicated to delivering high quality video editing and animation solutions to the world.
http://www.openshot.org
Other
4.36k stars 544 forks source link

Unwanted black frames added every few seconds in timelapse videos #2833

Closed Graystone55 closed 4 years ago

Graystone55 commented 5 years ago

I'm a 3D printer and my unedited video footage of a print can be 10-48 hours at 1080p 60fps h.264 50mb/s. These unedited videos are nearly perfect and have no frame errors or issues. But they are too high of a bitrate and length to easily stream. I then edit and post my lesser quality edited videos that are time lapsed to 32X faster (about 20-30 minute video) on YouTube.

I'm wanting to take these really large (100G to 2T), H.264, 1080p, 60fps videos and timelapse them to 32X the normal speed. They then would produce about 20 minute videos in the same h.264 1080p 60fps. Usually there is no sound or I will overwrite the sound track later.

I first apply a 16X speed increase then a 2X speed increase to achieve this since there is no 32X setting. I can see the video on the timeline is now about 20 minutes. I can view frame by frame and it looks OK but the system can't play the video preview without skipping. Not concerned about this.

If I had any audio in the video, I remove it. Then I add a music soundtrack of nearly the same amount of time and truncate it to match the video end.

I then export with the 1080p h.264 60fps settings in medium quality which is about 5mb/s. This takes about 80 hours of waiting for results and produces a video usually around 2G-3G in size.

The video itself is correct and looks great except for one really bad fact. About every 4 or 5 seconds the video will flash a lot. It's random timing when it flashes. Sometimes flashing only once sometimes 4 or more times.

When I analyze it by looking at it frame by frame, I see lots of blank black frames added into the otherwise good video. Each place/time one of these black frames was added, it appears as a flash to the viewer. I've tried this on two different videos. Needless to say with 20-40 hours of editing then waiting up to 80 hours for the final product and seeing Openshot insert these black frames is disheartening and many hours of wasted work. There are hundreds to thousands of these black frames added so redoing an edit to remove them isn't practical.

I have done one huge video in high quality and this doesn't happen then. So apparently the reducing the export to medium quality triggers it to happen. The high quality exports don't have the unwanted black frames. But those also take about 120 hours to export the file and is often too big for YT video at 200G or more. Hence the reason I am trying to reduce to medium quality.

Does anyone know why these black frames are being created and is there a way to stop this from happening and ruining a hundred hours or more of work?

SuslikV commented 5 years ago

About timelapse software - https://github.com/OpenShot/openshot-qt/issues/2766#issuecomment-494518153

Also, there was bug report that mentions black frames too - https://github.com/OpenShot/openshot-qt/issues/2798

About huge file size, if you are using h264, you can try to set 21 crf to Bit Rate/Quality field at advanced tab of export settings (place it instead of bitrate). To use constant rate factor of 21 (or any in range 0...63) for output.

mikelacsa commented 5 years ago

@Graystone55 are you still having the black frames with the latest version?

Graystone55 commented 5 years ago

I need to give you a rundown of what I do to edit since it may help you figure out the black frames. I know it's lengthy, but details might be what you need to find the error at 16X speedup? I'm not asking you to fix anything as I've found my solution. But I think you could use the info to possibly troubleshoot some issues with OpenShot. I'm not expecting or requiring a reply.

The version of OpenShot I've got now is 2.4.4. I generally get 20-100 hours of video from my Sony video camera in about 10 hour mp4 files by filming a 3D printer printing a model. I can end up with up to 100 hours of total videos when done. My Sony video camera has settings of 60fps or a 30fps 1080p output. When set to my normal choice of 30fps, it actually produces 29.97fps not 30. If I set it to 60fps, it really does 60. (Youtube, where I send the final results, tends to be mostly people who would have difficulty streaming 60fps so I generally use 30fps.)

I then edit each of the multi hour videos as follows: Using VideoRedo, I set all audio of each file to to 0% volume. I keep cutting the individual videos down till the total amount of video I will have is around 2 hours of video total or less. I then join all the individual videos together to one file using Videoredo. I use it here instead of OpenShot because Videoredo produces exact original video quality and original settings using a fast frame copy method so it only has to render the audio to 0% and join the video segments. It doesn't have to completely rerender again and therefore can completely take a 100 hour video and cut it down to a 2 hour video (or automatically remove commercials) in less than an hour. OpenShot takes 70-80 hours to do that for about 100 hours of original video because it always completely rerenders.

To be honest, I can't even get OpenShot to respond to the interface with a 30-100 hour long 1080p 30fps video loaded. One mouse click can take 10 minutes to respond. Also I can't EVER play a video using the OpenShots viewer as it stutters and stops every few frames even on small videos. So I have to do my editing blind to the possible results. I think that is because OpenShot is always doing something constantly in the background that sucks about 75% of my 3Ghz Quad cores.

So the single video produced by Videoredo is now about 2 hours with the exact same quality as the original at 29.97 fps. But VideoRedo is only good for cutting and splicing not adding things to a video. So now I turn to Openshot which is great at this.

Openshot now manages to load my 2 hour long 1080p 29.97fps videos fine (just can't play any of them with the viewer). With the main silent video loaded in one OS track, I now modify it with OS to 8X or 16X faster timelapse. I then add appropriate audio track(s) to the 2nd OS track that spans the main video length and turn down it's volume to 30% or so to play as background music. I use the OS editor to fade out and truncate the last audio added so it is not too long for the main video.

Now I add a 3rd OS track of a short video to show after the main video with audio fully in tact. (Previously edited to size and time with Videoredo). This is me demonstrating the end result of the model printed, usually with my narration. This track I do not modify or timelapse unless I do a fade or swipe or such from the main video to this one.

Now I render and save the whole thing as 1080p 29.97fps at top quality. On average it takes about 12-24 hours of OpenShot rendering to complete.

If I used 8X on the main video, it cuts that 2 hour+ video down to about 15-20 minutes and the results are great. I would rather be using 16X and have the video end up being 8-12 minutes. But the 16X does usually produce the black frames interleaved with my video frames. The audio track seems to be playing fine. It's almost like it's adding those frames on purpose to make it work with the timing or something. I notice the black frames on some videos can be really minor while on others it's every 5 or 6 frames gets one inserted. It's randomn in timing though as one area of the video can have hundreds of them and another looks almost clean. It's generally worse if I convert the 29.97fps to 30fps or change audio or video type codecs. But it only happens when rendering a 16X video speedup. It always works fine with 8X.

I've frankly learned not to use 16X at any more and haven't tried it for a while because I have to wait 12-24 hours for the render to complete before finding out I just have to delete it. I now just try to further cut my videos down to size when possible and then use 8X instead which never gives me issues. But of course cutting and editing don't look as smooth as timelapsing.

So there you have it. Sorry I had to be so long-winded. But maybe it will give you an idea where or why it happens. It's something in the rendering process that creates them and only at 16X. Maybe it just taxes my Quad Core or video adapter too much? I have learned to do the task using 8X so don't waste a lot of your time trying to fix this for me. OpenShot still is a great editor for features and so I use it when creating the final work. Now if you folks could create an editor that also did the fast frame copy with original quality and minimal rendering, like VideoRedo, you'd have me for the whole process. VR is great for editing and resaving fast but lousy at converting to anything other than standard mp4. Your OS is great at adding many elements together to make a true work of art and converting. I also have used PavTube for just converting videos with varying results, but again, it's a lousy editor.

If you would like to see some of the work I do with your editor you can see it on my Youtube channel at: https://www.youtube.com/channel/UCTmWjTJMaH6_cDykNYGoDDQ

Thanks and good luck! I like your video editor. Don Gray dongray55@gmail.com

On Tue, Oct 1, 2019 at 12:08 PM mikelacsa notifications@github.com wrote:

@Graystone55 https://github.com/Graystone55 are you still having the black frames with the latest version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OpenShot/openshot-qt/issues/2833?email_source=notifications&email_token=AMKVAAGUC6UF4QUABT63XW3QMON3PA5CNFSM4HXEWG4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEACMTOY#issuecomment-537184699, or mute the thread https://github.com/notifications/unsubscribe-auth/AMKVAAFJYCHMVCSMJG6EMDTQMON3PANCNFSM4HXEWG4A .

mikelacsa commented 5 years ago

Thanks Don. Have you tried it with the 32bit version as mentioned in this thread?

https://github.com/OpenShot/openshot-qt/issues/2798

Graystone55 commented 5 years ago

I'll try that. I only do new videos about 1 or 2 times a month now so it will be a while. But I'll download it. So the one I have now is 64bit? I'll let you know if it helps or doesn't on my next set of edits.

On Thu, Oct 3, 2019 at 12:52 PM mikelacsa notifications@github.com wrote:

Thanks Don. Have you tried it with the 32bit version as mentioned in this thread?

2798 https://github.com/OpenShot/openshot-qt/issues/2798

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OpenShot/openshot-qt/issues/2833?email_source=notifications&email_token=AMKVAAAIMWJZR3OFCDQ36BDQMZEPTA5CNFSM4HXEWG4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAJMNNA#issuecomment-538101428, or mute the thread https://github.com/notifications/unsubscribe-auth/AMKVAADRQBUXDH5DAM6WYDTQMZEPTANCNFSM4HXEWG4A .

mikelacsa commented 5 years ago

@Graystone55 this is, of course, assuming that you have the 64bit because it is the usually used version.

Will be looking forward to your update then.

Cheers!

ferdnyc commented 5 years ago

@Graystone55

Thanks for the very detailed report, information like that is always extremely helpful when we're trying to get a handle on how users interact with OpenShot and the issues they encounter along the way.

I'm not going to wade into #2798, the user went away satisfied and that's great. But I have my reservations about switching to the 32-bit build as a solution to much of anything, and I suspect there's more going on there than it appears.

(Most likely, the user downloaded the latest 2.4.4-dev2 Daily Build (in 32-bit), to replace the OpenShot 2.4.4 release build they were using previously, and it's the version upgrade that solved their problem, not the change in bit width. Or, the problem they were having initially was that their system was running out of memory, and since 32-bit applications can only access a maximum of 4GB, that may have relieved some of the memory pressure as a side-effect.)

Anyway, you're more than welcome to try a 32-bit build, and if it does make an appreciable difference then I'd be very interested to know because that means there's something wrong with our 64-bit builds that needs to be corrected. But as a long-term fix, it's not what I'd consider a particularly viable one, and if you're game I'd like to explore some more focused solutions to the issues you reported.

OpenShot still is a great editor for features and so I use it when creating the final work. Now if you folks could create an editor that also did the fast frame copy with original quality and minimal rendering, like VideoRedo, you'd have me for the whole process.

Enh. Honestly I think you're ahead of the curve here. Prepping assets before importing them into OpenShot is a smart idea for a whole host of reasons, and I actually recommend that approach over trying to do everything in OpenShot. You have no idea how much time I spend on these issues encouraging people to process their files in a more focused tool BEFORE they load them into OpenShot, because there are things it is good at and things it is not. The idea that there needs to be a "one-stop shop" that does everything is IMHO a misguided expectation. In fact, I'm going to encourage you to move MORE of your work out of OpenShot, in the interest of providing it with what it needs to do its part of the job as effectively as possible. And I'll explain my reasoning along the way, in hopes of convincing you that these are things worth trying, though ultimately you are of course free to heed or ignore my ideas as you see fit.

I took a look at the documentation for VideoReDo, and it seems like a fairly capable video preprocessor and transcoder. There are a bunch of things it can do in a lot of detail and really flexibly, and other things it can't really do at all. (Much like OpenShot.) But as a class of applications, I am very much on board with the idea of running video — especially raw video captured by a camera ­- through a preprocessor/converter before importing it into OpenShot. That's just good asset management, IMHO.

If I read correctly, you say that your primary uses for VideoReDo are:

  1. Cutting camera footage down to length
  2. Silencing audio tracks
  3. Joining videos together
  4. Removing commercials (though... surely that doesn't apply to camera footage? :laughing: )

So, ignoring the last one, we've got two important preprocessing steps (1 and 2), and an assembly step that isn't strictly part of the preprocessing — although with your current workflow, it's certainly a necessary step because speed-changing N shorter video clips in OpenShot would be a lot more hassle than speed-changing 1 long one. And that's only one of the issues with using OpenShot for the speed-change step.

To be honest, I can't even get OpenShot to respond to the interface with a 30-100 hour long 1080p 30fps video loaded. One mouse click can take 10 minutes to respond. Also I can't EVER play a video using the OpenShots viewer as it stutters and stops every few frames even on small videos.

That's unfortunately not surprising. And speeding it up will only make the performance worse, because the big problem is that due to the way OpenShot works, if you take a 30fps video and speed it up to 8x, you've effectively given OpenShot a 240fps video. And if you though the performance was bad before...

OpenShot's speed adjustment tools are also possibly its worse feature, in every aspect. They're inflexible, they're fragile, and using them is the performance equivalent of flooding a subway system with seawater: ain't nothing going to run properly.

It would be far better, in fact I'm going to predict it would be like night and day, to get that step out of OpenShot and into the preprocessing phase instead.

VideoReDo can't do that, unfortunately. However, the free video transcoder avidemux can... in fact, it almost feels like it was created specifically for your needs. And I think it could BE exactly what you need.

The interface is very basic: By default — though you can save your default settings, and configure it to load them either at startup or before opening each file — it loads up a video, automatically sets itself into Copy mode (where it operates, like VideoReDo, on the original video/audio streams without re-encoding), and presents you with a typical interface: seek bar, transport controls, time index, etc.

Trimming down a video is child's play: The initial selection is the entire length of the video, but you can move either endpoint by simply seeking where you want to start/end, and pressing Ctrl+PgUp to set the new position of the A marker (the start of the selection range), and Ctrl+PgDn to relocate the B marker (end of the selection). The selected range is displayed as a blue box around the seek slider.

To remove the audio track (not silence, but actually completely eliminate from the output file, which is even better) just go into the Audio > Select Track menu, and uncheck the Enabled box for the existing file's track(s). Simple as that.

Avidemux can concatenate videos (you simply choose File > Append instead of File > Open when loading additional files), but that's not useful when combined with trimming, and let's set it aside for the moment.

The real power of avidemux is in its ability to filter the video clips it's working on. This DOES involve re-encoding (there's no way around that), but I'll make an argument for why you want to do that here, before bringing the files into OpenShot.

So, to access the filters you first have to change the video output format from "Copy" to some other format. "Mpeg4 AVC (x264)" is by far the most common, though if you have a supported GPU and there are any hardware-accelerated encoding options listed, you should certainly consider using those instead. Depending which encoder you select, there are a bunch of options you can set under Configure (and save as presets, for reuse), but let's put those aside for now and visit Filter.

The reason avidemux's filters are so important at this step is because it has the ability to alter frame rate, in multiple ways: It can apply the rate changes on a 1:1 basis so that the video duration is affected, and it can resample the frame rate in a way that doesn't affect the duration. By combining those two, we can perform the speed change step right here, and much, much more effectively than OpenShot can.

If you open up the Filters window, you'll see a three-column window, with a filter list in the middle. (The right is the active filter list, so it starts empty.) To add a filter to the current processing configuration, just double-click on it and set the parameters in the dialog that comes up.

In order to apply the speed change you're interested in with avidemux filters, you can combine:

  1. Resample FPS — this keeps the video at the same speed, but removes/duplicates frames to achieve the selected rate. Your video is currently 29.97FPS, so here you should set the "New frame rate" to 2.00. Your video will keep the same runtime, but have 14.985 × fewer total frames.
  2. Change FPS — this alters the video duration, much like OpenShot. Since your video is now at "2FPS", make sure the "Source frame rate" is 2.00 (it should be, automatically), then set the "Destination frame rate" to 30.00 (or 29.97, whichever you want to use for export in OpenShot). The video's frame rate will be altered so it plays 15 × faster (or almost).

And there you have it. You'll now be able to write out a video clip, trimmed however you like, with its audio track removed, and already sped up 15× at 30FPS — ready for import into OpenShot. You'll have to wait for avidemux to encode it, which will take time, but it's well worth waiting for because the amount of workload you'll take off of OpenShot by doing this step is immeasurable.

If you choose, after you've exported all of the re-encoded clips, you could assemble them all together in avidemux, using File > Append and the Copy output mode to losslessly join the files. But I'd argue that you don't really have to, because now that you're not changing the speed in OpenShot, it's not really a problem to have your video made up of multiple separate clips instead of just one. You're not going to be changing durations, so it's easy enough to pop them all on the timeline end-to-end-to-end as separate clips. And then you have the option of re-arranging them or reconsidering what you include, while you're working on the final edit.

Encoding from 30fps video clips instead of (effectively) a massive 240fps (or 480fps!) effective-rate clip will go so much faster in OpenShot, and you won't have nearly as much difficulty working with the timeline during the editing step either. OpenShot doesn't need all of those extra frames, and they're just getting in the way, so my advice is to eliminate them right up front.

And if you want to tweak the speed change, unlike OpenShot avidemux will allow you to resample into any frame rate you want, even fractional ones. If you want to get the speedup to exactly 16× instead of not-quite 15×, just change the frame rate in the first filter from 2.00 to 29.97 / 16 = 1.87.

I'll leave it as an exercise for the reader to work out the export settings for the encoder Config. (Mostly because, if you do end up using a Windows hardware encoder, I have absolutely no idea what the configuration options will even look like.) But I suspect you'll be able to work it out with a little experimentation. It seems worth a try, at least, from my perspective.

Up to you.

stale[bot] commented 4 years ago

Thank you so much for submitting an issue to help improve OpenShot Video Editor. We are sorry about this, but this particular issue has gone unnoticed for quite some time. To help keep the OpenShot GitHub Issue Tracker organized and focused, we must ensure that every issue is correctly labelled and triaged, to get the proper attention. This issue will be closed, as it meets the following criteria: - No activity in the past 180 days - No one is assigned to this issue We'd like to ask you to help us out and determine whether this issue should be reopened. - If this issue is reporting a bug, please can you attempt to reproduce on the latest daily build to help us to understand whether the bug still needs our attention. - If this issue is proposing a new feature, please can you verify whether the feature proposal is still relevant. Thanks again for your help!