mltframework / shotcut

cross-platform (Qt), open-source (GPLv3) video editor
https://www.shotcut.org
GNU General Public License v3.0
10.76k stars 1.12k forks source link

Black video sequences in export when using proxy #1395

Open lmenzel opened 1 year ago

lmenzel commented 1 year ago

When inserting video files in the playlist, it randomly does not recognize the video index. The save file contains for these files <property name="video_index">-1</property> The proxy files were created correctly, so editing the videos was not a problem, but when exporting the video, the effected sequences were black (Audio was there). When I turn off proxy, the files are also blank in the preview and settings show Track: None. Videos in my case are 4K mp4 HEVC 30fps videos recorded with a Pixel 6 pro phone. When I deleted the project folder, created a new project and pulled in the files again, some other(!) files (but not all!) were effected, so it seems to be a random issue. Maybe it happens only when inserting many files at once? Replacing the video_index -1 with 2 in the save file solves the issue, but this workaround will probably not work for all kind of video files?

Shotcut version 22.12.21, Windows store version, Windows 11, Ryzen 5950X, 64GB RAM, RTX 4090

ddennedy commented 1 year ago

I think this is a known problem when the first stream in the file is not audio or video. In that case, proxy cannot be used. Please provide ffprobe output for this kind of video or a sample file.

lmenzel commented 1 year ago

Thank you very much for looking into this. I tried it again, and added one file twice to a new, proxy enabled project, and one copy was rendered fine and the other was black. If this is a problem of the source file, shouldn't it always work or always fail for one file?

By the way, this is the ffprobe output for one of the files that only some times work: ffprobe.txt

ddennedy commented 1 year ago

From the ffprobe output

Unsupported codec with id 0 for input stream 0

This is the known bug. It causes the audio_index and video_index in the proxy to mismatch in the source because upon transcoding to make the proxy, ffmpeg drops the first unsupported stream. I do not know why it is being random for you, but basically files like this are not currently supported in proxy mode due to this problem. In order to fix it, we need to code up a new relative stream index system. Since these smartphone camera videos might also be variable framerate, which is also not supported I suggest you convert them. You can use Properties > Convert or something else like Handbrake. Then, you can use proxy mode reliably.

I was not able to reproduce this issue with my video files. I am not sure I have a sample file with this problematic first stream if you can provide one.

lmenzel commented 1 year ago

Here is such a file.

https://user-images.githubusercontent.com/4169704/211201572-7dc7e2c0-bee6-4100-b33a-4f4017ea777f.mp4