A Deep Dive into HandBrake and Video Transcoding
robservatory.com
robservatory.com
You'd be better off diving into the foundation of HandBrake and using it directly:
Also, in before, "ffmpeg is too complicated for the average user ..." It isn't, you just need to RTFM.
Typically it involves demuxing the source with eac3to, decoding and indexing the video stream for avisynth (often with ffms2 for Blurays), filtering (such as resizing with a spline kernel, debanding, fixing dirty lines, fixing double range compression, correcting aliasing, removing edge enhancement artifacts, deinterlace/ivtc for DVDs etc.), followed by piping it out through avs2yuv to the x264 encoder. x264 parameters are often hand-tuned over a series of short test encodes at a fixed bitrate. Audio streams are left as is, stripped to the core (DTS-HD MA -> DTS) or transcoded to AC3 (Sony Soundforge), DTS (DTS-HD Master Audio Suite), AAC (qaac/fdkaac) or FLAC. Bitmap subtitles are ripped to text .srt files with subextractor/suprip/SubtitleEdit/ and spell-checked. Finally everything is muxed back together with mkvmerge.
I am quite certain that no audio quality is lost, as the explicit goal is to keep the audio at maximum fidelity.
Not sure what setup you are using, but most cinematic players have a way to do auto-dynamic gain. Or, if you do want a more faithful overall experience, all you really need is a better amp.
The problem is that the "body of knowledge" is rather extensive if you want to cover all the corner cases and imaginative ways in which authoring houses screw things up. To be able to filter the video correctly you need to know a bit how the h264 codec works, learn your color formats, color spaces, a little signal processing, a few tables from ITU-R recommendations and some proficiency in RPN wouldn't hurt. As such it is difficult to put it all down in one guide. To make it worse, as with every niche community there are disagreements and transient "fashions". At the end of the day though this is very much chasing rapidly diminishing returns.
What do you think they use to split the video from the audio in the source file, decode the source video frames, resize and crop every frame, and then mux the resulting new video stream with the (possibly also recompressed) audio stream?
Of course this is no fault of ffmpeg, but a lot of frustrated users end up thinking that anyway.
Nor does this article provide any information enhancing the user's understanding of the encoding options employed by the various presets discussed or the ultimate effects they hold in regard to signal processing.
Video needs to be analysed ideally in the temporal space (i.e as a sequence). I see no mention of the GOP structure or length of the encoding chosen, which would need to be considered.
For example the one frame you have chosen to compare could be an I frame in some of the video compression or could be a P or B frame which would result in slight variance in quality and artifacts.
> "I dumped all the images into separate PNG files, and then used sips to convert the PNGs to somewhat-more-reasonably sized JPGs"
You are adding further compression to the PNGs (the frame grabs) by using JPEG (I assume you are using it in lossy mode), which is basically adding another form of compression to your results.
The fact you used JPEGs (further compression) for comparison basically null and voids all the results I am afraid.
There are much better ways and tools for comparing encoded videos.
Oftentimes you want to remux the video, which means copying it to a new container format without touching the underlying stream. Handbrake doesn't support remuxing (no idea why); you have to turn to ffmpeg on the commandline [1]. Remuxing works if the video and audio codecs are supported by your target but the container isn't, and is very fast—about as fast as copying the file.
With remuxing you still have the option of changing the order of the audio tracks. For example, you can take a Cantonese film with a Mandarin dub and make the Mandarin dub primary so you don't have to fiddle with it (protip if you're learning Mandarin: all the good movies are in Cantonese but they all have Mandarin dubs).
[1] There are GUI options that I haven't explored, see below.
I keep a random google doc of some of my magical ffmpeg incantations that have worked in the past. I usually use it for cutting video segments out of longer vids. Seems like different versions have had different ways of handling things, and/or I really don't know what I'm doing!
for i in *mkv; do ffmpeg -i "$i" -vcodec copy -acodec copy "${i%.mkv}.mp4"; done;
What I discovered was, that unless you are rippling losslessly, your results will vary greatly from film to film.
The advice I give out is:
1. Start with the recommended defaults in Handbrake.
2. Rip a film you know well.
3. View that film on ALL platforms you are likely to view it on. [a]
If you are happy. You are done - keep ripping discs.
If not:
4. Adjust quality up/or down goto #2. Repeat until happy.
Do the above for each GENRE of film - Bright Action movies need different ripping specs compared to period dramas.
--
[a] I did not do this step originally, and the first batch of rips I did, looked good on my 24" monitor, good on my 50" plasma, and awful on my 9ft projector screen!
Pay special attention to videos whose source is TV (as opposed to film) because those sources tend to be interlaced, and you need to play around with the detelecine, decomb, and deinterlace settings. Unfortunately AFAIK Handbrake cannot detect this condition, and if you don't manually account for it, you'll get that ugly horizontal "comb" effect on output, during scenes showing motion.
[1] https://sourceforge.net/projects/megui/
[2] https://en.wikibooks.org/wiki/MeGUI/Tools/One_Click_Encoder
You can switch to "bob" deinterlace if that's an option and it will come out 60fps.
Ripping from DVD and Blu-rays is a lossless process involving the removal of DRM.
Encoding is where the space-saving magic happens, and where settings, and more importantly, bitrate, can lead to varying levels of quality.
DVD/BluRay content is compressed (already encoded).
If you're building an automated system to transcode video ffmpeg/x264 is great (or better yet, use an online transcoding service). For an average user go with Handbrake.
When I cut the cord I started down the path of figuring out how to do all the optimizations myself, but quickly realized just how deep and technical that was. I stumbled upon Don Melton's library and have used it as a key piece of my batch processing pipeline ever since.
Definitely check it out if you are looking to convert arbitrary video files to be played back later on arbitrary devices:
http://webcache.googleusercontent.com/search?q=cache:robserv...
First, the author calls extracting the video/audio of the movie from the Blu Ray (and circumventing the DRM) "ripping". Quote from Article "On the Blu-ray, the music video is 2:18 long. When I ripped it to the hard drive using MakeMKV, the final file size was 279MB."
But then the author also calls encoding the extracted video/audio using HandBrake or transcode-video "ripping". Quotes from the article: "I then fed this .mkv file to both HandBrake and transcode-video, running it through all 26 different conversion options. This table shows the results, sorted by ripping app first..." and "I then copied that same frame from all 26 of the ripped versions of the music video..."
No! No you didn't! You ripped the movie once, and then encoded that 26 times, each time using different options, to compare encode-time, size, and attempted to compare the output quality.
Honestly, confusing these 2 fundamental concepts makes me seriously question your entire experiment.
Was it really that hard to see what they were doing?
I thought the analysis was well written, and the screenshots helped show what was going on, terminology problems aside.
[1]: http://www.linestarve.com/blog/post/rendering-html5-video-wi...
I tend to rip most things with one of two configs I have.. one for br/1080p, another for DVD, and I have a tweaked DVD for bad content (Think Babylon 5)... It took a while to find settings I generally like. I've also taken to letting things run for h.265, since I'm pretty concerned about the space on my nas.
If you aren't trying to match YIFY on your sizes, then you can get away with being a bit more loose on your configs.
Thus I don't find their method of looking at stills to be all that compelling.
If you're working from a source without problems, and they're ending up in the result, Handbrake might be enforcing max rate to hit the H.264 "level" conformance, so "level 5.0" might help. Don't remember if it's got an option for that.
- take a video of varying format (mov, mp4, webm, mkv)
- give it the desired output resolution
- give it the desired output quality preset (simple will do - hi, med, low)
- output resulting file(s)
- do it fast
i have a giant shell script of ffmpeg commands i've used in the past, but i have to stop myself from getting sucked in to trying to understand the whole process and losing a whole day at workhttps://mjanja.ch/2016/07/video-encoding-for-the-web-in-2016...