Reputation: 2072
I have a script that fetches multiple chunks of a video from one place and streams it as a single video to other place (to Kodi player).
Everything seems to work fine except one thing that bothers me, the player doesn't seem to know how long the video is, therefore the total duration increments as the video plays.
I do know the duration of the video from an xml file that contains a link to all the chunks, but I don't know how to write that in the metadata of the first chunk.
The video codec is h264, but I'm not sure if it is wrapped in some container, like mp4.
Here is the ffmpeg -i
output for the first chunk:
ffmpeg version 3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 8.0.0 (clang-800.0.38)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.1.5 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --disable-lzma --enable-vda
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
[mpegts @ 0x7fc3c6000000] start time for stream 0 is not set in estimate_timings_from_pts
Input #0, mpegts, from '/Users/ibra/Desktop/daTgXic4JOI.ts':
Duration: 00:00:17.56, start: 0.000000, bitrate: 1220 kb/s
Program 1
Stream #0:0[0x102]: Data: timed_id3 (ID3 / 0x20334449)
Stream #0:1[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:2[0x101]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 150 kb/s
And here is a messy screenshot of the file opened in a hex editor: https://www.evernote.com/l/AWlILw5PcmVEl4fSFitOfS2M8Wzy1WTVSZc
Any suggestions of how to insert the video duration in the metadata of the first chunk?
I cannot download the all the chunks and then concat in a single file because this will take too much time and the streaming must be instantly.
Upvotes: 1
Views: 2014
Reputation: 31150
The container format is mpegts. There is no standard way to encode a duration in mpegts (or h.264 for that matter). So whatever you do will be proprietary. You could write it to the ID3 metaadata, but then kodi would need to be modified to handle this.
Upvotes: 3