From 053f6605739c0c6b33fa7ac5cb7eebc47ccd8fd9 Mon Sep 17 00:00:00 2001 From: rigaya Date: Thu, 4 May 2023 13:17:42 +0900 Subject: [PATCH] =?UTF-8?q?mp4box=E3=81=A7=E3=81=AEmux=E6=99=82=E3=80=81in?= =?UTF-8?q?-place=20editing=E3=82=92=E8=A1=8C=E3=82=8F=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=A6mux=E3=82=92?= =?UTF-8?q?=E9=AB=98=E9=80=9F=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Amatsukaze/Muxer.hpp | 7 ++++--- Amatsukaze/TranscodeSetting.hpp | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Amatsukaze/Muxer.hpp b/Amatsukaze/Muxer.hpp index 3cee100..b996b77 100644 --- a/Amatsukaze/Muxer.hpp +++ b/Amatsukaze/Muxer.hpp @@ -189,7 +189,8 @@ class AMTMuxder : public AMTObject { } } - tstring tmpOutPath = setting_.getVfrTmpFilePath(key, muxFormat); + const tstring tmpOut1Path = setting_.getVfrTmpFile1Path(key, muxFormat); + const tstring tmpOut2Path = setting_.getVfrTmpFile2Path(key, muxFormat); tstring metaFile; if (muxFormat == FORMAT_M2TS || muxFormat == FORMAT_TS) { @@ -240,7 +241,7 @@ class AMTMuxder : public AMTObject { setting_.getTimelineEditorPath(), setting_.getMp4BoxPath(), encVideoFile, encoderOutputInContainer(setting_.getEncoder(), muxFormat), vfmt, audioFiles, - outPath, tmpOutPath, chapterFile, + outPath, tmpOut1Path, tmpOut2Path, chapterFile, fileOut.timecode, timebase, subsFiles, subsTitles, metaFile); for (int i = 0; i < (int)args.size(); ++i) { @@ -301,7 +302,7 @@ class AMTSimpleMuxder : public AMTObject { setting_.getMuxerPath(), setting_.getTimelineEditorPath(), setting_.getMp4BoxPath(), encVideoFile, encoderOutputInContainer(setting_.getEncoder(), setting_.getFormat()), videoFormat, audioFiles, outFilePath, - tstring(), tstring(), tstring(), std::pair(), + tstring(), tstring(), tstring(), tstring(), std::pair(), std::vector(), std::vector(), tstring()); ctx.info("[Mux開始]"); ctx.infoF("%s", args[0].first); diff --git a/Amatsukaze/TranscodeSetting.hpp b/Amatsukaze/TranscodeSetting.hpp index 753c407..a388257 100644 --- a/Amatsukaze/TranscodeSetting.hpp +++ b/Amatsukaze/TranscodeSetting.hpp @@ -312,7 +312,8 @@ static std::vector> makeMuxerArgs( const VideoFormat& videoFormat, const std::vector& inAudios, const tstring& outpath, - const tstring& tmpoutpath, + const tstring& tmpout1path, + const tstring& tmpout2path, const tstring& chapterpath, const tstring& timecodepath, std::pair timebase, @@ -330,7 +331,7 @@ static std::vector> makeMuxerArgs( bool needTimecode = (timecodepath.size() > 0); bool needSubs = (inSubs.size() > 0); - tstring dst = needTimecode ? tmpoutpath : outpath; + tstring dst = (needTimecode || needChapter || needSubs) ? tmpout1path : outpath; #if 0 // まずはmuxerで映像、音声、チャプターをmux if (videoFormat.fixedFrameRate) { @@ -384,6 +385,7 @@ static std::vector> makeMuxerArgs( sb.clear(); if (needTimecode) { + tstring timelineeditorout = (needChapter || needSubs) ? tmpout2path : outpath; // 必要ならtimelineeditorでtimecodeを埋め込む sb.append(_T("\"%s\""), timelineeditorpath) .append(_T(" --track 1")) @@ -391,15 +393,17 @@ static std::vector> makeMuxerArgs( .append(_T(" --media-timescale %d"), timebase.first) .append(_T(" --media-timebase %d"), timebase.second) .append(_T(" \"%s\""), dst) - .append(_T(" \"%s\""), outpath); + .append(_T(" \"%s\""), timelineeditorout); ret.push_back(std::make_pair(sb.str(), false)); sb.clear(); needTimecode = false; + dst = timelineeditorout; } if (needChapter || needSubs) { // 字幕とチャプターを埋め込む sb.append(_T("\"%s\" -brand mp42 -ab mp41 -ab iso2"), mp4boxpath); + sb.append(_T(" -add \"%s\""), dst); for (int i = 0; i < (int)inSubs.size(); ++i) { if (subsTitles[i] == _T("SRT")) { // mp4はSRTのみ sb.append(_T(" -add \"%s#:name=%s\""), inSubs[i], subsTitles[i]); @@ -411,7 +415,7 @@ static std::vector> makeMuxerArgs( sb.append(_T(" -chap \"%s\""), chapterpath); needChapter = false; } - sb.append(_T(" \"%s\""), outpath); + sb.append(_T(" -new \"%s\""), outpath); ret.push_back(std::make_pair(sb.str(), true)); sb.clear(); } @@ -1079,8 +1083,13 @@ class ConfigWrapper : public AMTObject tmpDir.path(), key.video, key.format, key.div, GetCMSuffix(key.cm), GetNicoJKSuffix(type))); } - tstring getVfrTmpFilePath(EncodeFileKey key, ENUM_FORMAT format) const { - return regtmp(StringFormat(_T("%s/t%d-%d-%d%s.%s"), + tstring getVfrTmpFile1Path(EncodeFileKey key, ENUM_FORMAT format) const { + return regtmp(StringFormat(_T("%s/t1%d-%d-%d%s.%s"), + tmpDir.path(), key.video, key.format, key.div, GetCMSuffix(key.cm), getOutputExtention(format))); + } + + tstring getVfrTmpFile2Path(EncodeFileKey key, ENUM_FORMAT format) const { + return regtmp(StringFormat(_T("%s/t2%d-%d-%d%s.%s"), tmpDir.path(), key.video, key.format, key.div, GetCMSuffix(key.cm), getOutputExtention(format))); }