Author Topic: Anime from VHS with FLAC audio? + What to do with telecined content  (Read 410 times)

Offline kilsan97

  • Member
  • Posts: 50
  • Soreepeong
I got VHSes of Bakutou Sengen Daigunder, and used a paid service to convert into AVI files (5GB per episode: DVSD + 48kHz PCM). The sound is great, but the problem is I couldn't decide what to do with the audio.

Episode 1:
56.3MB (AAC 320k)
151MB (FLAC level 8)
124MB (Used AnimeIVTC to make it into 24000/1001 fps and libx264 crf=22 preset=veryslow tune=animation)
85MB (Used QTGMC(preset=slower), hqdn3d(4), Levels(0,0.9, 255, 0, 255, coring=false, dither=true) to make it into 60000/1001 fps, and same parameter for x264)

The sound quality of Hi-Fi VHS stereo is comparable to the quality of CD audio
I do think the audio worth to be lossless form, but since it's even bigger than the encoded video stream, I'm not sure if BBT accepts flac from VHS.

I practically gave up trying to perform inverse telecine for this video, since the video is a mixture of 24i, 30i, 30p, and some longer-that-it-should-be interlaced patterns. TIVTC, Decomb, AnimeIVTC and 2 self-rolled script didn't do the job, so QTGMC is it. At least it's better than seeing combed frames... Can anybody help with IVTC, or should I upload the file in 60000/1001 fps (when I'm done subbing)?

Audio samples (flac): The audio starts around 10sec.
https://mega.nz/#!2gRCVJKI!PjhP2S2oOe1h3e_AiB5LAxWeTIWXumV56Ur4cXuuc-c
https://mega.nz/#!u4p01ByS!Z8dRYZ-KTd6pgCRlF_RUdpM2em4-Ui_UaK6_vLUaH2Y

Offline cold_hell

  • Member
  • Posts: 350
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #1 on: December 25, 2016, 05:35:34 pm »
For me the audio should be equal to the video in terms of quality.
If you plan to go with --crf 22 --tune animation - by all means, please use 50kbps HE-AAC/OPUS or something like it.
If you want lossless audio go with FLAC.
AAC q127 (variable bitrate ~200-350 kbps) is completely fine and it saves tons of space if you want small files and most people won't be able to tell the difference, however the difference between crf 17 and crf 22 for example is quite noticeable especially on SD content.

Offline kilsan97

  • Member
  • Posts: 50
  • Soreepeong
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #2 on: December 28, 2016, 02:15:05 am »
For me the audio should be equal to the video in terms of quality.
If you plan to go with --crf 22 --tune animation - by all means, please use 50kbps HE-AAC/OPUS or something like it.
If you want lossless audio go with FLAC.
AAC q127 (variable bitrate ~200-350 kbps) is completely fine and it saves tons of space if you want small files and most people won't be able to tell the difference, however the difference between crf 17 and crf 22 for example is quite noticeable especially on SD content.


Alright! I'll go with crf=17 and flac, then. I only recently realized the difference of crf=22 and 17 when encoding contents from blu-ray...

Online Krudda

  • Member
  • Posts: 10298
  • 私は 日本語 が 上手 じゃ ありません
    • My Anime List
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #3 on: December 28, 2016, 10:20:55 am »
https://trac.ffmpeg.org/wiki/Encode/H.264
Quote
The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible. A lower value is a higher quality and a subjectively sane range is 18-28. Consider 18 to be visually lossless or nearly so: it should look the same or nearly the same as the input but it isn't technically lossless.
The above is for 8bit h.264, for 10bit h.264, the CRF values go up to 63. For HEVC (h.265), the values are on a completely different scale, do not use them as if they were h.264.

I cannot find the "sane CRF values" guide I read a few years back, but it had a far better explanation of which CRF values to choose, and why to choose them.
I stress that if you want higher quality, CRF is not as important as --preset, use --preset slow or --preset veryslow
I personally use --preset placebo, but thats just me. veryslow should be more than enough and slow should be adequate for VHS content.

Offline kilsan97

  • Member
  • Posts: 50
  • Soreepeong
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #4 on: December 28, 2016, 01:12:19 pm »
The above is for 8bit h.264, for 10bit h.264, the CRF values go up to 63. For HEVC (h.265), the values are on a completely different scale, do not use them as if they were h.264.


Don't worry! I'm using x264. My full command line is:
Code: [Select]
wine avs2yuv $fi.avs - | ffmpeg -hide_banner -f yuv4mpegpipe -i - -i $fi.flac -map 0:v:0 -map 1:a:0 -sws_flags lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -vf crop=704:480:10:0,scale=640:480,setdar=4/3 -c:v libx264 -c:a copy -crf 17 -preset veryslow -tune animation $fi.mkv
where $fi is filename, with AVS file of form
Code: [Select]
AviSource("FILENAME",fourCC="dvsd").KillAudio() #Using Cedocida DV Codec
QTGMC(preset="slower")
hqdn3d(4)
AssumeFPS(60000,1001)

The resulting file size is about 500MB per episode.
« Last Edit: December 28, 2016, 01:16:50 pm by kilsan97 »

Offline cold_hell

  • Member
  • Posts: 350
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #5 on: December 28, 2016, 01:55:15 pm »
CRF is not as important as --preset, use --preset slow or --preset veryslow
I personally use --preset placebo
Wrong. CRF control the size by reducing or increasing the quantizers, the presets control the quality of the predictions.

It's called "placebo" for a reason :).
Actually above 5 the references and the constructive b-frames aren't really that strong and in most cases there is another good enough frame for reference/ As long as motion search and the sub-pixel estimation are fine the other settings will just reflect on the final size of the files (by small margin) and the quality will be more or less the same, so the preset aren't really THAT useful especially if you want to speed-up the encoder without big trade off when it comes to quality. Unless the encoding is really slow, you should stick with the highest "sane" settings (for example: it's better to max-out all encoder's settings than using --tesa instead of --umh). Keep in mind that the encode is one time thing, while the video will be stored on a lot of drives, so you should try to compress as much as you can.

--CRF is more or less the quantization value of the blocks, but unlike the --QP (constant quantizers) it takes in mind other settings like qcomp, ipratio and etc.

crf values of the 10bit encoder start from -13 to keep consistency with the 8bit one, so the crf has the same meaning and the last I checked the max was still 51 (you can go with --qp 81 if you so desire, but I doubt that it preduces anything watchable)

So there is no actual magic value for the crf, depending on the other settings crf 14 may be bad or crf 20 can be a bloat, but on SD content you need higher quality (lower crf), since artifacts will be much more visible after upscale. 17 was just an example. Run some test and choose the one that suits your needs (i.e. where your encode look like the source or almost like it). What I actually wanted to say is that --tune anime is quite bad and you shouldn't really use it or at least increase the --aq-strength

Don't worry! I'm using x264. My full command line is:
Code: [Select]
wine avs2yuv $fi.avs - | ffmpeg -hide_banner -f yuv4mpegpipe -i - -i $fi.flac -map 0:v:0 -map 1:a:0 -sws_flags lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -vf crop=704:480:10:0,scale=640:480,setdar=4/3 -c:v libx264 -c:a copy -crf 17 -preset veryslow -tune animation $fi.mkv
where $fi is filename, with AVS file of form
Code: [Select]
AviSource("FILENAME",fourCC="dvsd").KillAudio() #Using Cedocida DV Codec
QTGMC(preset="slower")
hqdn3d(4)
AssumeFPS(60000,1001)
.
You should use x264, not ffmpeg (if I'm reading your script correctly? -no idea what you are actually doing in the first one). Also for telecined content, you can use frame matching like TFM with QTGMC on fail (I can agree that qtgmc with EdiMode="NNEDI3" can do a single field restoration quite good, but it should be your last option). apply deinterlacer/ITVC after the decode and then you can denoise and resize in 16bit depth and encode proper 10bit file.
« Last Edit: December 28, 2016, 02:08:51 pm by cold_hell »

Online Krudda

  • Member
  • Posts: 10298
  • 私は 日本語 が 上手 じゃ ありません
    • My Anime List
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #6 on: December 28, 2016, 07:49:47 pm »
I don't know what I was thinking last night... cold hell is absolutely right, preset affects filesize more than quality.
And yeah "tune animation" is almost less than useless.
Try either tune film or tune grain
Grain will probably be overkill, so run a few samples and compare them. Clip a few hundred frames of fast and slow motion, so you aren't waiting all day on the samples to encode.

Offline kilsan97

  • Member
  • Posts: 50
  • Soreepeong
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #7 on: December 28, 2016, 07:58:47 pm »
Well, some old dvdrips have file sizes of 500MB (Gold Lightan and Go Saurer), so I think 500MB isn't too much!

You should use x264, not ffmpeg (if I'm reading your script correctly? -no idea what you are actually doing in the first one). Also for telecined content, you can use frame matching like TFM with QTGMC on fail (I can agree that qtgmc with EdiMode="NNEDI3" can do a single field restoration quite good, but it should be your last option). apply deinterlacer/ITVC after the decode and then you can denoise and resize in 16bit depth and encode proper 10bit file.

Since I'm encoding in Arch Linux machine, I'm using Avs2yuv to feed the output of avisynth to ffmpeg. I've already compressed wav files into flac, so I'm just also muxing flac files. But why not ffmpeg? Doesn't it simply serves as a front-end(?) for x264?
For IVTC, I thought the content was telecined from 24000/1001 fps and tried various IVTC tools, but now I think that it's a giant mess because simply qtgmc'ing the video sometimes results in a sequence of frames without 3+ adjacent same frames in an action scene. It would be great if you can help me with that; I'll encode some more problematic parts if you need them.


Also, why is tune=animation bad? This anime is not supposed to have many grains and the following looks logical to me.
Quote
animation – intended for cartoons, etc., where deblocking is boosted to compensate for larger, flat areas. More reference frames are used.

Online Krudda

  • Member
  • Posts: 10298
  • 私は 日本語 が 上手 じゃ ありません
    • My Anime List
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #8 on: December 28, 2016, 09:53:44 pm »
why is tune=animation bad? This anime is not supposed to have many grains and the following looks logical to me.
Quote
animation – intended for cartoons, etc., where deblocking is boosted to compensate for larger, flat areas. More reference frames are used.

It's more that it affects psychovisual settings, in a negative way. --tune animation is actually detrimental to many animation types except flash, really.
More reference frames, isn't necessarily better.
Be glad you're not using --tune touhou

Code: [Select]
--tune <string>         Tune the settings for a particular type of source
                          or situation
                              Overridden by user settings.
                              Multiple tunings are separated by commas.
                              Only one psy tuning can be used at a time.
                              - film (psy tuning):
                                --deblock -1:-1 --psy-rd <unset>:0.15
                              - animation (psy tuning):
                                --bframes {+2} --deblock 1:1
                                --psy-rd 0.4:<unset> --aq-strength 0.6
                                --ref {Double if >1 else 1}
                              - grain (psy tuning):
                                --aq-strength 0.5 --no-dct-decimate
                                --deadzone-inter 6 --deadzone-intra 6
                                --deblock -2:-2 --ipratio 1.1
                                --pbratio 1.1 --psy-rd <unset>:0.25
                                --qcomp 0.8
                              - stillimage (psy tuning):
                                --aq-strength 1.2 --deblock -3:-3
                                --psy-rd 2.0:0.7
                              - psnr (psy tuning):
                                --aq-mode 0 --no-psy
                              - ssim (psy tuning):
                                --aq-mode 2 --no-psy
                              - fastdecode:
                                --no-cabac --no-deblock --no-weightb
                                --weightp 0
                              - zerolatency:
                                --bframes 0 --force-cfr --no-mbtree
                                --sync-lookahead 0 --sliced-threads
                                --rc-lookahead 0
« Last Edit: December 28, 2016, 10:01:50 pm by Krudda »

Offline pjkperker

  • Member
  • Posts: 27
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #9 on: December 29, 2016, 07:33:39 am »
Curious mind wants to know.
How does preset affect filesize ? Slower preset for smaller files ? And does that affect quality in any way ? If I'm to prioritize quality, how should I approach 'preset' ?

Online Krudda

  • Member
  • Posts: 10298
  • 私は 日本語 が 上手 じゃ ありません
    • My Anime List
Re: Anime from VHS with FLAC audio? + What to do with telecined content
« Reply #10 on: December 29, 2016, 10:35:01 am »
In the simplest terms, the slower the preset you use, the more time it devotes to improving the bitrate per frame.
If you choose a fast preset, it just slaps a number on it that seems right, and is good enough.

In the end, you could get better quality by devoting more time to each frame, and additionally, you could save a decent amount of space as it will also compress better.