The transmuxer now fully support Dash.

This commit is contained in:
Zoe Roux 2019-11-11 21:35:16 +01:00
parent 2bbd1bf81c
commit 9825336146
2 changed files with 8 additions and 7 deletions

View File

@ -54,11 +54,11 @@ int transmux(const char *path, const char *out_path, const char *stream_uri)
av_dump_format(out_ctx, 0, out_path, true);
//std::string val = (std::string)stream_uri + (std::string)"init-stream$RepresentationID$.m4s";
//av_dict_set(&options, "dirname", val.c_str(), 0);
//av_dict_set(&options, "init_seg_name", val.c_str(), 0);
//val = (std::string)stream_uri + (std::string)"chunk-stream$RepresentationID$-$Number%05d$.m4s";
//av_dict_set(&options, "media_seg_name", val.c_str(), 0);
std::filesystem::create_directory(((std::string)out_path).substr(0, strrchr(out_path, '/') - out_path).append("/dash/"));
av_dict_set(&options, "init_seg_name", "dash/init-stream$RepresentationID$.m4s", 0);
av_dict_set(&options, "media_seg_name", "dash/chunk-stream$RepresentationID$-$Number%05d$.m4s", 0);
av_dict_set(&options, "streaming", "1", 0);
if (open_output_file_for_write(out_ctx, out_path, &options) != 0)
return 1;
@ -80,11 +80,12 @@ int transmux(const char *path, const char *out_path, const char *stream_uri)
av_packet_unref(&pkt);
}
av_dict_free(&options);
av_write_trailer(out_ctx);
avformat_close_input(&in_ctx);
if (out_ctx && !(out_ctx->oformat->flags & AVFMT_NOFILE))
avio_closep(&out_ctx->pb);
avio_close(out_ctx->pb);
avformat_free_context(out_ctx);
delete[] stream_map;

View File

@ -48,7 +48,7 @@ constexpr enum AVRounding operator |(const enum AVRounding a, const enum AVRound
int open_output_file_for_write(AVFormatContext *out_ctx, const char *out_path, AVDictionary **options)
{
if (!(out_ctx->flags & AVFMT_NOFILE))
if (!(out_ctx->oformat->flags & AVFMT_NOFILE))
{
if (avio_open(&out_ctx->pb, out_path, AVIO_FLAG_WRITE) < 0)
{