@don.alcombright said:
Now that I have this up and running in docker (thanks @bjønness) is this a straight remux of the container or does it tweak other things as well? What I don’t want it lose quality. I tested it out on a 480p avi file and it went from 1.3GB to 750MB, which is troublesome to me.
Hey mate. Thanks for the feedback.
This is kind of a difficult question to answer.
Basically, the AVI container uses XVID/mpeg4 video codec. It’s quite inferior by comparison to that of h.264 or h.265. The compression algorithms used in h.265 are extremely good at creating a high quality output file, at a much smaller file size. On average, I can create an output file of h.265/MKV that is around 30-50% smaller than the input, with minimal loss.
To the question of video quality loss: You will always get some loss in any form of compression of video. Think of it like copying a cassette tape in the old ghetto blasters of the 80’s/90’s. If you copy the tape once, it’s a pretty good quality copy. If you copy the copy, then the quality decreases. If you keep doing this over and over, you will eventually end up with just white noise, as the quality decreases with each copy.
That said, I’ve tweaked the script to give as good a quality output as possible (in my eyes at least), with a good amount of compression.
Since I am a noob at stuff like this, I may be asking something stupid.
Would it be possible to change the format to mkv without compression and then quality loss? I don’t care about the file size (as long it is not much bigger than the original), just want to it be as close to the original quality as possible.
As I said, I really know nothing about stuff like this… :-/
@bjønness said:
Since I am a noob at stuff like this, I may be asking something stupid.
Would it be possible to change the format to mkv without compression and then quality loss? I don’t care about the file size (as long it is not much bigger than the original), just want to it be as close to the original quality as possible.
As I said, I really know nothing about stuff like this… :-/
That’s actually a really good question!
MKV is probably the most versatile video container format available to date.
Think of a container format as a zip file. In of itself, it contains nothing, unless you put something in it, right?
Well, different containers, can contain different codecs. Some are capable of more than others. You can see a list of what each kind of container supports here (look for the name “Matroska”, it’s the long name version of MKV)
To answer your question, MKV is capable of containing the codecs used in most videos. So yes. It is possible, using the -c:v copy switch, which will just copy the content of the video from one container format into another.
The problem is, it still requires a player that supports that kind of codec. So if you player can open MKV’s but cannot play mpeg4, then Plex will still transcode it to something your player will read.
The goal with transcoding with a script like mine, is to get all of your videos using a single codec that is supported by the majority of your devices, therefore saving CPU time on your Plex Server.
@don.alcombright said:
thanks and sounds good. Ya, I was only testing it with a crappy file. I have about 50 movies in weird formats that I want to switch over to mkv.
Here is a comparison of video quality and size after conversion to h.265.
These are from my own personal collection, so you can see a real world comparison. Remember, I have set mine to use the ultrafast preset, as I honestly don’t care about the output quality of these videos.
@TomasJAnderson said:
Can we use this script in a recursive manner ?
At the moment, no. The problem is that the recursion throws out the filetype search. That’s one of the big problems I have. I really want to use it for recursive file finding.
As soon as I have a working test, I’ll post it for you
@ChuckPa - Hey buddy, thought I’d update you on ffmpeg. The script definitely doesn’t work ffmpeg, however there is something interesting you might like to know.
As of about Ubuntu 15.04, when you install avconv, it also installs ffmpeg. From what I can tell, it seems like avconv has become a wrapper for ffmpeg, with it’s own input variables that it then converts to ffmpeg variables, and runs the command using ffmpeg binaries.
It’s odd, and avconv is still the primary binary of choice, but that it now seems to be directly intertwined with ffmpeg kinda shows that it may be a move toward merging the two again.
Basically, this points to a future where the two are one in the same again. Interesting, no?
Trying this out on my unRAID server and I don’t see it really working. Pretty sure I’ve followed the directions that Bjonness406 provided. I’ve changed the appropriate lines in the convert2mkv.sh file and when I run the docker it makes a MP4 file that is about 1KB big. I see no log files in the appdata folder either so I can see whats happening. What am I missing? Do I need to install anything else so that it can be converted? When I installed the docker I just left everything at default.
@djsnafu said:
Trying this out on my unRAID server and I don’t see it really working. Pretty sure I’ve followed the directions that Bjonness406 provided. I’ve changed the appropriate lines in the convert2mkv.sh file and when I run the docker it makes a MP4 file that is about 1KB big. I see no log files in the appdata folder either so I can see whats happening. What am I missing? Do I need to install anything else so that it can be converted? When I installed the docker I just left everything at default.
@djsnafu said:
Trying this out on my unRAID server and I don’t see it really working. Pretty sure I’ve followed the directions that Bjonness406 provided. I’ve changed the appropriate lines in the convert2mkv.sh file and when I run the docker it makes a MP4 file that is about 1KB big. I see no log files in the appdata folder either so I can see whats happening. What am I missing? Do I need to install anything else so that it can be converted? When I installed the docker I just left everything at default.
Can you post your docker log?
Couldn’t paste the log here because it was 12453 characters too long.
For me it looks like it is a problem with the script itself, just tested and getting the same error message as you. Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
It works fine with mkv, so it looks like a problem when you change to mp4.
Hopefully @ntrevena can take a look at this.
i am using my own ffmpeg script to convert-remux all mkv files to direct playable mp4 files on linux.
i have created a mkv2mp4 script in /usr/bin. My Root plex library folder is /hdd2/plex. I am watching this directory with Watcher python script (https://github.com/gregghz/Watcher) and if there is a new mkv file, watcher script is triggering my mkv2mp4 script to remux the new mkv files to mp4(recursively).
find . -name "*.mkv" to find mkv files in current directory (recursively) -metadata title=" " to remove any title information from source mkv file thats coming from rip-convert software, -c:v copy to copy source input video encoding to target mp4 file (x264, x265 etc.), -c:a libfdk_aac -ac 2 to convert audio stream to AAC 2.0, -movflags +faststart to moving the moov atom, the output mp4 file will be web/stream optimized for plex "${1%.mkv}.mp4"' to creating a movie.mp4 file from the source file movie.mkv, -exec sh -c 'rm -fr "$1"' to remove source mkv file after remuxing to mp4
Apologies that I’ve been MIA. I’ll review what’s been done so far, and see if I cant help out a bit. I was thinking about rewriting it to accept command line switches.