mifi / lossless-cut

The swiss army knife of lossless video/audio editing
GNU General Public License v2.0
24.01k stars 1.19k forks source link

Using Smart Cut makes Subtitles unsynchronized #2049

Open yFotouh opened 1 week ago

yFotouh commented 1 week ago

The fewer issues I have to read, the more new features I will have time to implement, so I ask that you please try these things first

Operating System

Windows 10

Steps to reproduce

I'm trying to achieve very precise cuts in a video file , and the smart cut feature helped me achieve that , however it made the subtitles unsynchronized. Steps : -Open a video file "vid.mp4" in Lossless cut. -Add video subtitles "subtitles.srt" in tracks section. -Exported Video with subtitles "vid with subtitles.mp4" -File -> close or restart Lossless cut. -Open exported video "vid with subtitles.mp4". -Start making segments to export. -Segments -> Invert all segments on timeline (i mainly want to remove parts from the video) -Export video (Merge Cuts) using Smart Cut feature.

Expected behavior

The final video should have subtitles synchronized

Actual behavior

The final video subtitles are not synchronized using smart cut feature. The subtitles are okay when not using smart cut feature , however without using smart cut , the cuts result are not accurate.

Share log from developer tools

No response

mifi commented 1 week ago

could you share some more information about your file? see the help menu (report an error)

yFotouh commented 1 week ago

Sure. This is the original file information :

No error occurred.

{ "err": false, "state": { "ffmpegExperimental": false, "preserveMovData": false, "movFastStart": true, "preserveMetadataOnMerge": false, "filePath": "...\Monster.Pets.A.Hotel.Transylvania.Short.Film.2021.1080p.WEBRip.x264.AAC5.1-[YTS.MX].mp4", "fileFormat": "mp4", "externalFilesMeta": {}, "mainStreams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "avc1", "codec_tag": "0x31637661", "width": 1920, "height": 1040, "coded_width": 1920, "coded_height": 1040, "closed_captions": 0, "film_grain": 0, "has_b_frames": 2, "sample_aspect_ratio": "255:254", "display_aspect_ratio": "3060:1651", "pix_fmt": "yuv420p", "level": 41, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "true", "nal_length_size": "4", "id": "0x1", "r_frame_rate": "24000/1001", "avg_frame_rate": "24000/1001", "time_base": "1/24000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 8442434, "duration": "351.768083", "bit_rate": "2242581", "bits_per_raw_sample": "8", "nb_frames": "8434", "extradata_size": 53, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "VideoHandler", "vendor_id": "[0][0][0][0]" } }, { "index": 1, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_tag_string": "mp4a", "codec_tag": "0x6134706d", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 6, "channel_layout": "5.1", "bits_per_sample": 0, "initial_padding": 0, "id": "0x2", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/48000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 16885248, "duration": "351.776000", "bit_rate": "384058", "nb_frames": "16492", "extradata_size": 2, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "SoundHandler", "vendor_id": "[0][0][0][0]" } } ], "copyStreamIdsByFile": { "...\Monster.Pets.A.Hotel.Transylvania.Short.Film.2021.1080p.WEBRip.x264.AAC5.1-[YTS.MX].mp4": { "0": true, "1": true } }, "cutSegments": [ {} ], "mainFileFormatData": { "filename": "...\Monster.Pets.A.Hotel.Transylvania.Short.Film.2021.1080p.WEBRip.x264.AAC5.1-[YTS.MX].mp4", "nb_streams": 2, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.000000", "duration": "351.776000", "size": "115735563", "bit_rate": "2632028", "probe_score": 100, "tags": { "major_brand": "isom", "minor_version": "512", "compatible_brands": "isomiso2avc1mp41", "encoder": "Lavf58.67.100" } }, "rotation": 360, "shortestFlag": false, "effectiveExportMode": "merge", "outSegTemplate": "${FILENAME}-${CUT_FROM}-${CUT_TO}${SEG_SUFFIX}${EXT}" }, "platform": "win32", "version": "3.61.1" } ############################################################################ The file info. after adding subtitles and exporting :

No error occurred.

{ "err": false, "state": { "ffmpegExperimental": false, "preserveMovData": false, "movFastStart": true, "preserveMetadataOnMerge": false, "filePath": "...\soft subtitle.mp4", "fileFormat": "mp4", "externalFilesMeta": {}, "mainStreams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "avc1", "codec_tag": "0x31637661", "width": 1920, "height": 1040, "coded_width": 1920, "coded_height": 1040, "closed_captions": 0, "film_grain": 0, "has_b_frames": 2, "sample_aspect_ratio": "255:254", "display_aspect_ratio": "3060:1651", "pix_fmt": "yuv420p", "level": 41, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "true", "nal_length_size": "4", "id": "0x1", "r_frame_rate": "24000/1001", "avg_frame_rate": "24000/1001", "time_base": "1/24000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 8442434, "duration": "351.768083", "bit_rate": "2242581", "bits_per_raw_sample": "8", "nb_frames": "8434", "extradata_size": 53, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "VideoHandler", "vendor_id": "[0][0][0][0]" } }, { "index": 1, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_tag_string": "mp4a", "codec_tag": "0x6134706d", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 6, "channel_layout": "5.1", "bits_per_sample": 0, "initial_padding": 0, "id": "0x2", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/48000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 16885248, "duration": "351.776000", "bit_rate": "384011", "nb_frames": "16492", "extradata_size": 2, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "SoundHandler", "vendor_id": "[0][0][0][0]" } }, { "index": 2, "codec_name": "mov_text", "codec_long_name": "MOV text", "codec_type": "subtitle", "codec_tag_string": "tx3g", "codec_tag": "0x67337874", "id": "0x3", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 350759000, "duration": "350.759000", "bit_rate": "57", "nb_frames": "98", "extradata_size": 68, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "SubtitleHandler" } } ], "copyStreamIdsByFile": { "...\soft subtitle.mp4": { "0": true, "1": true, "2": true } }, "cutSegments": [ { "start": 0, "end": 60 }, { "start": 120, "end": 180 }, { "start": 240, "end": 351.776 } ], "mainFileFormatData": { "filename": "...\soft subtitle.mp4", "nb_streams": 3, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.000000", "duration": "351.776000", "size": "115741215", "bit_rate": "2632157", "probe_score": 100, "tags": { "major_brand": "isom", "minor_version": "512", "compatible_brands": "isomiso2avc1mp41", "encoder": "Lavf60.3.100" } }, "rotation": 360, "shortestFlag": false, "effectiveExportMode": "merge", "outSegTemplate": "${FILENAME}-${CUT_FROM}-${CUT_TO}${SEG_SUFFIX}${EXT}" }, "platform": "win32", "version": "3.61.1" }

############################################################################ The file info. after cutting and merging the last exported file with subtitles :

No error occurred.

{ "err": false, "state": { "ffmpegExperimental": false, "preserveMovData": false, "movFastStart": true, "preserveMetadataOnMerge": false, "filePath": "...\cut with subtitle.mp4", "fileFormat": "mp4", "externalFilesMeta": {}, "mainStreams": [ { "index": 0, "codec_name": "h264", "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "profile": "High", "codec_type": "video", "codec_tag_string": "avc1", "codec_tag": "0x31637661", "width": 1920, "height": 1040, "coded_width": 1920, "coded_height": 1040, "closed_captions": 0, "film_grain": 0, "has_b_frames": 2, "sample_aspect_ratio": "255:254", "display_aspect_ratio": "3060:1651", "pix_fmt": "yuv420p", "level": 41, "color_range": "tv", "color_space": "bt709", "color_transfer": "bt709", "color_primaries": "bt709", "chroma_location": "left", "field_order": "progressive", "refs": 1, "is_avc": "true", "nal_length_size": "4", "id": "0x1", "r_frame_rate": "24000/1001", "avg_frame_rate": "22240000/927623", "time_base": "1/24000", "start_pts": 1008, "start_time": "0.042000", "duration_ts": 5565738, "duration": "231.905750", "bit_rate": "2029787", "bits_per_raw_sample": "8", "nb_frames": "5560", "extradata_size": 53, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "VideoHandler", "vendor_id": "[0][0][0][0]" } }, { "index": 1, "codec_name": "aac", "codec_long_name": "AAC (Advanced Audio Coding)", "profile": "LC", "codec_type": "audio", "codec_tag_string": "mp4a", "codec_tag": "0x6134706d", "sample_fmt": "fltp", "sample_rate": "48000", "channels": 6, "channel_layout": "5.1", "bits_per_sample": 0, "initial_padding": 0, "id": "0x2", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/48000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 11133858, "duration": "231.955375", "bit_rate": "384024", "nb_frames": "10874", "extradata_size": 2, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "SoundHandler", "vendor_id": "[0][0][0][0]" } }, { "index": 2, "codec_name": "mov_text", "codec_long_name": "MOV text", "codec_type": "subtitle", "codec_tag_string": "tx3g", "codec_tag": "0x67337874", "id": "0x3", "r_frame_rate": "0/0", "avg_frame_rate": "0/0", "time_base": "1/1000000", "start_pts": 0, "start_time": "0.000000", "duration_ts": 237742375, "duration": "237.742375", "bit_rate": "52", "nb_frames": "73", "extradata_size": 108, "disposition": { "default": 1, "dub": 0, "original": 0, "comment": 0, "lyrics": 0, "karaoke": 0, "forced": 0, "hearing_impaired": 0, "visual_impaired": 0, "clean_effects": 0, "attached_pic": 0, "timed_thumbnails": 0, "captions": 0, "descriptions": 0, "metadata": 0, "dependent": 0, "still_image": 0 }, "tags": { "language": "und", "handler_name": "SubtitleHandler" } } ], "copyStreamIdsByFile": { "...\cut with subtitle.mp4": { "0": true, "1": true, "2": true } }, "cutSegments": [ {} ], "mainFileFormatData": { "filename": "...\cut with subtitle.mp4", "nb_streams": 3, "nb_programs": 0, "format_name": "mov,mp4,m4a,3gp,3g2,mj2", "format_long_name": "QuickTime / MOV", "start_time": "0.000000", "duration": "231.955375", "size": "70136865", "bit_rate": "2418977", "probe_score": 100, "tags": { "major_brand": "isom", "minor_version": "512", "compatible_brands": "isomiso2avc1mp41", "encoder": "Lavf60.3.100" } }, "rotation": 360, "shortestFlag": false, "effectiveExportMode": "merge", "outSegTemplate": "${FILENAME}-${CUT_FROM}-${CUT_TO}${SEG_SUFFIX}${EXT}" }, "platform": "win32", "version": "3.61.1" }

########################### Note that i have removed the file full path from the json.

mifi commented 1 week ago

Thanks. I don't see anything odd about the file, so it could be a bug in the experimental smart cut code. I've added it here #126

yFotouh commented 1 week ago

Great. Good luck.