Support WebVtt Text to WebVtt Mp4
Added new path to allow webvtt text input to be written as webvtt mp4. This will happen when the input is a vtt file and the output path is a mp4 path or the output format is mp4. Missing test content for this. Close: 70990714 Change-Id: Idbb4023db4a126a560528e73801f762cc45f4685
This commit is contained in:
parent
c57da2b42d
commit
5d5cb8678d
|
@ -40,6 +40,7 @@
|
||||||
#include "packager/media/formats/webvtt/webvtt_output_handler.h"
|
#include "packager/media/formats/webvtt/webvtt_output_handler.h"
|
||||||
#include "packager/media/formats/webvtt/webvtt_parser.h"
|
#include "packager/media/formats/webvtt/webvtt_parser.h"
|
||||||
#include "packager/media/formats/webvtt/webvtt_segmenter.h"
|
#include "packager/media/formats/webvtt/webvtt_segmenter.h"
|
||||||
|
#include "packager/media/formats/webvtt/webvtt_to_mp4_handler.h"
|
||||||
#include "packager/media/replicator/replicator.h"
|
#include "packager/media/replicator/replicator.h"
|
||||||
#include "packager/media/trick_play/trick_play_handler.h"
|
#include "packager/media/trick_play/trick_play_handler.h"
|
||||||
#include "packager/mpd/base/media_info.pb.h"
|
#include "packager/mpd/base/media_info.pb.h"
|
||||||
|
@ -367,8 +368,8 @@ std::shared_ptr<MediaHandler> CreateEncryptionHandler(
|
||||||
|
|
||||||
Status CreateMp4ToMp4TextJob(const StreamDescriptor& stream,
|
Status CreateMp4ToMp4TextJob(const StreamDescriptor& stream,
|
||||||
const PackagingParams& packaging_params,
|
const PackagingParams& packaging_params,
|
||||||
|
std::unique_ptr<MuxerListener> muxer_listener,
|
||||||
MuxerFactory* muxer_factory,
|
MuxerFactory* muxer_factory,
|
||||||
MuxerListenerFactory* muxer_listener_factory,
|
|
||||||
std::shared_ptr<OriginHandler>* root) {
|
std::shared_ptr<OriginHandler>* root) {
|
||||||
Status status;
|
Status status;
|
||||||
std::shared_ptr<Demuxer> demuxer;
|
std::shared_ptr<Demuxer> demuxer;
|
||||||
|
@ -380,8 +381,6 @@ Status CreateMp4ToMp4TextJob(const StreamDescriptor& stream,
|
||||||
|
|
||||||
std::shared_ptr<MediaHandler> chunker(
|
std::shared_ptr<MediaHandler> chunker(
|
||||||
new ChunkingHandler(packaging_params.chunking_params));
|
new ChunkingHandler(packaging_params.chunking_params));
|
||||||
std::unique_ptr<MuxerListener> muxer_listener =
|
|
||||||
muxer_listener_factory->CreateListener(ToMuxerListenerData(stream));
|
|
||||||
std::shared_ptr<Muxer> muxer =
|
std::shared_ptr<Muxer> muxer =
|
||||||
muxer_factory->CreateMuxer(GetOutputFormat(stream), stream);
|
muxer_factory->CreateMuxer(GetOutputFormat(stream), stream);
|
||||||
muxer->SetMuxerListener(std::move(muxer_listener));
|
muxer->SetMuxerListener(std::move(muxer_listener));
|
||||||
|
@ -442,6 +441,36 @@ Status CreateHlsTextJob(const StreamDescriptor& stream,
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status CreateWebVttToMp4TextJob(const StreamDescriptor& stream,
|
||||||
|
const PackagingParams& packaging_params,
|
||||||
|
std::unique_ptr<MuxerListener> muxer_listener,
|
||||||
|
MuxerFactory* muxer_factory,
|
||||||
|
std::shared_ptr<OriginHandler>* root) {
|
||||||
|
Status status;
|
||||||
|
std::unique_ptr<FileReader> reader;
|
||||||
|
status = FileReader::Open(stream.input, &reader);
|
||||||
|
|
||||||
|
if (!status.ok()) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<OriginHandler> parser(new WebVttParser(std::move(reader)));
|
||||||
|
std::shared_ptr<MediaHandler> text_to_mp4(new WebVttToMp4Handler);
|
||||||
|
std::shared_ptr<MediaHandler> chunker(
|
||||||
|
new ChunkingHandler(packaging_params.chunking_params));
|
||||||
|
std::shared_ptr<Muxer> muxer =
|
||||||
|
muxer_factory->CreateMuxer(GetOutputFormat(stream), stream);
|
||||||
|
muxer->SetMuxerListener(std::move(muxer_listener));
|
||||||
|
|
||||||
|
status.Update(chunker->AddHandler(std::move(muxer)));
|
||||||
|
status.Update(text_to_mp4->AddHandler(std::move(chunker)));
|
||||||
|
status.Update(parser->AddHandler(std::move(text_to_mp4)));
|
||||||
|
|
||||||
|
*root = std::move(parser);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
Status CreateTextJobs(
|
Status CreateTextJobs(
|
||||||
const std::vector<std::reference_wrapper<const StreamDescriptor>>& streams,
|
const std::vector<std::reference_wrapper<const StreamDescriptor>>& streams,
|
||||||
const PackagingParams& packaging_params,
|
const PackagingParams& packaging_params,
|
||||||
|
@ -452,12 +481,32 @@ Status CreateTextJobs(
|
||||||
DCHECK(muxer_listener_factory);
|
DCHECK(muxer_listener_factory);
|
||||||
DCHECK(job_manager);
|
DCHECK(job_manager);
|
||||||
for (const StreamDescriptor& stream : streams) {
|
for (const StreamDescriptor& stream : streams) {
|
||||||
// TODO(70990714): Support webvtt to mp4
|
|
||||||
if (GetOutputFormat(stream) == CONTAINER_MOV) {
|
if (GetOutputFormat(stream) == CONTAINER_MOV) {
|
||||||
|
std::unique_ptr<MuxerListener> muxer_listener =
|
||||||
|
muxer_listener_factory->CreateListener(ToMuxerListenerData(stream));
|
||||||
|
|
||||||
std::shared_ptr<OriginHandler> root;
|
std::shared_ptr<OriginHandler> root;
|
||||||
Status status =
|
Status status;
|
||||||
CreateMp4ToMp4TextJob(stream, packaging_params, muxer_factory,
|
|
||||||
muxer_listener_factory, &root);
|
switch (DetermineContainerFromFileName(stream.input)) {
|
||||||
|
case CONTAINER_WEBVTT:
|
||||||
|
status.Update(CreateWebVttToMp4TextJob(stream, packaging_params,
|
||||||
|
std::move(muxer_listener),
|
||||||
|
muxer_factory, &root));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONTAINER_MOV:
|
||||||
|
status.Update(CreateMp4ToMp4TextJob(stream, packaging_params,
|
||||||
|
std::move(muxer_listener),
|
||||||
|
muxer_factory, &root));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
status.Update(
|
||||||
|
Status(error::INVALID_ARGUMENT,
|
||||||
|
"Text output format is not support for " + stream.input));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!status.ok()) {
|
if (!status.ok()) {
|
||||||
return status;
|
return status;
|
||||||
|
|
Loading…
Reference in New Issue