Commit Graph

269 Commits

Author SHA1 Message Date
Jonathan Thomas
09ce05bbf2 Many improvements for smooth audio playback when 'time' keyframes are used for time remapping.
- Added new Frame::ReverseAudio() helper method - for time keyframe support playing backwards audio
- Fixed math rounding error on time keyframe Resampler, to use the rounded source samples value
- Removed some unused args and Frame audio methods
- Reset FrameMapper resample context when non-adjacent frames are requested
- Correctly reverse Frame audio if a time keyframe is present, and reversing audio
- Rewrite Keyframe::IsIncreasing() function, to give accurate direction of time keyframes at any index (special logic to support first and last indexes)
- Fixed Keyframe unit tests - since logic has changed a bit
- Improved time mapping unit tests
- Replace many c-style casts with static_cast
- Added new sine.wav test file
2023-03-10 01:15:14 -06:00
Jonathan Thomas
70e86ef044 Improved Profile Class (Helper methods, Sortable, Unit tests) (#895)
* Removing legacy profile property. Add new operators for Profile classes (for comparison). Also added new functions to generate different variations of the Profile data (key, short name, long name, long name w/description).

* Add empty constructor for Profile class, and new Profile unit tets

* Adding zero padding to profile Key function, for easier sorting: 01920x1080i2997_16:09

* Clear setfill flag after creating Key() output

* Updating example exe to load an *.osp project file via C++, which makes debugging complex broken projects much easier.

* - Add new unit test to FFmpegWriter to create an animated GIF and verify it can be wrapped with a FrameMapper (with no audio track)
- Improve FrameMapper to ignore missing audio data (i.e. when no audio samples present, don't try and find them or resample them)

* Fix some whitespace issues

* Fix inline documentation mistype

* Fixed missing reuse licensing on new example profile files

* Changing Profile::Key() format to exclude the : character, since Windows file names cannot contain that

* - Large memory leak fixed in FFmpegWriter when closing the video & audio contexts
- Reducing # of cached frames and rescalers to 1, since we no longer use OMP and this is unneeded - we need to refactor much of this code out eventually

* - Fixing whitespace issues
- Code clean-up / line wrapping / etc...
2023-02-02 16:29:38 -06:00
Frank Dana
08b4975600 Replace av_init_packet in FFmpeg 3.2+ (#784) 2022-03-16 23:58:06 -04:00
Frank Dana
6c546408ca src/FFmpegWriter.cpp: Fix indents 2022-03-13 20:00:43 -04:00
FeRD (Frank Dana)
2a93c0c3bf FFmpegWriter: Don't use AVPicture (gone in 5.0) 2022-02-24 10:34:41 -05:00
FeRD (Frank Dana)
eac566f81f FFmpegWriter: Don't force deprecated stream member 2022-02-24 07:55:03 -05:00
FeRD (Frank Dana)
93debab7c4 FFmpegWriter: Macro & member cleanup
- The `fmt` class member, which was of type AVFormat*, was really
  just an unnecessary copy of `(AVFormatContext*)oc->oformat`.
  But we were ASSIGNING into its members, which we were definitely
  not supposed to be doing. (And in recent FFmpegs, now that
  `AVFormat` has been `const`d, we can't.) It's gone; now we just
  use `oc->oformat` anywhere we used to access `fmt`.

- The preprocessor macro to allocate a new _stream_ was a mess of
  cross purposes: It did allocate a stream, but then it also
  allocated a new AvCodecCtx on newer FFmpeg releases. Worse (and
  always galling to me), it proceeded to assign to a variable
  that WASN'T passed in to the macro, just taking it on faith that
  it would only be used where that variable was defined. That's
  just... ugh. So I broke it apart into two steps (stream creation
  and context allocation), realized the stream creation code was
  the same for all ffmpeg versions and didn't need to be a macro
  at all, and now a 4-parameter, 6-line magical macro has been
  replaced with a simple, zero-side-effect one-liner.

- I also cleaned up the add_video_stream() code to be more like
  the add_audio_stream() code, since they were bad-different for
  no discernible reason.
2022-02-24 07:29:08 -05:00
FeRD (Frank Dana)
3b1d4102af FFmpegWriter: Format ZmqLogger calls, move headers 2022-01-12 11:02:52 -05:00
nick black
99034feb4e constify some AVCodecIDs, necessary for new ffmpeg
Signed-off-by: nick black <dankamongmen@gmail.com>
2021-11-22 00:09:08 -05:00
FeRD (Frank Dana)
e11b9434cf Docs: Fix doc ambiguities when matching functions 2021-11-11 07:04:05 -05:00
FeRD (Frank Dana)
59108504e3 Code changes for compatibility with JUCE 6.x
- Replace all juce::CriticalSection with std::recursive_mutex
- Replace all juce::AudioSampleBuffer with juce::AudioBuffer<float>
- Eliminate implicit reliance on 'using namespace juce;'
- Replace OpenShotAudio.h includes with targeted juce modules
2021-11-09 06:22:25 -05:00
Frank Dana
311d86957e Include FFmpegUtilities.h earlier (#764) 2021-10-27 06:49:27 -04:00
Frank Dana
59138ea3e4 Adopt license management via Reuse project/tool (#711)
* reuse-managed license/copyright headers

reuse is a tool for compliance with the REUSE recommendations. See
<https://reuse.software/> for more information, and
<https://reuse.readthedocs.io/> for the online documentation.

* Set jsoncpp license
* Add MIT license for Decklink sources
* Explicitly license examples/
  - Add headers to source files
  - Change blanket licensing in .reuse/dep5 to only cover binary media
  - Import CC-BY-3.0 license and assign to sintel_trailer
2021-10-16 01:26:26 -04:00
Jonathan Thomas
111026d8a1 Merge pull request #753 from OpenShot/anomorphic-fix
Support for anamorphic profiles, i.e. non-square pixels (including waveform fixes)
2021-10-08 16:08:38 -05:00
Jonathan Thomas
15e5285206 Support for anamorphic profiles, i.e. non-square pixels. Fixes include Frame::Display, Frame::Save, and Timeline::SetMaxSize, all which had various issues. Added sample_aspect_ratio to FFmpegWriter, so the exported videos will continue to be anamorphic.
Also fixed some waveform issues, which were not appearing, or appearing squished, and sometimes containing gaps.
2021-10-07 13:45:16 -05:00
Frank Dana
d78ac099d6 CodeQL fixes, take 2 (#745)
* Protect values against integer overflow

When the code multiplies integer values in an rvalue context before
it's stored in a larger type, the on-the-fly math is stored as int.
The value can overflow before it reaches the wider memory space.

To prevent this, we explicitly cast the result of the arithmetic
to the destination type.

Issues flagged by GitHub CodeQL.

* Apply these fixes correctly
2021-10-03 07:01:56 -04:00
Frank Dana
3d18347e71 Protect values against integer overflow (#743)
When the code multiplies integer values in an rvalue context before
it's stored in a larger type, the on-the-fly math is stored as int.
The value can overflow before it reaches the wider memory space.

To prevent this, we explicitly cast the result of the arithmetic
to the destination type.

Issues flagged by GitHub CodeQL.
2021-09-27 20:36:56 -04:00
Frank Dana
fbe0242837 FFmpeg: Create, use av_err2string() (#689)
- Previously 'av_make_error_string' was defined in FFmpegUtilities.h
  for the sole purpose of redefining `av_err2str()` as a call to that
  function. `av_err2str()` was then used in our code, often in string
  contexts where its output was cast to `std::string`.
- Since that was excessively circular, instead the function is named
  `av_err2string()`, and it's used directly in contexts where a
  std::string is expected.
- `av_err2str()` is still #defined as `av_err2string(...).c_str()`
2021-08-11 03:58:45 -04:00
Jonathan Thomas
db7f0fb5e7 Fix audio encoding on FFmpeg 4.4. AVFrame was missing a few properties that need to be set in newer versions of FFmpeg. This is also compatible with FFmpeg 3+. 2021-07-07 00:08:27 -05:00
Jonathan Thomas
9ca63b321a Reverting video_timestamp increment logic which used pkt.duration. In some codecs (such as vp8), this approach breaks due to differences in the timebase vs the framerate. For example, if the timebase is an inverse of the FPS, everything works. But if the timebase is not, for example 1/1000000, this approach breaks. 2021-07-03 17:01:55 -05:00
Jonathan Thomas
850140df7d Switch to pkt.duration for incrementing PTS, and rename the 2 timestamp variables to something more sane. 2021-06-26 17:24:15 -05:00
Jonathan Thomas
5b524aba2f Experimental conversion of timestamp rescaling to use the av_packet_rescale_ts() method. I'm just not sure the backwards compatibility of this approach with older FFmpeg versions. 2021-06-26 15:56:58 -05:00
Jonathan Thomas
1cec1843c6 We already init values in constructor, and moving incrementing to later in function. 2021-06-26 15:48:16 -05:00
Jackson
64e578241a Reduced, but didn't eliminate empty time at the beginning 2021-06-25 18:54:27 -05:00
Jonathan Thomas
bdf6e9f854 Fix invalid starting PTS value, preventing blank 1st frames on some thumbnailing and video players. 2021-06-25 15:57:52 -05:00