rigaya / QSVEnc

QSVによる高速エンコードの性能実験
http://rigaya34589.blog135.fc2.com/blog-category-10.html
Other
313 stars 28 forks source link

--sub-source results in Error: Failed to write subtitle stream # frame: Invalid argument. #109

Closed bavdevc closed 1 year ago

bavdevc commented 1 year ago

Hello @rigaya

I tried adding an external PGS subtitle to the encoding process using the --sub-source option but it will always result to the following error message and the qsvenc aborts:

[matroska @ 00000182603214c0] Application provided invalid, non monotonically increasing dts to muxer in stream 3: 119800 >= 119797 avout: Error: Failed to write subtitle stream 3 frame: Invalid argument.

workaround: remux the input mkv file and the subtitle with MKVToolNix/mkvmerge into a new mkv file, then qsvenc runs without any error and the resulting file is correct incl. the subtitle and all the other specified options for that subtitle stream

rigaya commented 1 year ago

Thank you for letting me know the issue.

I've found out that it is required to insert "pgs_frame_merge" bitstream filter to avoid this error.

However, currently the bitstream filter is not included in the ffmpeg dlls, therefore I need to update ffmpeg and rebuild the dlls. Unfortunately, it might take time, as when updating the dlls, I need to test much more compared to ordinary updates.

bavdevc commented 1 year ago

no problem, workaround is fine for me - take all the time you need and tell me if you need help with testing something - atm. I'm creating a lot of CI/CD test cases for Intel GPU driver / ffmpeg / qsvenc and some automation scripts

rigaya commented 1 year ago

Thanks. The fix for this issue is now in the code but currently disabled, I'll update ffmpeg dlls once I've gone through tests to make sure the app works fine with the new dlls.

rigaya commented 1 year ago

QSVEnc 7.30 updates ffmpeg libs and now PGS subtitles file can be muxed in with --sub-source.

Thanks again for reporting this issue.

bavdevc commented 1 year ago

Hello rigaya,

I have good news and bad news after testing the 7.30 release.

good news: --sub-source now works without any error that breaks qsvenc

bad news: all subtitles, using --sub-copy or --sub-source turn out empty / 0 bytes in the resulting file when using 7.30 - working fine in 7.29 for --sub-copy

btw. there is a little typo in the https://github.com/rigaya/QSVEnc/blob/master/QSVEncC_Options.en.md#--sub-source-stringintparam1value1 for --sub-source example section:

Example2: --sub-source "":disposition=default;metadata=language=jpn should be Example2: --sub-source ":disposition=default;metadata=language=jpn"

otherwise you get a command line error

same goes for https://github.com/rigaya/QSVEnc/blob/master/QSVEncC_Options.en.md#--master-display-string-or-copy-hevc-av1

Example1: --master-display G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1) should be Example1: --master-display "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)"

rigaya commented 1 year ago

Thank you, I made another fix with QSVEnc 7.33 fixing the problem with the subtitle.

bavdevc commented 1 year ago

re-test with 7.33 successful --sub-source now works without any error and the output is correct

fabulous work!!! Thank you very much