[Solved] FFMpeg has a return code of -22

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
binary512
Posts: 36
Joined: Sat Sep 30, 2017 2:10 am

[Solved] FFMpeg has a return code of -22

Post by binary512 »

After upgrading to any version since 13.60, when trying to play .mp4 videos, I get an error...
"FFMpeg.exe has a return code of -22".

I am currently trying to get version 14.3.0 to work properly with my TV "Sony Bravia HX" (renderer: Sony-BraviaHX.conf)

Is it the newer version of FFMpeg.exe that is the culprit?

I notice that the Mencoder works fine, but I don't know how to get Mencoder to over-ride FFMpeg. The setting "Defer to MEncoder when transcoding problematic subtitles" does not seem to do the trick.
(log file is attached)
Is there something else that I am missing?
Thank you.
Kurt C
Attachments
ums_dbg_2024-08-13-10-43.zip
(371.33 KiB) Downloaded 393 times
User avatar
mik_s
Moderator
Posts: 1445
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: FFMpeg has a return code of -22

Post by mik_s »

Is it just this one file that is failing?

It may be related to the external subtitle file as the transcoding command looks a little odd to me, but I know little about this.

Code: Select all

Starting "C:\Program Files (x86)\Universal Media Server\bin\ffmpeg.exe" -y -loglevel info -i "\\miniserver2\d\0pending\Faith's Song (2017).mp4" -filter_complex "subtitles=//miniserver2/d/0pending/Faith\\\'s Song (2017).eng.srt:charenc=ISO-8859-1" -bufsize 1835k -maxrate 37000k -g 25 -qmin 2 -qmax 5 -ab 448k -c:a copy -c:v mpeg2video -f vob \\.\pipe\ffmpegvideo_100_1723560190864
The bit that looks odd is the "\\\'s" in the external .srt filename.
I know a single slash is used as an escape character, double is if you actually want a single slash in the name, but a triple one is strange and may be what is causing the error.
Would it work properly if the .srt file is not there? How about if you remove the ( ' ) from the filename?
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
binary512
Posts: 36
Joined: Sat Sep 30, 2017 2:10 am

Re: FFMpeg has a return code of -22

Post by binary512 »

Thank you for the response. I have the same issue (return code -22) from other files and other UMS installations on other PCs that do not use the double-backslash. On other systems, it is "D:\dirname\filename.mp4"
I have other files (thousands) with subtitles that work fine with earlier versions, but this version (any v14.x version) has problems with this return code (some files with subtitles, some without).
I can find other files with the same error if you would like debug output.
Thanks.
Kurt C
User avatar
mik_s
Moderator
Posts: 1445
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: FFMpeg has a return code of -22

Post by mik_s »

That would be helpful as I may be barking up the wrong tree.

Also do it with renaming this video too so I can see if it still inserts the triple slash next to the apostrophe.
Try it on videos that don't have external (or even internal) subtitles too.

Are these on a network share? Will the same thing happen when sharing those from a local folder?
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
binary512
Posts: 36
Joined: Sat Sep 30, 2017 2:10 am

Re: FFMpeg has a return code of -22

Post by binary512 »

Here are the Debug logs when trying to use the same file from local drive (no network sharing)...
- Original .mp4 file with apostrophe and subtitles
- Original .mp4 with no subtitles
- Original .mp4 with no subtitles and no apostrophe in the name

All attempts fail with return code -22.
The only thing that works is Mencoder.

Kurt
Attachments
ums_dbg_2024-08-14-08-00.zip
(382.99 KiB) Downloaded 385 times
User avatar
mik_s
Moderator
Posts: 1445
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: FFMpeg has a return code of -22

Post by mik_s »

OK that narrows things down as that made no difference so I can ignore that.

I noticed in the conf for that TV there is no transcoding profile set which means it uses the default one "MPEGPS-MPEG2-AC3"

Doing some testing I was able to replicate this on my PS4. It appears to be an incorrect argument (vob) for the output file

Code: Select all

ffmpeg.exe -y -loglevel info -i "XXXX" -bufsize 7000k  -maxrate 44000k -g 5 -q:v 1 -qmin 2 -qmax 3 -ab 448k -c:a copy -c:v mpeg2video -f vob \\.\pipe\ffmpegvideo_103_1723683251229

Code: Select all

DEBUG 2024-08-15 01:58:59.355 [ffmpeg.exe-2-2] [out#0/vob @ 00000226d32b8a40] Codec AVOption b (set bitrate (in bits/s)) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
DEBUG 2024-08-15 01:58:59.355 [ffmpeg.exe-2-2] Stream mapping:
DEBUG 2024-08-15 01:58:59.355 [Thread-43] Result of \\.\pipe\ffmpegvideo_101_1723683539000: true
DEBUG 2024-08-15 01:58:59.355 [ffmpeg.exe-2-2]   Stream #0:0 -> #0:0 (hevc (native) -> mpeg2video (native))
DEBUG 2024-08-15 01:58:59.355 [ffmpeg.exe-2-2]   Stream #0:1 -> #0:1 (copy)
DEBUG 2024-08-15 01:58:59.356 [ffmpeg.exe-2-2] Press [q] to stop, [?] for help
DEBUG 2024-08-15 01:58:59.394 [ffmpeg.exe-2-2] [vob @ 00000226d32c8640] Unsupported audio codec. Must be one of mp1, mp2, mp3, 16-bit pcm_dvd, pcm_s16be, ac3 or dts.
DEBUG 2024-08-15 01:58:59.394 [ffmpeg.exe-2-2] [out#0/vob @ 00000226d32b8a40] Could not write header (incorrect codec parameters ?): Invalid argument
DEBUG 2024-08-15 01:58:59.394 [ffmpeg.exe-2-2] [vf#0:0 @ 00000226d3287500] Error sending frames to consumers: Invalid argument
DEBUG 2024-08-15 01:58:59.396 [ffmpeg.exe-2-2] [vf#0:0 @ 00000226d3287500] Task finished with error code: -22 (Invalid argument)
DEBUG 2024-08-15 01:58:59.396 [ffmpeg.exe-2-2] [vf#0:0 @ 00000226d3287500] Terminating thread with return code -22 (Invalid argument)
If I change the profile to "MPEGTS-MPEG2-AC3" it will work as it uses the mpegts argument

Code: Select all

ffmpeg.exe" -y -loglevel info -i "XXXX" -bufsize 7000k -maxrate 44000k -g 5 -q:v 1 -qmin 2 -qmax 3 -ab 448k -c:a copy -c:v mpeg2video -f mpegts \\.\pipe\ffmpegvideo_102_1723688789869
I think vob used to be a valid option in an older version of FFmpeg but was renamed or removed.


I don't know if this will effect how well your TV plays it but you could add this to your conf file and in theory it will work but some things may not like seeking.

Code: Select all

TranscodeVideo = MPEGTS-MPEG2-AC3


I'll make an issue on Github as this could be effecting other renderers that use the default setting.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
binary512
Posts: 36
Joined: Sat Sep 30, 2017 2:10 am

Re: FFMpeg has a return code of -22

Post by binary512 »

I added the following line, as suggested.
TranscodeVideo = MPEGTS-MPEG2-AC3

That fixed the problem with allowing the video file to be played. But as you state, the ability to Fast-Forward or Rewind no longer functions. And the error code -22 is still showing in the log file.

Also, some videos no longer show subtitles, while others continue to work properly.

Would you say my only options are to remain on 13.60 and keep the functionality, or upgrade and lose functionality? If this is the case, then upgrading is not really an option. Things should be fixed properly.

Also, all functions seem to work with Mencoder.exe. Is there a way to use Mencoder.exe instead of FFMpeg.exe for all videos? Will putting MEncoder ahead of FFMpeg in the Transcoding section use MEncoder instead of FFMpeg?

I have attached the latest log file with four separate test videos.
Video 1 - The original video now can be streamed (showing subtitles), but Fast-Forward/Rewind do not function.
Video 2 - A plain video without subtitles works fine. Fast-Forward/Rewind continue to work.
Video 3 - An .mp4 with external subtitle file. Can stream but subtitles not showing. Fast-Forward/Rewind function correctly.
Video 4 - An .mkv with internal subtitles works fine. Fast-Forward/Rewind continue to work.


I am now getting a lot of the following error:
[Fatal Error] :1:10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.

I have uploaded a new debug file.

Update: If I put the MEncoder first in the list above FFMpeg, then it fixes the issue with Video 1. However, Video 3 above wants to stream with No Transcoding. If I manually force it to use MEncoder, then it works fine. Is it possible to force usage of MEncoder with a specific type(s) of video? Also, the Fatal Error shown above goes away if I put MEncoder first in the list.
Attachments
ums_dbg_2024-08-15-12-24.zip
(684.03 KiB) Downloaded 382 times
Last edited by binary512 on Fri Aug 16, 2024 6:01 am, edited 1 time in total.
User avatar
mik_s
Moderator
Posts: 1445
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: FFMpeg has a return code of -22

Post by mik_s »

Its up to you if you want to go back to a previous version that works. I have made that issue on Github so hopefully it can be fixed in the next version then you can upgrade straight to that one.

On some devices it is not possible to seek videos that are being transcoded as they use SeekByByte instead of SeelByTime, but if this has worked before for you on the old version then it will because of that transcoding profile change.

If you move Mencoder above FFmpeg then Mencoder will be used for transcoding but I don't think it will be as good or flexible as FFmpeg.
If you have no issues with it then this is a quick fix for now. You should also revert the change in the conf when using Mencoder just to be sure.

For video 3 this is being streamed so is up to the TV to handle subtitles. See if there is a subtitle button on the remote to turn them on.

I don't know what that DOCTYPE error is, It looks like the TV is sending some HTML instead of XML in a response.
It also may be related to that transcoding method and it is not too happy with it.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
binary512
Posts: 36
Joined: Sat Sep 30, 2017 2:10 am

Re: FFMpeg has a return code of -22

Post by binary512 »

Thank you for all your help. Is there a link that shows the issue on Github so I can see if/when it is fixed in a future release?
User avatar
mik_s
Moderator
Posts: 1445
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: FFMpeg has a return code of -22

Post by mik_s »

You can keep track of it here.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
Post Reply