Skip to content

fangornsrealm/ffmpeg-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FFMPEG scripts I have lying around

These are some scripts for doing things with ffmpeg that I use or have used heavily.

There are families and specializations here.

  • 2mkv and it's siblings are for simple videos. They convert a single video stream to HEVC and a single audio audio to mp3 and drop everything else. This is for making downloads usable on hardware and saving space.
  • 2movie and it's siblings are what you want to use for anything that had multiple audio streams or subtitle streams. They convert the video stream into HEVC and copy everything else, including the metadata.

There are specializations for hardware.

  • The base script (without suffix) uses libx254 and therefore uses the CPU (very slow but theoretically better quality)
  • _nvenc scripts are for NVIDIA GPUs. They are much faster than CPU. And since RTX 2000 series they are good enough to archive, at least in my opinion.
  • _qsv scripts are for INTEL QuickSyncVideo for integrated GPUs. Very fast and very good. If you still have an INTEL CPU.
  • _arc scripts are for new INTEL GPUs of the Alchemist and Battlemage generation. Extremely fast and good quality. The AI scaling is much better than what the TVs or boxes do on the fly. And oders of magnitude faster than Video Enhance AI.
  • _amf scripts are for modern AMD GPUs. According to the manuals this should work. But I never got it to start on my integrated GPU on a 7950.

There are also special purposes. The names should be quite speaking.

_denoise_nlmeans and _nlmeans use the nlmeans denoise algorithm to clean noisy video. The result is very good. But effort is extremely high! There is an OpenCL accelerated version that can use the thousands of processors on a GPU which is still going to take many hours to clean a 120 minute movie. The pure CPU version is much slower than that. _scale is the original version that automatically scales based on the input size. The new 2mkv versions also have this scaling as well. The default to convert the throwaway videos to around 1080p, but scale by integer values to preserve quality. Here the _arc versions shine because of the AI upscaling and enhancing engine in the hardware. _amf now very freshly contains also FSR upscaling known from games. Theoretically this should give similar results. But as written before, my test did not succeed to use the hardware.

mfatal

For reference I'm including mfatal.pl. The code is more than ten years old. This is a product of a time when there was TV worth recording and movies you wanted to have in your collection. It aimed to be the swiss-army knife of media conversion. It is an orchestration tool. Previous versions were split up into different tasks and heavily relied on external programs to do the actual work. The combined version used ffmpeg wherever possible.

The main feature of mfatal always was the do what I mean approach. The user says I want all videos in MP4 containers. Or in .ogm containers. Or as a .ts Transport stream. The user does not have to say more. mfatal knows the supported formats for video, audio and subtitles for the supported containers. If you don't say any more it will pick a good default for the video and copy all other streams. If a format is not supported by the container, it will convert it automatically. If you pick a format that is not compatible with the container yoy want, mfatal will inform you when the run starts. The user can also write the preferred settings into a config file and just run the program with. It can do outright crazy stuff as well. Like changing the frame rate to match the length of an audio stream. And adjust the time codes of chapter marks and subtitle streams automatically. If you should be one of the two people on earth that needs that feature. That speed change adjustment feature is entirely done in the perl code, so it should still work fine whenever the playback speed is changed. By default it does not tell ffmpeg to change the speed of the audio, though.

I made sure that it is running on current PERL 5. I don't have the capacity - or the test samples - to test if each and every functionality it has still works with modern ffmpeg. If you take a glance at the help text you might get an idea why. If somebody wants to try, I also have a collection of old programs that were hard to find in 2015 that are still necessary for very esotheric functionality.

Because the code is so old the video encoding uses CPU encoding only. The top codec supported is h.264. But there are redeeming qualities if you happen to have a use case. I personally haven't had that use case for over a decade. But there might be people who do. There is a feature to override the video encoder settings, which will give you the hardware accelerated encoding if you use NVENC. Include this in your config file.

override_video_encoder    = -c:v hevc_nvenc -preset p7 -tune hq -rc constqp -qp 27

This does not work if you have to change more than the encoder part of the command line, though.

If you have a use-case and want perfect batch capability and sane defaults, mfatal is your best bet. You can point it to a directory with media in different format and tell it to convert everything to the same parameters. And it will do so, even if the job takes months.

I would not use the CPU video conversion, nowadays, though. ARC and NVENC are good enough in my opinion. At least for a private archive of videos. I could not test AMF for quality or speed. It should be quick to add the hardware accelerated encoding command lines from the modern scripts into the code. They make encoding parameters so much easier. Just set an average quality and let it rip through gigabytes of your video. ffmpeg can be told to just copy all other streams. But if you want ffmpeg to do specific things to streams - of different languages, of different encoding, of different number of channels, ... - the ffmpeg command line gets complicated quickly. I found out how to do all the things, immortalized it into code and immediately forgot all about it. Things like this are meant to be automatically generated. Because they work if they are and usually you do a sequence of trial and error if you do it by hand.

About

A collection of media conversion scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published