mifi / lossless-cut

The swiss army knife of lossless video/audio editing
https://losslesscut.app/
GNU General Public License v2.0
25.98k stars 1.25k forks source link

Thumbnail track not attached as cover #2062

Open niwazukihon opened 2 months ago

niwazukihon commented 2 months 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 11

Steps to reproduce

Cut a mp4 file with 3 tracks. One of them has a codec of mjpeg or png with "disposition" being attached_pic.

Export. The app shows a warning of "Cutting thumbnail tracks is known to cause problems".

Expected behavior

I expect either (1) an output file with 2 tracks (video+audio) and a metadata cover of that 3rd track image. Or,

(2) an output file with 3 tracks where the "thumbnail track" is cut to the duration of the output file.

Actual behavior

I got a file with 2 tracks (video+audio) and no metadata cover. The thumbnail/cover information seems to be lost.

I searched that warning but find nothing elaborating it. What are the problems that can be caused by cutting the thumbnail track? Is there an issue already to track this problem?

It seems that it should be straightforward? For example maybe we can extract the cover using ffmpeg, keep only the 2 tracks, then attach the cover? Or just cut the 3rd track which is just a static image? I don't understand how this would be an issue (not very familiar with ffmpeg). Considering the process is supposed to be lossless, I think this is an important issue.

Share log from developer tools

Cutting from start to 3105.7956363636363 ffmpeg.ts:47 STDERR: ffmpeg.ts:48 [mov,mp4,m4a,3gp,3g2,mj2 @ 000001aacfeb8bc0] stream 0, timescale not set Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\xxx.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf59.3.101 Duration: 01:21:20.54, start: 0.000000, bitrate: 4433 kb/s Stream #0:00x1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 4300 kb/s, 30 fps, 30 tbr, 90k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream #0:2[0x0]: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 4096x2304 [SAR 1:1 DAR 16:9], 90k tbr, 90k tbn (attached pic) Output #0, mp4, to 'C:\Users\xxx-00.00.00.000-00.51.45.796.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf60.3.100 Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 4300 kb/s, 30 fps, 30 tbr, 90k tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] Stream #0:2: Video: mjpeg (Baseline) (mp4v / 0x7634706D), yuvj420p(pc, bt470bg/unknown/unknown), 4096x2304 [SAR 1:1 DAR 16:9], q=2-31, 90k tbr, 90k tbn (attached pic) Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Stream #0:2 -> #0:2 (copy) Press [q] to stop, [?] for help frame= 0 fps=0.0 q=-1.0 q=-1.0 size= 0kB time=00:00:00.00 bitrate=N/A speed=N/A
frame=14565 fps=0.0 q=-1.0 q=-1.0 size= 257024kB time=00:08:05.53 bitrate=4336.5kbits/s speed= 971x
frame=29408 fps=29408 q=-1.0 q=-1.0 size= 524288kB time=00:16:20.30 bitrate=4381.3kbits/s speed= 980x
frame=44529 fps=29683 q=-1.0 q=-1.0 size= 796672kB time=00:24:44.33 bitrate=4396.8kbits/s speed= 989x
frame=59791 fps=29893 q=-1.0 q=-1.0 size= 1071360kB time=00:33:13.13 bitrate=4403.4kbits/s speed= 996x
frame=74488 fps=29777 q=-1.0 q=-1.0 size= 1336064kB time=00:41:22.96 bitrate=4408.0kbits/s speed= 993x
frame=88835 fps=29597 q=-1.0 q=-1.0 size= 1594624kB time=00:49:21.21 bitrate=4411.4kbits/s speed= 987x
frame=93173 fps=26609 q=-1.0 q=-1.0 size= 1672448kB time=00:51:45.78 bitrate=4411.3kbits/s speed= 887x
frame=93173 fps=23284 q=-1.0 q=-1.0 size= 1672448kB time=00:51:45.78 bitrate=4411.3kbits/s speed= 776x
frame=93173 fps=20698 q=-1.0 q=-1.0 size= 1672448kB time=00:51:45.78 bitrate=4411.3kbits/s speed= 690x
[mp4 @ 000001aad1ceec00] Starting second pass: moving the moov atom to the beginning of the file frame=93173 fps=16517 q=-1.0 Lq=-1.0 size= 1680698kB time=00:51:45.78 bitrate=4433.1kbits/s speed= 551x
video:1631000kB audio:47614kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.124118%

mifi commented 1 month ago

in my experience, when you cut a file with an mjpeg thumbnail stream, the output will have problems where the video/audio in the output file stops early but the playback continues for a while with a stuck/black frame. so I think this is an issue in ffmpeg, therefore I added the warning

It seems that it should be straightforward? For example maybe we can extract the cover using ffmpeg, keep only the 2 tracks, then attach the cover? Or just cut the 3rd track which is just a static image? I don't understand how this would be an issue (not very familiar with ffmpeg). Considering the process is supposed to be lossless, I think this is an important issue.

I don't know how to cut the image. afaik ffmpeg is supposed to do it but it doesn't always cut it correctly. as for extract the cover and re-attach it, while it seems simple, in reality it's quite complex to implement because losslesscut supports many different export flows and permutations (concat files, export segments, export + concat, export segments to chapters, and smart cut are the most important)

wangx1ng commented 2 weeks ago

Can we forget about the thumbnail track of the original video? Instead, we can take a screenshot of the first frame automatically for each video about to be exported, then attach the screenshots to the corresponding videos, and that's it.

mifi commented 2 weeks ago

There is already a function that allows you to do this. Go to keyboard actions and bind "Set current frame as cover art"