Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyway to set custom-name using "-segment-timeline" #2855

Closed
Jain2098 opened this issue Jun 2, 2024 · 6 comments
Closed

Anyway to set custom-name using "-segment-timeline" #2855

Jain2098 opened this issue Jun 2, 2024 · 6 comments

Comments

@Jain2098
Copy link

Jain2098 commented Jun 2, 2024

I am using Python on Windows 11 with Stable version of GPAC. I am having these warning continuously through out the code.:

[Dasher] First CTS 61560 in segment 12 drifting by -4.44 (more than half a segment duration) from segment time, consider reencoding or using segment timeline
[Dasher] First CTS 32048 in segment 7 drifting by -3.952 (more than half a segment duration) from segment time, consider reencoding or using segment timeline
[Dasher] First CTS 38533 in segment 8 drifting by -3.467 (more than half a segment duration) from segment time, consider reencoding or using segment timeline

If I use "-segment-timeline" I can't use "-segment-name" with custom name format. Using "-segment-name", makes the above error gone. Also when I play it via VLC Player I see this error at beginning of start of the video:

mp4 warning: elst box found
mp4 warning: no chunk defined
mp4 warning: STTS table of 0 entries
mp4 warning: STTS table of 24 entries
mp4 warning: that media doesn't look interleaved, will need to seek
mp4 info: Fragment sequence discontinuity detected 1 != 0
mp4 warning: no chunk defined
mp4 warning: STTS table of 0 entries
mp4 warning: STTS table of 24 entries
mp4 warning: that media doesn't look interleaved, will need to seek
mp4 info: Fragment sequence discontinuity detected 1 != 0
mp4 warning: elst box found
mp4 warning: no chunk defined
mp4 warning: STTS table of 0 entries
mp4 warning: STTS table of 24 entries
mp4 warning: that media doesn't look interleaved, will need to seek
mp4 info: Fragment sequence discontinuity detected 1 != 0
avcodec info: Using D3D11VA (Intel(R) HD Graphics 620, vendor 8086(Intel), device 5916, revision 2) for hardware decoding
faad warning: decoded zero sample

#Update
Now I am trying to ReEncode every video:
Will below config would be best for Mp4Box dash

video_bitrate = {480: "350k", 720: "900k", 1080: "1800k"}
audio_bitrate = {480: "96k", 720: "128k", 1080: "192k"}
key_int = int(self.video_avg_frame_rate * 3) # Calculate keyint for 6-second segments
Video Command:

[
                os.path.join(BIN_DIR, "ffmpeg"),
                "-i", self.original_file_location,
                "-c:v", "libx264",
                "-preset", "slow",
                "-crf", "23",
                "-b:v", video_bitrate.get(res, "500k"),
                "-an",  # No Audio
                "-sn",  # No Subtitle
                "-movflags", "faststart",
                "-x264opts", f"keyint={key_int}:min-keyint={key_int}:no-scenecut",
                "-vf", f"scale=-2:{res}",
                "-f", "mp4",
                "-y",
                output_video
]

Audio:

[
                    os.path.join(BIN_DIR, "ffmpeg"),
                    "-i", self.original_file_location,
                    "-map", f"0:{track['id']}",
                    "-c:a", "aac",
                    "-b:a", audio_bitrate.get(res, '96k'),
                    "-ac", "2",
                    "-t", str(video_duration_TEMP),
                    "-shortest",
                    "-ar", "48000",
                    "-movflags", "faststart",
                    "-profile:a", "aac_low", 
                    "-strict", "experimental",
                    "-y",
                    output_audio
]

Subtitles:

[
                        os.path.join(BIN_DIR, "ffmpeg"),
                        "-i", self.original_file_location,
                        "-map", f"0:{track['id']}",
                        "-c:s", "srt",
                        "-t", str(video_duration_TEMP),
                        "-y",
                        output_subtitle
]

I am having another issue that:, while inspecting chunks, I get this warning:

mp4box -info .\vid0_1.m4s
[iso file] Movie fragment but no moov (yet) - possibly broken parsing!
File is a segment - 1 movie fragments - Brand msdh (version 0):
Fragment #1 size 1549569 (moof 2088) {TKID 1 TFDT 608560}

I tried everything but I am unable to add this moov details into segments. Is it okay that segment not to have moov info?

Here is the config that i am using. Please guide me if anything wrong and what improvement i can do. I tried to use onDemand but it won't create chunks so I currently stick to main profile as using chunks is mainly needed.
split_command:
[
'C:/Program Files/GPAC/mp4box.exe',
'-dash', '6000',
'-frag', '6000',
'-rap',
'-bound',
'-profile', 'main',
'-segment-ext', 'm4s',
'-segment-name', '$RepresentationID$_$Number$',
'-out', '/manifest.mpd',
'-url-template',
'c9757e84318e.mkv#video:id=vid0:lang=und',
'c9757e84318e.mkv#1:id=aud0:lang=hin',
'c9757e84318e.mkv#2:id=sub0:lang=eng',
'c9757e84318e.mkv#3:id=sub1:lang=eng'
]

Any kind of help is greatly appreciated.
Thank You. 😊

@Jain2098 Jain2098 changed the title Any way to set custom-name while using "-segment-timeline" Anyway to set custom-name using "-segment-timeline" and fix "no moov (yet)" Issue Jun 2, 2024
@Jain2098 Jain2098 changed the title Anyway to set custom-name using "-segment-timeline" and fix "no moov (yet)" Issue Anyway to set custom-name using "-segment-timeline" and "no moov (yet)" Issue Jun 3, 2024
@Jain2098 Jain2098 changed the title Anyway to set custom-name using "-segment-timeline" and "no moov (yet)" Issue Anyway to set custom-name using "-segment-timeline" Jun 3, 2024
@Jain2098
Copy link
Author

Jain2098 commented Jun 3, 2024

Post content updated as Now I am doing Re-Encode to fix all unsupported codec issues in browser.

@rbouqueau
Copy link
Member

For the error messages I would have suspected that your sync points are not regular. However your FFmpeg command-line seems fine. Can you upload an 'output_video' file here?

 [iso file] Movie fragment but no moov (yet) - possibly broken parsing!

That's because the 'moov' box is contained in the init segment. Add the -initseg=INIT_FILENAME to your command-line.

@Jain2098
Copy link
Author

Jain2098 commented Jun 3, 2024

I am having weird issue, no matter how I encode with FFMPEG, Mp4Box keep giving error due to audio.
This file is a .mkv file with dual audio file with one subtitle. As in testing I am Re-encoding the file as 360p using FFMPEG. mkv to mp4 with all audio conversion to aac and subtitle to vtt format.

File Link: https://gofile.io/d/PHZTV7

Original File:

Input #0, matroska,webm, from '.\898b4ad5-a8a0-44d6-a6eb-d8d9fc44db3a.mkv':
Metadata:
title : DEVENU [OMNiRiPs]
ENCODER : Lavf61.3.104
Duration: 00:04:09.86, start: 0.000000, bitrate: 1555 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 1k tbn (default)
Metadata:
title : DEVENU [x264]
BPS : 1293485
NUMBER_OF_FRAMES: 5995
NUMBER_OF_BYTES : 40387779
_STATISTICS_WRITING_APP: mkvmerge v77.0 ('Elemental') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2023-07-01 17:15:20
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:04:09.791000000
Stream #0:1(eng): Audio: eac3, 48000 Hz, 5.1(side), fltp, 192 kb/s (default)
Metadata:
title : DEVENU [DD+ 5.1 - 192kbps]
BPS : 192000
NUMBER_OF_FRAMES: 7807
NUMBER_OF_BYTES : 5995776
_STATISTICS_WRITING_APP: mkvmerge v77.0 ('Elemental') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2023-07-01 17:15:20
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:04:09.824000000
Stream #0:2(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : DEVENU [AAC 2.0 - 64kbps]
BPS : 64000
NUMBER_OF_FRAMES: 11712
NUMBER_OF_BYTES : 1998849
_STATISTICS_WRITING_APP: mkvmerge v77.0 ('Elemental') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2023-07-01 17:15:20
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:04:09.855000000
Stream #0:3(eng): Subtitle: subrip (default)
Metadata:
title : DEVENU
BPS : 28
NUMBER_OF_FRAMES: 50
NUMBER_OF_BYTES : 734
_STATISTICS_WRITING_APP: mkvmerge v77.0 ('Elemental') 64-bit
_STATISTICS_WRITING_DATE_UTC: 2023-07-01 17:15:20
_STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
DURATION : 00:03:27.417000000

FFMPEG Command

video:
['ffmpeg', '-i', 'original_file.mkv', '-c:v', 'libx264', '-preset', 'slow', '-crf', '23', '-b:v', '500k', '-an', '-sn', '-movflags', 'faststart', '-x264opts', 'keyint=72:min-keyint=72:no-scenecut', '-vf', 'scale=-2:360', '-f', 'mp4', '-y', 'output_file.mp4']

Audio:
['ffmpeg', '-i', 'original_file.mkv', '-map', '0:1', '-c:a', 'aac', '-b:a', '96k', '-ac', '2', '-shortest', '-ar', '48000', '-y', '1.eng.aac']
also used used "-t" "video_duration" but same issue.

when checking Audio using FFPROBE After conversion, its like this:

2.eng.aac':
Duration: 01:21:11.94, bitrate: 5 kb/s
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 5 kb/s

1.eng.aac':
Duration: 00:07:12.98, bitrate: 57 kb/s
Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 57 kb/s

Duration is invalid but when played it play exact the video length.

Mp4Box Command:

[
MP4BOX_PATH,
"-dash", "3000",
"-frag", "3000",
"-profile", "main",
"-segment-name", segment_path_template,
"-rap",
"-bound",
"-segment-ext", "null",
"-segment-timeline",
"-out", manifest_name,
"-url-template",
video_command
] + audio_commands + subtitle_commands

Error Code:

2024-06-03 05:59:51,389 - DEBUG - result: False
2024-06-03 05:59:51,389 - ERROR - Error during video split: 'bool' object has no attribute 'returncode'
Error: Command '['C:/Program Files/GPAC/mp4box.exe', '-dash', '3000', '-frag', '3000', '-profile', 'main', '-segment-name', '$RepresentationID$_$Number$', '-rap', '-bound', '-segment-ext', 'null', '-segment-timeline', '-out', 'D:/FastApi Projects/dash/uploads/processed/a7866ede-7a95-4ff8-af6d-6b040a93dbf3/360/manifest.mpd', '-url-template', 'D:/FastApi Projects/dash/uploads/encoded/a7866ede-7a95-4ff8-af6d-6b040a93dbf3/360/video/360.mp4:id=vid0:role=main:lang=eng', 'D:/FastApi Projects/dash/uploads/encoded/a7866ede-7a95-4ff8-af6d-6b040a93dbf3/360/audio/1.eng.aac:id=aud0:role=main:lang=eng', 'D:/FastApi Projects/dash/uploads/encoded/a7866ede-7a95-4ff8-af6d-6b040a93dbf3/360/audio/2.eng.aac:id=aud1:role=main:lang=eng']' returned non-zero exit status 3221225477.

@rbouqueau
Copy link
Member

This is unreadable. It looks like you dumped some Python into the issue.

I can't see the MP4Box error in here. Could you post the full log please? Or confirm which error you see?

Btw I confirm something is indeed incorrect in GPAC with your input file. The DASHing seems to timeout and I tried to inspect it to a limited avail:

$ MP4Box -info testing_dual_audio.mkv -logs=all@warning
[FFDmx] No PTS for packet on stream 4
Filter ffdmx failed to setup: Feature Not Supported
[Importer] Error probing testing_dual_audio.mkv
Error probing file testing_dual_audio.mkv: Feature Not Supported

        Error: Feature Not Supported

and

$ gpac -i testing_dual_audio.mkv inspect
[FFDmx] No PTS for packet on stream 4
[RFC6381] Incomplete upstream-filter 'colr' information. Ignoring.
PID 5 video duration 04:09.856 timescale 90000 1765x995 fps 90000 SAR 1/1 codec mp4v.6D PNG Image
[RFC6381] Incomplete upstream-filter 'colr' information. Ignoring.
PID 2 audio language "eng" duration 04:09.856 timescale 1000 48000 Hz 3/2.1 chan 192 kbps codec ec-3 Enhanced AC3 Audio
[RFC6381] Incomplete upstream-filter 'colr' information. Ignoring.
PID 3 audio language "eng" duration 04:09.856 timescale 1000 48000 Hz stereo chan codec mp4a.40.2 AAC LC (aot=2 implicit)
PID 1 video language "eng" duration 04:09.856 timescale 1000 delay -82 1280x720 fps 24 SAR 1/1 codec avc1.640028 AVC|H264 PL High@4 YUV 4:2:0 8 bpp
Filter txtin failed to setup: Feature Not Supported
session last connect error Feature Not Supported

@jeanlf
Copy link
Member

jeanlf commented Jun 4, 2024

The setup failure is a recent regression on mkv file using srt , fixed in master

The dash messages came from a broken signaling of PID delay in ffdmx resulting in the first GOP being less than 2sec in presentation time, now also fixed.

If I use "-segment-timeline" I can't use "-segment-name" with custom name format.

These are unrelated, probably a mistake in your command line. Could you post it ?

@jeanlf
Copy link
Member

jeanlf commented Jul 4, 2024

No follow-up on side question and main issue fixed, closing. If you can reproduce your segment naming problem, please open a new issue.

@jeanlf jeanlf closed this as completed Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants