rigaya / NVEnc

NVENCによる高速エンコードの性能実験
https://rigaya34589.blog.fc2.com/blog-category-17.html
Other
1.08k stars 114 forks source link

Subtitles order is reversed from original #349

Closed norbusan closed 3 years ago

norbusan commented 3 years ago

Yesterday I have tried to convert a BD 4k rip using nvencc. The video and audio worked absolutely correctly, but interestingly the subtitle tracks are completely messed up. I used

... --sub-copy 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24 --sub-metadata  1?language='eng' --sub-metadata  2?language='fre' --sub-metadata  3?language='ger' ...

which is seemingly correct looking at the mediainfo output:

Text #1
ID                                       : 14
ID in the original source medium         : 4768 (0x12A0)
...
Language                                 : English
...

Text #2
ID                                       : 16
ID in the original source medium         : 4769 (0x12A1)
...
Language                                 : French
...

But at the end, the encoded files gives me Finnish subtitles when selecting English etc. As far as I see the mapping that is there now is

ID   Shown        Actual       possible matching IDs
1    English      Finnish      13
2    French       Japanese     24 (23)
3    German       Japanese     23 (24)
4    Italian      Spanish      22 (10/5)
5    Spanish      Italian      21 (4)
6    Dutch        German       20 (3)
7    Chinese      French       19 (2)
8    Chinese      Thai         18
9    Korean       Swedish      17
10   Spanish      Polish       16
11   Czech        Norwegian    15
12   Danish       Greek        14
13   Finnish      English      1
14   Greek        Danish       12
15   Norwegian    Czech        11
16   Polish       Spanish      10 (5/22)
17   Swedish      Korean       9
18   Thai         Chinese      8 (7)
19   French       Chinese      7 (8)
20   German       Dutch        6
21   Italian      Spanish      5 (10/22)
22   Spanish      Italian      4 (21)
23   Japanese     German       3 (20)
24   Japanese     French       2 (19)

What one sees is that

Note that if I do NOT specify --sub-metadata and let nvencc copy the information I get the correct tagging of language, but as shown above in the second Actual column, the order is very different from the original.

I checked that the above --sub-metadata entries are all correct.

This is with nvencc compiled from source in git checkout yesterday, running on Debian/sid.

Thanks

追加:今気が付きましたが、日本語でも連絡して構いません。よろしくお願いします。

rigaya commented 3 years ago

Thank you for reporting the issue.

However, I'm not being able to reproduce the issue. Having tried input mkv file with 7 subtitles, the subtitle tracks were in order in the output file.

I've tried command line below on both Windows and Ubuntu, but had no problem there.

  1. nvencc -i input.mkv -o output.mkv --audio-copy --sub-copy
  2. nvencc -i input.mkv -o output.mkv --audio-copy --sub-copy 1,2,3,4,5,6,7

It might be specific to input file. Would you please run again adding --log-level debug --log log.txt and share the log.txt file? It might provide some hints.

norbusan commented 3 years ago

Thanks for looking into this. I just run:

nvencc" --log-level debug --log log.txt -i "/home/norbert/LOTR/LOTR1/The Lord of the Rings- The Fellowship of the Ring (EXT.) PT. 1.mkv"  --audio-copy --sub-copy -o bla.mkv

and in the log file there is

avcuvid/avsw: found subtitle stream, stream idx 25, trackID 1.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 36, trackID 2.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 35, trackID 3.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 34, trackID 4.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 33, trackID 5.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 32, trackID 6.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 31, trackID 7.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 30, trackID 8.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 29, trackID 9.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 28, trackID 10.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 27, trackID 11.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 26, trackID 12.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 13, trackID 13.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 24, trackID 14.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 23, trackID 15.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 22, trackID 16.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 21, trackID 17.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 20, trackID 18.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 19, trackID 19.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 18, trackID 20.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 17, trackID 21.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 16, trackID 22.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 15, trackID 23.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 14, trackID 24.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms

which seems strange that the stream idx and the trackID are not ordered in parallel.

I can send you the complete log (about 300M for conversion of a few minutes) if you want.

Thanks again.

rigaya commented 3 years ago

Thank you for pointing out the problem from the log, it helped me much. I also think the log you mentioned shows where the problem is.

I made a commit ( 1e07de2 ) which I think will fix the problem. It removes the old and unnecessary code which I think was causing the problem.

Will you please pull and have a try?

norbusan commented 3 years ago

Thanks a lot for the quick fix, this is MUCH appreciated!!! I can confirm that with the above commit the subtitles are now correctly ordered, and the log file shows the expected output:

avcuvid/avsw: found subtitle stream, stream idx 13, trackID 1.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 14, trackID 2.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 15, trackID 3.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 16, trackID 4.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 17, trackID 5.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 18, trackID 6.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 19, trackID 7.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 20, trackID 8.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 21, trackID 9.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 22, trackID 10.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 23, trackID 11.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 24, trackID 12.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 25, trackID 13.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 26, trackID 14.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 27, trackID 15.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 28, trackID 16.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 29, trackID 17.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 30, trackID 18.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 31, trackID 19.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 32, trackID 20.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 33, trackID 21.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 34, trackID 22.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 35, trackID 23.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
avcuvid/avsw: found subtitle stream, stream idx 36, trackID 24.0, hdmv_pgs_subtitle, frame_size 0, timebase 1/1000, delay 0 ms
rigaya commented 3 years ago

Thank you for confirming, nice to hear it now works fine.

I'll have this issue closed now.