lisamelton / other_video_transcoding

Other tools to transcode videos.
MIT License
549 stars 25 forks source link

DVD slows down during scenes #47

Closed ESClaus closed 4 years ago

ESClaus commented 4 years ago

I am currently working on encoding Star Trek Voyager DVDs and noticed that when I use other_video_transcoding that some scenes the movement slows down. Though audio is fine. I have tried this with HEVC and x264 and both times it causes these scenes to move slow.

When I use the video_transcoding it is fine and has none of these slow down issues.

Here is the options I use on other_video_transcoding:

HEVC: --hevc --nvenc-temporal-aq --crop auto --max-muxing-queue-size 9999 --add-audio 1

x264: --crop auto --max-muxing-queue-size 9999 --add-audio 1

lisamelton commented 4 years ago

@TheClaus My apologies for taking so long to respond.

Since your input is a DVD rip, the problem is likely due to interlacing and/or telecining issues. FFmpeg, on which other-transcode is based, and HandBrake, on which transcode-video is based, handle these differently.

Can you try adding the --detelecine option and see how that works?

ESClaus commented 4 years ago

@donmelton No problem. You along with others are quick to respond. So I just encoded it in HEVC with the --detelecine and the audio is way off now. It was correct for about 10 secs and then just got worse and worse. I am encoding in x264 now to see the results.

Let me know if you need logs I will get them and put them somewhere for you.

ESClaus commented 4 years ago

Same results with x264 using the --detelecine option.

lisamelton commented 4 years ago

@TheClaus Hmmmm, it's odd that the audio would be out of sync. There's something peculiar going on here.

Yes, you can attach the .log files here and I'll take a look once I get back from the doctor.

ESClaus commented 4 years ago

Here you go.

HEVC.Star.Trek.Voyager.S04E01.mkv.log

x264.Star.Trek.Voyager.S04E01.mkv.log

skj-dev commented 4 years ago

@TheClaus Are you running a snapshot build of ffmpeg? I'm wondering based on the version being ffmpeg version git-2020-05-28-c0f01ea. It might be a good idea to try running against a release build just to rule out the possibility of a dev-release bug being in play, if nothing else.

arikalish commented 4 years ago

So there's no great solution to this.

Star Trek: TNG, Voyager, and DS9 were filmed at 24fps but all the special effects were done at 30fps. The DVDs switch between frame rates as needed. Unfortunately, it's a mess for transcoding.

The TNG Blu Rays were redone at 24fps with new special effects, unfortunately it doesn't look like Voyager or DS9 will get that treatment.

You can find more details in this discussion from ages ago: https://forum.videohelp.com/threads/305764-Star-Trek-Voyager-whats-the-actual-frame-rate-24p-YES-%5BRESOLVED%5D

I'd try encoding at 29.97fps with a deinterlace filter. Try something like:

other-transcode.bat --nvenc --hevc --crop auto --eac3 --add-subtitle 2 ----rate 30000/1001 --deinterlace 'Z:\TV\Star Trek - Voyager\Season 1\S01E01E02.mkv

lisamelton commented 4 years ago

@arikalish Agreed. Forcing the frame rate and deinterlacing seems the safest option here. Thanks!

ESClaus commented 4 years ago

@ttyS0 So I remember why I switch to snapshots. I was having an issue with a stable build not wanting to auto crop. It wouldn't detect crops. I just tried 4.3 version of ffmpeg with the same issue. I jumped back to 4.2.3 and encoded the episode again and it started auto cropping. It didn't fix my issue with the sync though.

@arikalish I tried the following options but looking at the log it looks like it didn't even pick up the rate command.

--nvenc --hevc --crop auto --rate 30000/1001 --detelecine --max-muxing-queue-size 9999 --add-audio 1

Here is the logs if that helps.

Star.Trek.Voyager.S04E01.mkv.log

arikalish commented 4 years ago

Hmm... Here's what happens on mine:

PS Z:\Converted> other-transcode.bat --nvenc --hevc --crop auto --eac3 --add-subtitle 2 --rate 30000/1001 --deinterlace 'Z:\TV\Star Trek - Voyager\Season 4\S04E01.mkv'
Verifying "ffprobe" availability...
Verifying "ffmpeg" availability...
Verifying "mkvpropedit" availability...
Finding encoders...
Scanning media...
Detecting crop...
crop = 710:480:6:0
duration = 00:45:58.021
Stream mapping:
 0 = hevc_nvenc / 1500 Kbps
 1 = copy
 4 = subrip
Command line:
ffmpeg -loglevel error -stats -i "Z:\TV\Star Trek - Voyager\Season 4\S04E01.mkv" -map 0:0 -filter:v yadif=deint=interlaced,fps=30000/1001,crop=710:480:6:0 -c:v hevc_nvenc -pix_fmt:v p010le -b:v 1500k -maxrate:v 4500k -rc:v vbr_hq -spatial_aq:v 1 -color_primaries:v smpte170m -color_trc:v bt709 -colorspace:v smpte170m -metadata:s:v title= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title= -disposition:a:0 default -map 0:4 -c:s:0 copy -disposition:s:0 0 -metadata:g title= S04E01.mkv
Transcoding...
frame= 8319 fps=593 q=20.0 size=   66554kB time=00:04:59.48 bitrate=1820.5kbits/s speed=21.3x

You can see the deint=interlaced,fps=30000/1001 in there.

I'm on ffmpeg 4.2.1.

Here's my log: S04E01.mkv.log

arikalish commented 4 years ago

@TheClaus I think I see your problem! You're using --detelecine. You should be using --deinterlace

arikalish commented 4 years ago

Yep! That's it. Just ran a test on my machine:

PS Z:\Converted> other-transcode.bat --nvenc --hevc --crop auto --eac3 --add-subtitle 2 --rate 30000/1001 --detelecine 'Z:\TV\Star Trek - Voyager\Season 4\S04E01.mkv'
Verifying "ffprobe" availability...
Verifying "ffmpeg" availability...
Verifying "mkvpropedit" availability...
Finding encoders...
Scanning media...
Detecting crop...
crop = 710:480:6:0
duration = 00:45:58.021
Stream mapping:
 0 = hevc_nvenc / 1500 Kbps
 1 = copy
 4 = subrip
Command line:
ffmpeg -loglevel error -stats -i "Z:\TV\Star Trek - Voyager\Season 4\S04E01.mkv" -map 0:0 -filter:v fieldmatch=order=tff:combmatch=none,decimate,crop=710:480:6:0 -c:v hevc_nvenc -pix_fmt:v p010le -b:v 1500k -maxrate:v 4500k -rc:v vbr_hq -spatial_aq:v 1 -color_primaries:v smpte170m -color_trc:v bt709 -colorspace:v smpte170m -metadata:s:v title= -disposition:v default -map 0:1 -c:a:0 copy -metadata:s:a:0 title= -disposition:a:0 default -map 0:4 -c:s:0 copy -disposition:s:0 0 -metadata:g title= S04E01.mkv
ESClaus commented 4 years ago

Okay that seems to do the trick. I ran a quick test and everything looked okay. I still think I am seeing a slight slow down during scenes but I feel I could be overthinking it and seeing things that don't exist. It is nothing like before. Will run a true test when I get off work and watch it from my TV.

Thanks all for everything.

arikalish commented 4 years ago

Make sure your display can handle the framerate properly. With 29.97/30fps video you should be alright just about everywhere, but watching 24fps on a 60Hz display is rough.

lisamelton commented 4 years ago

Hmmmm, I would have thought the input being a DVD rip that it would be automatically deinterlaced. Weird. Anyway, it's fixed! Thanks again, @arikalish!

@TheClaus Let us know if your test looks good and we can close this.

ESClaus commented 4 years ago

Nope still slow in some parts. Is there a way to install video_transcoding on Windows easily? Something that I can setup a script that will do video_transcoding for DVDs that require handbrake instead of ffmpeg.

lisamelton commented 4 years ago

@TheClaus Damn. Something is weird with that file I think. Sorry about that.

Installing on Windows is not that hard. Instructions are on the wiki:

https://github.com/donmelton/other_video_transcoding/wiki/Windows

arikalish commented 4 years ago

Aw... that's a bummer. Have you tried it through the software pipeline in ffmpeg with the 29.97fps + deinterlace flags? It'd be worth knowing if it's ffmpeg or the nVidia setup that's acting up.

Also, what video card do you have? There are known feature differences between different generations of cards.

FWIW I'm running a GTX 1050Ti.

I haven't done a terribly detailed scan through of the outputs of my Voyager and DS9 transcodes but they looked ok at a glance. If you've got a timecode in an episode or two I can run some tests on my end.

lisamelton commented 4 years ago

@TheClaus Also, why exactly are you passing --max-muxing-queue-size 9999 to other-transcode? This could very well be what's causing the problem. I strongly recommend that you leave that out.

samhutchins commented 4 years ago

Nope still slow in some parts. Is there a way to install video_transcoding on Windows easily? Something that I can setup a script that will do video_transcoding for DVDs that require handbrake instead of ffmpeg.

@TheClaus As Don mentioned, the instructions for other_video_transcoding are here: https://github.com/donmelton/other_video_transcoding/wiki/Windows

Instructions for installing the older video_transcoding project are here:

With WSL: https://github.com/JMoVS/installing_video_transcoding_on_windows#windows-10
Without WSL (what I'd recommend): https://github.com/JMoVS/installing_video_transcoding_on_windows#pre-windows-10-creators-update-and-earlier

ESClaus commented 4 years ago

@donmelton I had an issue with a file and when I looked up the error I found that adding that would fix the issue. I removed it and for some reason ffmpeg just doesn't transcode that show as smoothly as handbrake does. Since this is just a rare thing(most of my content is BD or 4K) I did what @samhutchins suggested and installed video_transcoding under Windows. I got it running last night and sure enough the video is just smoother when it is encoded using handbrake.

Thanks for all the help