Skip to content

Commit e359ea4

Browse files
authored
Merge pull request #137 from OpenShot/release
Merge release into develop
2 parents 2f45a4e + cc17315 commit e359ea4

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ windows-builder-x86:
6767
- New-Item -ItemType Directory -Force -Path build
6868
- New-Item -ItemType Directory -Force -Path build\install-x86\python
6969
- cd build
70-
- cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" ../
70+
- cmake -D"CMAKE_INSTALL_PREFIX:PATH=$CI_PROJECT_DIR\build\install-x86" -G "MinGW Makefiles" -D"CMAKE_BUILD_TYPE:STRING=Release" -D"CMAKE_CXX_FLAGS=-m32" -D"CMAKE_EXE_LINKER_FLAGS=-Wl,--large-address-aware" -D"CMAKE_C_FLAGS=-m32" ../
7171
- mingw32-make install
7272
- Move-Item -Force -path "C:\msys32\mingw32\lib\python3.6\site-packages\*openshot*" -destination "install-x86\python\"
7373
- cp src\libopenshot.dll install-x86\lib

include/FFmpegWriter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ namespace openshot
258258
/// Determine if writer is open or closed
259259
bool IsOpen() { return is_open; };
260260

261+
/// Determine if codec name is valid
262+
static bool IsValidCodec(string codec_name);
263+
261264
/// Open writer
262265
void Open();
263266

src/FFmpegReader.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,18 @@ void FFmpegReader::Open()
156156
if (pCodec == NULL) {
157157
throw InvalidCodec("A valid video codec could not be found for this file.", path);
158158
}
159+
160+
// Init options
161+
AVDictionary *opts = NULL;
162+
av_dict_set(&opts, "strict", "experimental", 0);
163+
159164
// Open video codec
160-
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0)
165+
if (avcodec_open2(pCodecCtx, pCodec, &opts) < 0)
161166
throw InvalidCodec("A video codec was found, but could not be opened.", path);
162167

168+
// Free options
169+
av_dict_free(&opts);
170+
163171
// Update the File Info struct with video details (if a video stream is found)
164172
UpdateVideoInfo();
165173
}
@@ -186,10 +194,18 @@ void FFmpegReader::Open()
186194
if (aCodec == NULL) {
187195
throw InvalidCodec("A valid audio codec could not be found for this file.", path);
188196
}
197+
198+
// Init options
199+
AVDictionary *opts = NULL;
200+
av_dict_set(&opts, "strict", "experimental", 0);
201+
189202
// Open audio codec
190-
if (avcodec_open2(aCodecCtx, aCodec, NULL) < 0)
203+
if (avcodec_open2(aCodecCtx, aCodec, &opts) < 0)
191204
throw InvalidCodec("An audio codec was found, but could not be opened.", path);
192205

206+
// Free options
207+
av_dict_free(&opts);
208+
193209
// Update the File Info struct with audio details (if an audio stream is found)
194210
UpdateAudioInfo();
195211
}

src/FFmpegWriter.cpp

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ void FFmpegWriter::SetOption(StreamType stream, string name, string value)
296296

297297
}
298298

299+
/// Determine if codec name is valid
300+
bool FFmpegWriter::IsValidCodec(string codec_name) {
301+
// Initialize FFMpeg, and register all formats and codecs
302+
av_register_all();
303+
304+
// Find the codec (if any)
305+
if (avcodec_find_encoder_by_name(codec_name.c_str()) == NULL)
306+
return false;
307+
else
308+
return true;
309+
}
310+
299311
// Prepare & initialize streams and open codecs
300312
void FFmpegWriter::PrepareStreams()
301313
{
@@ -990,11 +1002,18 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st)
9901002
if (!codec)
9911003
throw InvalidCodec("Could not find codec", path);
9921004

1005+
// Init options
1006+
AVDictionary *opts = NULL;
1007+
av_dict_set(&opts, "strict", "experimental", 0);
1008+
9931009
// Open the codec
994-
if (avcodec_open2(audio_codec, codec, NULL) < 0)
1010+
if (avcodec_open2(audio_codec, codec, &opts) < 0)
9951011
throw InvalidCodec("Could not open codec", path);
9961012
AV_COPY_PARAMS_FROM_CONTEXT(st, audio_codec);
9971013

1014+
// Free options
1015+
av_dict_free(&opts);
1016+
9981017
// Calculate the size of the input frame (i..e how many samples per packet), and the output buffer
9991018
// TODO: Ugly hack for PCM codecs (will be removed ASAP with new PCM support to compute the input frame size in samples
10001019
if (audio_codec->frame_size <= 1) {
@@ -1061,11 +1080,18 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st)
10611080
if(video_codec->max_b_frames && video_codec->codec_id != AV_CODEC_ID_MPEG4 && video_codec->codec_id != AV_CODEC_ID_MPEG1VIDEO && video_codec->codec_id != AV_CODEC_ID_MPEG2VIDEO)
10621081
video_codec->max_b_frames = 0;
10631082

1083+
// Init options
1084+
AVDictionary *opts = NULL;
1085+
av_dict_set(&opts, "strict", "experimental", 0);
1086+
10641087
/* open the codec */
1065-
if (avcodec_open2(video_codec, codec, NULL) < 0)
1088+
if (avcodec_open2(video_codec, codec, &opts) < 0)
10661089
throw InvalidCodec("Could not open codec", path);
10671090
AV_COPY_PARAMS_FROM_CONTEXT(st, video_codec);
10681091

1092+
// Free options
1093+
av_dict_free(&opts);
1094+
10691095
// Add video metadata (if any)
10701096
for(std::map<string, string>::iterator iter = info.metadata.begin(); iter != info.metadata.end(); ++iter)
10711097
{

src/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ IF (PYTHONLIBS_FOUND)
6262
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/openshot.py DESTINATION ${PYTHON_MODULE_PATH} )
6363

6464
ENDIF(PYTHONINTERP_FOUND)
65-
ENDIF (PYTHONLIBS_FOUND)
65+
ENDIF (PYTHONLIBS_FOUND)

0 commit comments

Comments
 (0)