Tdarr icon indicating copy to clipboard operation
Tdarr copied to clipboard

Transcode ffmpeg command fails but slight mod can make it work

Open adefaria opened this issue 2 years ago • 9 comments

I've transcoded a lot of my videos. I'm now dealing with the stragglers and I have a few thousand of them. What I do is look at the transcode errors and search the info and reports looking for a long ffmpeg line. I then copy that line to a command line on my Ubuntu desktop, protect the filenames as they often have spaces in them, and try to transcode the file outside of Tdarr and the Docker container I'm running that in. This often produces an error message which I google and try to find a solution. If I find a solution I transcode the file and move it back in place.

Here's an example of a failure:

ffmpeg -c:v h264_cuvid -i "/input/TV/Britain's Got Talent/Britain's Got Talent S15E11 - Semi Final 3.mkv" -map 0 -c:v hevc_nvenc -cq:v 19 -b:v 2858k -minrate 2000k -maxrate 3715k -bufsize 5716k -spatial_aq:v 1 -rc-lookahead:v 32 -c:a copy -c:s copy -max_muxing_queue_size 9999 "/temp/Britain's Got Talent S15E11 - Semi Final 3-TdarrCacheFile-R0iRNbb15L.mp4" && say done || say failed
    ffmpeg version 4.4-6ubuntu5 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 11 (Ubuntu 11.2.0-7ubuntu1)
    ...

    [mp4 @ 0x55bbebc3b9c0] Could not find tag for codec dvb_subtitle in stream #2, codec not currently supported in container
    Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
    Error initializing output stream 0:0 -- 

For this error, all I need to do is change the .mp4 -> .mkv in the output file and the transcode works!

Why did Tdarr generate a ffmpeg that would not work? Do I need to configure a plugin to handle this? I have not done much with plugins. The only thing I did was to add the Migz-Transcode Using Nvidia GPU & FFMPEG to the library's Transcode options and disabled Migz-Transcode USing CPU && FFMPEG. I don't know a lot about plugins and the chaining of plugins. Is it supposed to be that if the GPU plugin fails the CPU plugin will be tried? Is there a plugin that will try the same transcode with .mp4 -> .mkv if the first fails?

There are other failures where I sometimes need to simply remove -map 0 or some other thing in order to get my ffmpeg command to run on my Ubuntu desktop to perform the transcode without error.

Expected behavior I expected Tdarr to generate a ffmpeg command that works.

-Worker error [can be found on the 'Tdarr' tab by pressing the 'i' button on a failed item in the staged file section or in the transcode error section at the bottom]

data.txt mvqB81Msna-log.txt

  • Docker and Ubuntu 21.10

adefaria avatar Jun 07 '22 21:06 adefaria

For those plugins you set the container yourself in the settings so it's just going to try and do what you specify and give an error if it can't be done. Containers are important so you wouldn't want a situation where it's automatically changing the container from what you specify.

HaveAGitGat avatar Aug 08 '22 23:08 HaveAGitGat

I don't understand. I'm using the default plugins with the default settings. Am I odd to expect it to work?

It might be helpful if you explained how I could configure any plugins to handle this situation. I have no idea of how plugins work nor how to properly configure them.

adefaria avatar Aug 09 '22 03:08 adefaria

Different containers support different codecs so you can’t force any type codec into any container.

In your case you’re trying to put dvb_subtitle codec into mp4 container which is not fully supported by FFmpeg at the moment hence the error.

So to avoid codec/compatibility errors you’d need to keep the container the same as the original and not change it (or use mkv which supports almost everything).

Other option is to use the remove subtitles plugin and then just have something like Bazarr handle subtitles for you.

HaveAGitGat avatar Aug 09 '22 19:08 HaveAGitGat

What do you mean me, batman? I'm not trying to put dbv_subtitle into an mp4, it's tdarr that composed the ffmpeg command no? Perhaps I did change the plugin once to use mp4 instead of mkv but that's only because I was experiencing problems trying to use mkv. I found that using mp4 worked. So I changed it to mp4 and it worked, for some videos. Others failed in the manner described above so I switched it back to mkv.

I guess the point is that I expected tdarr to know way more about these containers and what to use given the input that it would choose mp4 or mkv depending on which was best for the given input file. Am I wrong in thinking that?

Or perhaps there is some way to configure the plugins in line such that it cascades to the next plugin if this plugin fails. I looked to see if that was the case but I could not figure it out.

adefaria avatar Aug 09 '22 19:08 adefaria

I think typically people want their files all in the same container so everything’s organised so that’s why Migz wrote it that way.

The FFmpeg command is composed by the plugin, you can see it here:

https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz1FFMPEG.js

If you want to keep the original container of each file then you could make a small edit to line 139 and change it to:

response.container = `.${file.container}`;

You can edit the plugin on the plugins tab. Suppose an option could be added to keep the original container.

HaveAGitGat avatar Aug 09 '22 19:08 HaveAGitGat

Hmm... I see it as line 131...?

I would vote for "If you specify a blank container extension then the original container is used".

BTW, I have completed my big Tdarr conversion process and saved ~5TB! Most ended up to be .mkv files. Thanks. But new videos are coming in every day and Tdarr attempts to convert them. Largely it works except for issue #666. Would love to see that one addressed. (Maybe the problem is that it's issue #666).

I'm currently restarting the tdarr_node Docker container everyday.

adefaria avatar Aug 09 '22 19:08 adefaria

Woops yeah 131 is right. Viewing it on my phone which squashed it.

Maybe could do that but the issue is that if you don’t enter anything then it defaults to mkv and there may be people using it like that at the moment.

Nice 😁. And sure I’m looking to get an update out soon so hopefully can resolve that.

HaveAGitGat avatar Aug 09 '22 19:08 HaveAGitGat

Smartphones -> not dev machines!

I was thinking that by default it would be filled in with mkv but the documentation would say "If you want to keep the original container, set this to blank" with the corresponding code changes.

Looking forward to the update!

adefaria avatar Aug 09 '22 19:08 adefaria

Largely it works except for issue #666. Would love to see that one addressed. (Maybe the problem is that it's issue #666).

Found a workaround for #666. It was a devil of a problem and was hell to figure out what was going wrong, but if you downgrade nvidia-docker2 by a couple of revisions it seems to work.

Lebo77 avatar Aug 28 '22 23:08 Lebo77

Added option to use original container in default plugins here: https://github.com/HaveAGitGat/Tdarr_Plugins/pull/393

HaveAGitGat avatar Mar 17 '23 08:03 HaveAGitGat