forked from facebookarchive/360-Capture-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFLVmuxer.cpp
63 lines (50 loc) · 1.95 KB
/
FLVmuxer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include "FLVmuxer.h"
namespace FBCapture {
namespace Mux {
FLVMuxer::FLVMuxer() {}
FLVMuxer::~FLVMuxer() {
remove(videoFile_.c_str()); // Remove h264 video file
remove(audioFile_.c_str()); // Remove aac audio file
}
string FLVMuxer::changeFormatString(const string& path, const string& oldFormat, const string& newFormat) {
string newPath(path);
newPath.erase(path.length() - oldFormat.length(), oldFormat.length());
newPath += newFormat;
return newPath;
}
FBCAPTURE_STATUS FLVMuxer::muxingMedia(const wstring& videoFile, const string& audioFile, float fps) {
FBCAPTURE_STATUS status = FBCAPTURE_STATUS_OK;
string outputfile;
const string newformat = "flv";
const string oldFormat = "h264";
uint32_t nErrorCode = 0;
wstring_convert<std::codecvt_utf8<wchar_t>> stringTypeConversion;
videoFile_ = stringTypeConversion.to_bytes(videoFile);
audioFile_ = audioFile;
outputfile = changeFormatString(videoFile_, oldFormat, newformat);
nErrorCode = flvmuxAVStreams(audioFile_.c_str(),
videoFile_.c_str(),
outputfile.c_str(),
0.0f,
0.0f,
NO_DURATION_SPECIFIED,
fps);
if (0 != nErrorCode) {
DEBUG_ERROR_VAR("Muxing failed. [Error code] ", to_string(nErrorCode));
status = FBCAPTURE_STATUS_WAMDEIA_MUXING_FAILED;
}
remove(videoFile_.c_str()); // Remove h264 video file
remove(audioFile_.c_str()); // Remove aac audio file
return status;
}
}
}