Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

Subtitle scan of a file on a server waits for playback and reads at a bounded rate (C5)

Veyra Goal Agent3e513c1ebd0e
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 5761d707..4c1c25cc 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -5888,6 +5888,13 @@
"en": "Subtitle's own font",
"ja": "字幕本来のフォント"
},
+ {
+ "zh": "字幕将在视频缓冲好后读取",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "字幕將在影片緩衝好後讀取",
+ "en": "Subtitles will load once the video is buffered",
+ "ja": "動画のバッファーが整ってから字幕を読み込みます"
+ },
{
"zh": "字幕延时 %1 ms",
"src": "src/ui/QmlPlayerBridge.cpp",
diff --git a/include/veyra/engine/Subtitles.h b/include/veyra/engine/Subtitles.h
index c6aeca1e..5237f84a 100644
--- a/include/veyra/engine/Subtitles.h
+++ b/include/veyra/engine/Subtitles.h
@@ -2,6 +2,7 @@
// Shared text and bitmap subtitle loading, including external SUP/VobSub and
// container tracks. Bitmap subtitles retain their authored canvas and palette.
+#include <atomic>
#include <string>
#include <vector>
#include <functional>
@@ -82,9 +83,18 @@ SubtitleTrack loadSubtitleFile(const std::wstring& path);
std::vector<SubtitleTrack> loadExternalSubtitleTracks(const std::wstring& path,std::stop_token stop={},
const std::function<void(const std::vector<SubtitleTrack>&)>& metadata={});
-// Subtitle tracks inside the container (Matroska/MP4/...).
+// Subtitle tracks inside the container (Matroska/MP4/...). `serverGate` is for a
+// file on a server (NAS) that playback is reading too (#48): the scan opens it only
+// once the gate is true, reads it at a bounded rate and stops reading while the gate
+// is false. Null reads the file straight away, as before.
std::vector<SubtitleTrack> loadEmbeddedSubtitleTracks(const std::wstring& path,std::stop_token stop={},
- const std::function<void(const std::vector<SubtitleTrack>&)>& metadata={});
+ const std::function<void(const std::vector<SubtitleTrack>&)>& metadata={},const std::atomic<bool>* serverGate=nullptr);
+
+// True for a file on a server: a UNC path or a drive mapped to a share (media::remoteMediaPath),
+// or any file when VEYRA_TEST_FORCE_REMOTE_PATH is set (tests).
+bool subtitleServerFile(const std::wstring& path);
+// Bytes the server-file subtitle scan has read so far (diagnostics and tests).
+uint64_t subtitleServerScanBytes();
// One worker, one pending source and one published snapshot. Replacing a source
// interrupts its demuxer and prevents stale results from reaching the UI.
@@ -93,6 +103,9 @@ public:
struct Result {uint64_t generation=0;bool complete=false;std::vector<SubtitleTrack> tracks;};
SubtitleLoader();
~SubtitleLoader();
+ // Set before request(). Applies only to files on a server (UNC / mapped drive);
+ // the owner flips it with the state of playback's own buffer. See loadEmbeddedSubtitleTracks.
+ void setReadGate(std::shared_ptr<const std::atomic<bool>> gate);
uint64_t request(std::wstring path);
uint64_t requestFile(std::wstring path);
std::optional<Result> poll();
diff --git a/src/engine/Subtitles.cpp b/src/engine/Subtitles.cpp
index 5ea097fb..566415ba 100644
--- a/src/engine/Subtitles.cpp
+++ b/src/engine/Subtitles.cpp
@@ -1,5 +1,6 @@
#include "veyra/engine/Subtitles.h"
#include "veyra/engine/SubtitleCacheBudget.h"
+#include "veyra/media/NetworkInput.h"
#include <cstdlib>
#include "veyra/Log.h"
@@ -407,14 +408,121 @@ std::vector<uint32_t> SubtitleBitmap::pixels()const{
return result;
}
+// ---------------------------------------------------------------------------------------------
+// A file on a server (UNC share / mapped drive) read by the subtitle scan (#48 C5). Playback reads
+// the same file through the shared demux session, so the scan must not compete with it: the caller
+// opens the file only after playback has its start buffer, every read waits while the gate is false
+// (playback short of data), and reads are paced to a bounded rate. Container demuxers read every
+// block of the file to find subtitle packets, so this is the whole file's worth of traffic.
+// VEYRA_TEST_SLOW_IO=<MB/s>[,<ms per read>] slows it like a slow NAS, as it does for playback.
+// ---------------------------------------------------------------------------------------------
+namespace {
+constexpr double kServerScanMBps=40.0;
+std::atomic<uint64_t> g_serverScanBytes{0};
+bool serverFilePath(const std::wstring& path){
+ static const bool forced=GetEnvironmentVariableW(L"VEYRA_TEST_FORCE_REMOTE_PATH",nullptr,0)>0; // tests: a local file stands in for a NAS
+ return forced||media::remoteMediaPath(path);
+}
+struct ScanAvio {
+ static constexpr int kBuffer=64*1024;
+ HANDLE handle=INVALID_HANDLE_VALUE;AVIOContext* avio=nullptr;
+ const std::atomic<bool>* gate=nullptr;std::stop_token stop;
+ int64_t size=-1;double mbps=kServerScanMBps;int latencyMs=0;int64_t startNs=0;double paced=0;
+ ScanAvio()=default;
+ ScanAvio(const ScanAvio&)=delete;ScanAvio& operator=(const ScanAvio&)=delete;
+ ~ScanAvio(){
+ if(avio){av_freep(&avio->buffer);avio_context_free(&avio);}
+ if(handle!=INVALID_HANDLE_VALUE)CloseHandle(handle);
+ }
+ static int64_t nowNs(){return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();}
+ bool open(const std::wstring& file,const std::atomic<bool>* readGate,std::stop_token token){
+ gate=readGate;stop=std::move(token);
+ handle=CreateFileW(file.c_str(),GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,nullptr,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN,nullptr);
+ if(handle==INVALID_HANDLE_VALUE)return false;
+ LARGE_INTEGER length{};if(GetFileSizeEx(handle,&length))size=length.QuadPart;
+ wchar_t text[64]{};
+ if(const DWORD n=GetEnvironmentVariableW(L"VEYRA_TEST_SLOW_IO",text,64);n>0&&n<64){
+ wchar_t* end=nullptr;const double slow=std::wcstod(text,&end);
+ if(slow>0)mbps=std::min(mbps,slow);
+ if(end&&*end==L',')latencyMs=std::max(0,_wtoi(end+1));
+ }
+ auto* buffer=static_cast<uint8_t*>(av_malloc(kBuffer));
+ if(!buffer)return false;
+ avio=avio_alloc_context(buffer,kBuffer,0,this,&ScanAvio::readPacket,nullptr,&ScanAvio::seek);
+ if(!avio){av_free(buffer);return false;}
+ startNs=nowNs();
+ return true;
+ }
+ // False once the scan is cancelled.
+ bool pause(int ms)const{
+ for(int waited=0;waited<ms;waited+=10){
+ if(stop.stop_requested())return false;
+ Sleep(DWORD(std::min(10,ms-waited)));
+ }
+ return !stop.stop_requested();
+ }
+ bool waitGate()const{
+ while(gate&&!gate->load()){
+ if(stop.stop_requested())return false;
+ Sleep(50);
+ }
+ return !stop.stop_requested();
+ }
+ static int readPacket(void* opaque,uint8_t* buffer,int size){
+ auto& self=*static_cast<ScanAvio*>(opaque);
+ if(!self.waitGate())return AVERROR_EXIT;
+ if(self.latencyMs>0&&!self.pause(self.latencyMs))return AVERROR_EXIT;
+ DWORD got=0;
+ if(!ReadFile(self.handle,buffer,DWORD(std::min(size,kBuffer)),&got,nullptr))return AVERROR(EIO);
+ if(got==0)return AVERROR_EOF;
+ g_serverScanBytes.fetch_add(got);
+ // Pacing: the bytes read so far may not run ahead of the allowed rate; idle time earns at most a second.
+ self.paced+=got;
+ const double allowed=self.paced/(self.mbps*1048576.0);
+ const double elapsed=double(nowNs()-self.startNs)/1e9;
+ if(allowed>elapsed&&!self.pause(int((allowed-elapsed)*1000.0)))return AVERROR_EXIT;
+ if(elapsed>allowed+1.0){self.startNs=nowNs();self.paced=0;}
+ return int(got);
+ }
+ static int64_t seek(void* opaque,int64_t offset,int whence){
+ auto& self=*static_cast<ScanAvio*>(opaque);
+ if(whence&AVSEEK_SIZE)return self.size;
+ whence&=~AVSEEK_FORCE;
+ if(self.latencyMs>0)self.pause(self.latencyMs);
+ LARGE_INTEGER target{},result{};
+ target.QuadPart=offset;
+ const DWORD method=whence==SEEK_SET?FILE_BEGIN:whence==SEEK_CUR?FILE_CURRENT:FILE_END;
+ if(!SetFilePointerEx(self.handle,target,&result,method))return AVERROR(EIO);
+ return result.QuadPart;
+ }
+};
+
+} // namespace
+
static std::vector<SubtitleTrack> loadDemuxedSubtitleTracks(const std::wstring& path,std::stop_token stop,
- const std::function<void(const std::vector<SubtitleTrack>&)>& metadata,const AVInputFormat* format=nullptr){
+ const std::function<void(const std::vector<SubtitleTrack>&)>& metadata,const AVInputFormat* format=nullptr,
+ const std::atomic<bool>* serverGate=nullptr){
std::vector<SubtitleTrack> tracks;
if(stop.stop_requested())return tracks;
const auto started=std::chrono::steady_clock::now();
+ ScanAvio serverFile; // outlives the demuxer below (members are released in reverse order)
+ if(serverGate){
+ // Deferred: the server is not touched until playback has its buffer.
+ while(!serverGate->load()){
+ if(stop.stop_requested())return tracks;
+ Sleep(100);
+ }
+ log::info("subtitle",std::format("server file scan starts (playback buffered) file={} rate<={:.0f}MB/s",
+ utf8(std::filesystem::path(path).filename().wstring()),kServerScanMBps));
+ if(!serverFile.open(path,serverGate,stop)){
+ log::warn("subtitle",std::format("server file open failed file={}",utf8(std::filesystem::path(path).filename().wstring())));
+ return tracks;
+ }
+ }
AVFormatContext* input=avformat_alloc_context();
if(!input)return tracks;
input->interrupt_callback={[](void* opaque){return static_cast<std::stop_token*>(opaque)->stop_requested()?1:0;},&stop};
+ if(serverGate){input->pb=serverFile.avio;input->flags|=AVFMT_FLAG_CUSTOM_IO;}
struct InputCleanup {AVFormatContext*& input;~InputCleanup(){avformat_close_input(&input);}} cleanup{input};
const auto utf8Path=utf8(path);
const int openResult=avformat_open_input(&input,utf8Path.c_str(),format,nullptr);
@@ -646,10 +754,13 @@ static std::vector<SubtitleTrack> loadDemuxedSubtitleTracks(const std::wstring&
}
std::vector<SubtitleTrack> loadEmbeddedSubtitleTracks(const std::wstring& path,std::stop_token stop,
- const std::function<void(const std::vector<SubtitleTrack>&)>& metadata){
- return loadDemuxedSubtitleTracks(path,stop,metadata);
+ const std::function<void(const std::vector<SubtitleTrack>&)>& metadata,const std::atomic<bool>* serverGate){
+ return loadDemuxedSubtitleTracks(path,stop,metadata,nullptr,serverGate);
}
+bool subtitleServerFile(const std::wstring& path){return serverFilePath(path);}
+uint64_t subtitleServerScanBytes(){return g_serverScanBytes.load();}
+
std::vector<SubtitleTrack> loadExternalSubtitleTracks(const std::wstring& path,std::stop_token stop,
const std::function<void(const std::vector<SubtitleTrack>&)>& metadata){
if(stop.stop_requested())return {};
@@ -719,6 +830,7 @@ struct SubtitleLoader::Impl {
bool requested=false;
bool pendingExternal=false;
std::stop_source cancel;
+ std::shared_ptr<const std::atomic<bool>> gate; // see setReadGate
std::optional<Result> ready;
std::jthread worker;
Impl():worker([this](std::stop_token shutdown){
@@ -727,6 +839,7 @@ struct SubtitleLoader::Impl {
if(!wake.wait(lock,shutdown,[&]{return requested;}))break;
const auto path=std::move(pending);const auto id=generation;const auto stop=cancel.get_token();
const bool externalFile=pendingExternal;requested=false;
+ const auto readGate=gate;
lock.unlock();
auto publish=[&](std::vector<SubtitleTrack> tracks,bool complete){
std::lock_guard guard(mutex);
@@ -748,7 +861,9 @@ struct SubtitleLoader::Impl {
external=std::move(tracks);break;
}
if(!external.empty())publish(external,false);
- auto embedded=loadEmbeddedSubtitleTracks(path,stop,[&](const auto& tracks){auto listing=external;listing.insert(listing.end(),tracks.begin(),tracks.end());publish(std::move(listing),false);});
+ // A file on a server that playback is reading too: deferred and paced (#48 C5).
+ const std::atomic<bool>* serverGate=readGate&&serverFilePath(path)?readGate.get():nullptr;
+ auto embedded=loadEmbeddedSubtitleTracks(path,stop,[&](const auto& tracks){auto listing=external;listing.insert(listing.end(),tracks.begin(),tracks.end());publish(std::move(listing),false);},serverGate);
for(auto& track:embedded)external.push_back(std::move(track));
publish(std::move(external),true);
}catch(const std::exception& e){log::error("subtitle",std::format("loader failed: {}",e.what()));publish({},true);}
@@ -758,6 +873,7 @@ struct SubtitleLoader::Impl {
};
SubtitleLoader::SubtitleLoader():p_(std::make_unique<Impl>()){}
SubtitleLoader::~SubtitleLoader()=default;
+void SubtitleLoader::setReadGate(std::shared_ptr<const std::atomic<bool>> gate){std::lock_guard lock(p_->mutex);p_->gate=std::move(gate);}
uint64_t SubtitleLoader::request(std::wstring path){return request(std::move(path),false);}
uint64_t SubtitleLoader::requestFile(std::wstring path){return request(std::move(path),true);}
uint64_t SubtitleLoader::request(std::wstring path,bool external){
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index c5110925..2cb81f62 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -318,6 +318,10 @@ struct QmlPlayerBridge::Impl {
uint64_t playlistSession = 0, playlistCompletedSession = 0;
// --- subtitles (ported from the Win32 shell, same semantics) ---
std::unique_ptr<engine::SubtitleLoader> subLoader;
+ // Embedded-subtitle scan of a file on a server (#48): reads only while playback has its own
+ // buffer. The gate follows the engine's network statistics (tickSubtitles); null for local files.
+ std::shared_ptr<std::atomic<bool>> subScanGate;
+ bool subScanOpen = false;
std::unique_ptr<engine::SubtitleLoader> subFileLoader;
uint64_t subFileGeneration = 0;
std::wstring subFilePath;
@@ -4351,12 +4355,34 @@ void QmlPlayerBridge::refreshSubtitles(const std::wstring& media) {
if (i.subAlignWorker.joinable()) { i.subAlignWorker.request_stop(); i.subAlignWorker = {}; }
i.subAligning = false; i.subAlignReady = false;
if (!i.subLoader) i.subLoader = std::make_unique<engine::SubtitleLoader>();
+ // A file on a server is scanned only while playback has its buffer (#48): a second reader
+ // that takes the same share's bandwidth would starve the picture it is meant to subtitle.
+ const bool server = !media.empty() && engine::subtitleServerFile(media);
+ i.subScanGate = server ? std::make_shared<std::atomic<bool>>(false) : nullptr;
+ i.subScanOpen = false;
+ i.subLoader->setReadGate(i.subScanGate);
+ if (server) i.subStatus = tr("字幕将在视频缓冲好后读取");
i.subGeneration = i.subLoader->request(media);
emit subtitlesChanged();
}
void QmlPlayerBridge::tickSubtitles() {
auto& i = *impl_;
bool changed = false;
+ if (i.subScanGate) {
+ // Opens once playback holds a few seconds ahead (or has read the whole file), closes when
+ // it runs short, and never opens for a server too slow for the stream itself.
+ const auto& n = i.snapshot.network;
+ const bool ended = n.active && n.state == media::NetworkStats::State::Ended;
+ const bool healthy = n.active && !n.bandwidthLow && n.state == media::NetworkStats::State::Playing;
+ const bool open = i.subScanOpen ? (ended || (healthy && n.bufferedSeconds >= 1.0))
+ : (ended || (healthy && n.bufferedSeconds >= 3.0));
+ if (open != i.subScanOpen) {
+ i.subScanOpen = open;
+ i.subScanGate->store(open);
+ veyra::log::info("subtitle", std::format("server scan gate {} (buffer {:.1f}s)", open ? "open" : "closed", n.bufferedSeconds));
+ if (open && i.subStatus == tr("字幕将在视频缓冲好后读取")) { i.subStatus = tr("正在读取字幕"); changed = true; }
+ }
+ }
if (i.subLoader) {
if (auto result = i.subLoader->poll(); result && result->generation == i.subGeneration) {
// Replace the loader's tracks, keep user-loaded files and per-track offsets.
@@ -4368,7 +4394,7 @@ void QmlPlayerBridge::tickSubtitles() {
i.subTracks.insert(i.subTracks.begin() + std::ptrdiff_t(i.subExternal),
std::make_move_iterator(result->tracks.begin()), std::make_move_iterator(result->tracks.end()));
i.subLoaded = count;
- if(result->complete&&i.subStatus==tr("正在读取字幕"))i.subStatus.clear();
+ if(result->complete&&(i.subStatus==tr("正在读取字幕")||i.subStatus==tr("字幕将在视频缓冲好后读取")))i.subStatus.clear();
int firstUsable = -1, firstChinese = -1;
for (size_t k = 0; k < i.subTracks.size(); ++k) {
if (!i.subTracks[k].usable()) continue;
diff --git a/tests/integration/NetworkBufferTests.cpp b/tests/integration/NetworkBufferTests.cpp
index 3a0fac09..7bf89a8e 100644
--- a/tests/integration/NetworkBufferTests.cpp
+++ b/tests/integration/NetworkBufferTests.cpp
@@ -3,6 +3,7 @@
// veyra_network_buffer_tests selftest
// veyra_network_buffer_tests source <path-or-url> <outdir> [key=value ...]
// veyra_network_buffer_tests engine <path-or-url> <outdir> [key=value ...]
+// veyra_network_buffer_tests scan <file> <outdir> [key=value ...] (subtitle scan of a server file)
//
// `source` drives MediaFileSource directly (blocking reads unless nonblocking=1) and writes a per-frame
// CSV (pts, luma hash) for A/B comparisons; `engine` plays through EngineController on a hidden window
@@ -10,6 +11,7 @@
// "RESULT {json}" line the orchestrator (tests/network/run_network_tests.py) parses.
#include "veyra/source/MediaFileSource.h"
#include "veyra/engine/EngineController.h"
+#include "veyra/engine/Subtitles.h"
#include "veyra/media/NetworkInput.h"
#include "veyra/media/NetworkSettings.h"
#include "veyra/Log.h"
@@ -335,16 +337,96 @@ int engineTest(const std::wstring& path, const std::filesystem::path& out, const
return failed ? 1 : 0;
}
+// ---------------------------------------------------------------------------------------------
+// scan: the embedded-subtitle scan of a file on a server (C5). Run with VEYRA_TEST_FORCE_REMOTE_PATH=1
+// (a local file stands in for the NAS) and, to pace it, VEYRA_TEST_SLOW_IO=<MB/s>.
+// - gate closed: nothing may be read or published (closedSeconds, default 3)
+// - gate open: the scan completes; bytes / seconds is the pace
+// - toggle=1: the gate closes closeAfter seconds into the scan; reading must stop and then resume
+int scanTest(const std::wstring& path, const std::filesystem::path& out, const Options& o) {
+ std::filesystem::create_directories(out);
+ Logger::instance().openFile((out / L"scan.log").wstring());
+ Logger::instance().setConsoleEnabled(false);
+ engine::SubtitleLoader loader;
+ auto gate = std::make_shared<std::atomic<bool>>(false);
+ loader.setReadGate(gate);
+ const bool server = engine::subtitleServerFile(path);
+ const uint64_t bytesBefore = engine::subtitleServerScanBytes();
+ loader.request(path);
+ const auto begin = Clock::now();
+ auto since = [&] { return std::chrono::duration<double>(Clock::now() - begin).count(); };
+ uint64_t publishedWhileClosed = 0;
+ const double closedFor = num(o, "closedSeconds", 3);
+ bool complete = false;
+ double completeAt = -1;
+ std::vector<engine::SubtitleTrack> tracks;
+ while (since() < closedFor) {
+ // A local file is not gated: its scan finishes in this window (the control case).
+ if (auto r = loader.poll()) {
+ ++publishedWhileClosed;
+ tracks = std::move(r->tracks);
+ if (r->complete) { complete = true; completeAt = since(); break; }
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(50));
+ }
+ const uint64_t bytesWhileClosed = engine::subtitleServerScanBytes() - bytesBefore;
+ const double openAt = since();
+ gate->store(true);
+ const bool toggle = num(o, "toggle", 0) != 0;
+ const double closeAfter = num(o, "closeAfter", 1.0), closedAgainFor = num(o, "closedAgainSeconds", 2.0);
+ bool closedAgain = false, reopened = false;
+ double closeStart = 0;
+ uint64_t bytesAtClose = 0, bytesWhileClosedAgain = 0, partials = 0;
+ while (!complete && since() < openAt + num(o, "timeout", 120)) {
+ if (auto r = loader.poll()) {
+ tracks = std::move(r->tracks);
+ if (r->complete) { complete = true; completeAt = since(); break; }
+ ++partials;
+ }
+ if (toggle) {
+ if (!closedAgain && since() - openAt >= closeAfter) {
+ closedAgain = true;
+ gate->store(false);
+ std::this_thread::sleep_for(std::chrono::milliseconds(400)); // a read already in flight finishes
+ bytesAtClose = engine::subtitleServerScanBytes();
+ closeStart = since();
+ }
+ if (closedAgain && !reopened && since() - closeStart >= closedAgainFor) {
+ bytesWhileClosedAgain = engine::subtitleServerScanBytes() - bytesAtClose;
+ reopened = true;
+ gate->store(true);
+ }
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
+ }
+ const uint64_t bytesTotal = engine::subtitleServerScanBytes() - bytesBefore;
+ std::error_code ec;
+ const auto fileBytes = std::filesystem::file_size(std::filesystem::path(path), ec);
+ const double scanSeconds = complete ? std::max(0.0, completeAt - (publishedWhileClosed && !server ? 0.0 : openAt)) : -1;
+ std::ostringstream json;
+ json << "{\"serverFile\":" << (server ? "true" : "false") << ",\"publishedWhileClosed\":" << publishedWhileClosed
+ << ",\"bytesWhileClosed\":" << bytesWhileClosed << ",\"complete\":" << (complete ? "true" : "false")
+ << ",\"scanSeconds\":" << scanSeconds << ",\"partialPublishes\":" << partials << ",\"bytesRead\":" << bytesTotal
+ << ",\"fileBytes\":" << (ec ? 0 : fileBytes) << ",\"rateMBps\":" << (scanSeconds > 0 ? bytesTotal / 1048576.0 / scanSeconds : 0.0)
+ << ",\"toggled\":" << (toggle ? "true" : "false") << ",\"bytesWhileClosedAgain\":" << bytesWhileClosedAgain
+ << ",\"tracks\":" << tracks.size() << ",\"cues\":[";
+ for (size_t i = 0; i < tracks.size(); ++i) json << (i ? "," : "") << tracks[i].cues.size();
+ json << "]}";
+ std::cout << "RESULT " << json.str() << std::endl;
+ return complete ? 0 : 1;
+}
+
} // namespace
int wmain(int argc, wchar_t** argv) {
if (argc >= 2 && std::wstring_view(argv[1]) == L"selftest") return selfTest();
if (argc < 4) {
- std::cerr << "usage: selftest | source <path-or-url> <outdir> [k=v...] | engine <path-or-url> <outdir> [k=v...]" << std::endl;
+ std::cerr << "usage: selftest | source|engine|scan <path-or-url> <outdir> [k=v...]" << std::endl;
return 2;
}
const Options options = parseOptions(argc, argv, 4);
if (std::wstring_view(argv[1]) == L"source") return sourceTest(argv[2], argv[3], options);
if (std::wstring_view(argv[1]) == L"engine") return engineTest(argv[2], argv[3], options);
+ if (std::wstring_view(argv[1]) == L"scan") return scanTest(argv[2], argv[3], options);
return 2;
}
diff --git a/tests/network/make_media.py b/tests/network/make_media.py
index 06622f19..e5f52ba0 100644
--- a/tests/network/make_media.py
+++ b/tests/network/make_media.py
@@ -5,6 +5,7 @@
the "huge high-bitrate MKV" a slow server cannot keep up with
av-720p30-60s.mp4 / .mkv small A/V files (synthetic: running timer + one beep per second)
av-720p30-10min.ts 10 minutes of MPEG-TS for the packet-loss runs
+ av-720p30-60s-subs.mkv the 60 s MKV with two embedded SRT tracks (subtitle scan of a NAS-style file)
live-src.ts 20 s loop source for the real-time /live.ts relay
hls/vod, hls/multi HLS playlists + segments (single rendition and three renditions)
@@ -50,6 +51,14 @@ def main():
for name, extra in (('av-720p30-60s.mp4', ['-movflags', '+faststart']), ('av-720p30-60s.mkv', [])):
if not (out / name).exists():
run(common + synthetic + ['-t', '60'] + encode + extra + [out / name])
+ subs = out / 'av-720p30-60s-subs.mkv'
+ if not subs.exists() and (out / 'av-720p30-60s.mkv').exists():
+ for tag, lang in (('a', 'eng'), ('b', 'chi')):
+ lines = [f'{n + 1}\n00:00:{n:02d},100 --> 00:00:{n:02d},900\nline {n + 1} ({lang})\n' for n in range(60)]
+ (out / f'subs-{tag}.srt').write_text('\n'.join(lines), encoding='utf-8')
+ run(common + ['-i', out / 'av-720p30-60s.mkv', '-i', out / 'subs-a.srt', '-i', out / 'subs-b.srt',
+ '-map', '0', '-map', '1', '-map', '2', '-c', 'copy', '-c:s', 'srt',
+ '-metadata:s:s:0', 'language=eng', '-metadata:s:s:1', 'language=chi', subs])
if not (out / 'av-720p30-10min.ts').exists():
run(common + synthetic + ['-t', '600'] + encode + ['-f', 'mpegts', out / 'av-720p30-10min.ts'])
if not (out / 'live-src.ts').exists():