View Full Version : ffxvid for Linux/BSD


microchip8
17th February 2017, 21:04
I've received a number of requests from people who asked for a script that helps to encode to Xvid, so here it is. It's a modified script of ffx264 for Xvid encoding with FFmpeg

https://sourceforge.net/projects/ffxvid/

Enjoy

microchip8
18th February 2017, 17:55
ChangeLog for ffxvid 1.0.2

* Switch to using libxvid instead of mpeg4 encoder
* Set appropriate threads amount for encoding
* Update default encoding options

microchip8
19th February 2017, 06:19
ChangeLog for ffxvid 1.0.3

* Enable Variance AQ by default
* Correct a few things in man page
* Update the preset.txt file

microchip8
22nd February 2017, 16:15
ChangeLog for ffxvid 1.0.4

* Support high FPS -> low FPS conversions
* Bugfix: missing options in FPS conversion menu

microchip8
18th March 2017, 22:57
ChangeLog for ffxvid 1.0.5

* Update audio compression level values
* Update colorspace entry for NTSC video
* Fixed bug in the video_colorspace_func() values

microchip8
13th May 2017, 19:11
ChangeLog for ffxvid 1.0.7

* Support accurate rounding for the software scalers
* Support full chroma interpolation for the software scalers
* Use the flags option of the scale option instead of -sws_flags to set scaler and its options
* Bugfix: software scaler code missing

microchip8
14th May 2017, 10:33
ChangeLog for ffxvid 1.0.8

* Bugfix in the software scale code. Use an if conditional to check for an y/n answer

microchip8
16th May 2017, 09:50
ChangeLog for ffxvid 1.0.9

* Added support for FFmpeg's internal Opus audio encoder

microchip8
1st June 2017, 13:02
ChangeLog for ffxvid 1.1.0

* Simplify the scale variable a bit
* Support SMPTE170M colorspace conversion

microchip8
4th June 2017, 22:40
ChangeLog for ffxvid 1.1.1

* Match software scaler options in config file with the ones inside the script. $SCALER in config file now takes a value between 0 and 9
* Do some basic checking of scaler option when it's set in the config file

microchip8
5th June 2017, 04:51
ChangeLog for ffxvid 1.1.2

* Remove redundant software scaler warning and exit in the sws_func() function for the config file
* Added support for the experimental software scaler
* Added support for software scaler tuning where applicable
* Removed additional encoder info on max audio channels support

microchip8
8th June 2017, 15:44
ChangeLog for ffxvid 1.1.3

* Report software scaler set in the config file
* Merge the bicubic and spline scaler tuning code
* Mention for the Lanczos scaler that the scaler tuning value is the filter length and not sharpness

microchip8
9th June 2017, 09:46
ChangeLog for ffxvid 1.1.4

* New function, video_chars_func(), to detect and display video characteristics like color range/space/transfer/primaries
* Detect and display video resolution if video scaling is enabled
* Detect and display pixel format

microchip8
10th June 2017, 08:51
ChangeLog for ffxvid 1.1.5

* Replace numbers in array variable char of the video_chars_func() function with the ones from the for loop
* Pipe the ffprobe string to tail -1 to work around issues with some problematic files
* Some small improvements to the video_colorspace_func() function

microchip8
13th June 2017, 00:57
ChangeLog for ffxvid 1.1.6

* Bugfix in the video_colorspace_func() function. Wrong value used for the ispace option of the filter. Must be bt2020ncl instead of just bt2020

microchip8
14th June 2017, 13:11
ChangeLog for ffxvid 1.1.7

* Make software scaler tweaking optional
* Added support for the unsharp filter for sharpen/blur
* Use a colon symbol as separation for input/output color range in the video_colorspace_func() function as to be consistent with the other options. Also set the default to tv:tv

microchip8
20th July 2017, 19:45
ChangeLog for ffxvid 1.1.8

* Bugfix: use realpath instead of readlink for the OUTPUT var when running in batch mode. Fixes the issue where readlink will follow the full path in case the input is a symlink which may result of encoding files we were not asked to
* Don't print cropped resolution during runtime if batch mode is selected
* Remove check for realpath. It is now required and not optional

microchip8
23rd August 2017, 10:50
ChangeLog for ffxvid 1.1.9

* Support full chroma input for the software scaler

microchip8
29th September 2017, 16:42
ChangeLog for ffxvid 1.2.0

* Support setting the output video aspect ratio

microchip8
22nd October 2017, 18:32
ChangeLog for ffxvid 1.2.1

* Support dialog level normalization for AC3/EAC3 audio

microchip8
26th December 2017, 08:19
ChangeLog for ffxvid 1.2.2

* Initial support for HDR to SDR conversions. Requires FFmpeg to be compiled with the zimg library as it needs the zscale filter https://github.com/sekrit-twc/zimg

microchip8
27th December 2017, 15:05
ChangeLog for ffxvid 1.2.3

* Renamed array variable CHARS to VCHARS in the video_chars_func() function
* Report pixel format in the video_chars_func() function
* Use -v quiet instead of -v error log level for ffprobe
* Cosmetics

microchip8
2nd January 2018, 00:06
ChangeLog for ffxvid 1.2.4

* Reworked the video_chars_func() function and added reporting of video bit depth
* Initial support for audio codec metadata when doing audio copy
* Increased default E-AC-3 audio bitrate from 768 to 960 kbps
* Set dialnorm for AC-3/E-AC-3 to its FFmpeg default (-31)
* Use a desat value of 2.5 for the tonemap filter when doing HDR to SDR conversions
* Don't use pix_fmts in the format filter. It is not really needed
* Removed 12-bit options from the video_pixfmt_func() function
* Cosmetics

microchip8
4th January 2018, 22:42
ChangeLog for ffxvid 1.2.5

* Don't hardcode the desaturation strength of the tonemap filter but let is be an option
* Removed the matrix and primaries options in the zscale filter as it leads to over-saturation of colors
* Support tweaking the tonemap algorithms for HDR to SDR conversion
* Support applying color saturation correction when doing an HDR to SDR conversion
* Added bt2020-12 to the list of transfers when doing color characteristics copy
* Added HDR_to_SDR_instructions.txt file to the package

microchip8
9th January 2018, 21:43
ChangeLog for ffxvid 1.2.6

* Moved the eq filter to almost the end of the video filter chain as it can lead to banding in certain cases in case the filter is in front of most other ones
* If the eq filter is used, also insert the format one after it if a pixel format has been chosen
* Fixed a possible devision by 0 that may occur when one copies audio and the bitrate for metadata is reported as N/A by ffprobe

microchip8
20th February 2018, 12:52
ChangeLog for ffxvid 1.2.7

* Fixed an issue where in some cases write-testing the output directory will fail due usage of readlink -f instead of readlink -m
* Update transfer chars to support latest changes to zimg from git

microchip8
26th February 2018, 21:51
ChangeLog for ffxvid 1.2.8

* Set the eq saturation default value to 1.0 (same as filter default)
* Add the colorspace and colormatrix filters when doing an HDR to SDR conversion
* Lower tonemap desat strength to 2.8
* Support white point adaptation for HDR to SDR
* Moved the colorspace filter after the scale one
* Moved the pixel format filter near the end of the filter chain

microchip8
14th June 2019, 19:42
ChangeLog for ffxvid 1.2.9

* Added support for the bm3d denoise filter

microchip8
23rd July 2019, 12:23
ChangeLog for version 1.3.0

* Added support for crop preview using MPlayer when autocrop is enabled in the config file. This was ported over from my h264enc script

microchip8
21st August 2019, 15:38
ChangeLog for ffxvid 1.3.1

* Add audio sample rate to the audio metadata

microchip8
29th August 2019, 08:53
ChangeLog for ffxvid 1.3.2

* Use a comma instead of a dash for the audio sample rate metadata

microchip8
5th September 2019, 04:33
ChangeLog for ffxvid 1.3.3

* Code optimization in the audio sample rate metadata

microchip8
13th September 2019, 15:13
ChangeLog for ffxvid 1.3.4

* Add audio channel metadata when using audio copy

microchip8
18th September 2019, 09:01
ChangeLog for ffxvid 1.3.5

* Improvements to the audio copy metadata

microchip8
19th September 2019, 05:00
ChangeLog for ffxvid 1.3.6

* Support encoding to WMAv1 and WMAv2 audio
* Update high bit depth pixel formats options
* Add WMAv1 and WMAv2 audio detection metadata when doing audio copy

microchip8
21st September 2019, 06:33
ChangeLog for ffxvid 1.3.7

* Add side channel info to the audio metadata

microchip8
22nd September 2019, 05:54
ChangeLog for ffxvid 1.3.8

* For audio stream copy, in case ffprobe reports channels layout as unknown, try to guess the amount of channels based on channel detection and use that as metadata
* Set Mobisu transform as default for HDR to SDR
* Updated the man page

microchip8
25th September 2019, 07:26
ChangeLog for ffxvid 1.3.9

* Use the audindex[i] variable for audio metadata during audio copy
* Don't use audio metadata when using audio copy and running in batch mode
* Updated default audio bitrates for some codecs

microchip8
25th September 2019, 15:06
ChangeLog for ffxvid 1.4.0

* Revert using audindex[i] var for audio metadata during copy

microchip8
11th October 2019, 11:28
ChangeLog for ffxvid 1.4.1

* Support hardcoding external or embedded subtitles. Requires libass support in FFmpeg
* Fixed a typo in the subtitles code

microchip8
13th October 2019, 06:39
ChangeLog for ffxvid 1.4.2

* Use readlink -e and realpath -e where needed
* Cosmetics

microchip8
14th October 2019, 15:35
ChangeLog for ffxvid 1.4.3

* Support scanning for multiple video tracks in the input file

microchip8
15th October 2019, 05:00
ChangeLog for ffxvid 1.4.4

* Bugfix: use correct video mapping for crop detection

microchip8
16th October 2019, 06:24
ChangeLog for ffxvid 1.4.5

* Support the fftdnoiz denoise filter

microchip8
17th October 2019, 06:42
ChangeLog for ffxvid 1.4.6

* Support the WMV container format

microchip8
18th October 2019, 06:02
ChangeLog for ffxvid 1.4.7

* Bugfix: use correct video track for crop preview with MPlayer
* Bugfix: missing ;; in the additional container formats code
* Renamed variable SCAN_MULTIPLE_VID_TRACKS to SCAN_MULTI_VID_TRACKS
* Some reordering in the config file
* Set Catmull-Rom as default Bicubic/Spline tuning
* Add LPCM detection for audio copy
* Support the mp4/m4v containers
* Add support for cover art for the mp4/m4v/mov containers. Requires MP4Box from GPAC
* Some code optimization

microchip8
19th October 2019, 08:20
ChangeLog for ffxvid 1.4.8

* Use atomicparsley to add cover art for the mp4/m4v containers. This removes dependence on MP4Box and makes it possible to copy over metadata info in an easy way
* Add +frag_keyframe to the -movflags option when output is mp4
* Renamed variable METACOVER to MKVCOVER
* Updated the man page

microchip8
20th October 2019, 05:44
ChangeLog for ffxvid 1.4.9

* Added support for embedding of SRT/SSA/ASS subtitles in the MP4/M4V containers
* Moved back to MP4Box for adding cover art to MP4/M4V/MOV. Apparently, after lots of testing, atomicparsley creates files that hang during playback
* Cosmetics
* Updated the man page

microchip8
21st October 2019, 04:42
ChangeLog for ffxvid 1.5.0

* Add support for verbose logging to a log file
* Bugfix: -map_metadata and -map_chapters where not set to 0 when the respective options in the config file were set to "y"

microchip8
21st October 2019, 09:48
ChangeLog for ffxvid 1.5.1

* Renamed variables $MDATA and $CHPS to $METADATA and $CHAPS
* Add $METADATA and $CHAPS to the remuxing code

microchip8
22nd October 2019, 05:25
ChangeLog for ffxvid 1.5.2

* Add support for SRT/SSA/AAS subtitles for the MOV container
* Remove the colorprim lines from the video_colorspace_func() function. They are not used

microchip8
23rd October 2019, 04:22
ChangeLog for ffxvid 1.5.3

* Set default audio codec based on output container format
* Add colr option for MP4Box to the video_colorspace_func() function and the color primaries code. Only used for MOV
* Add -color_primaries, -color_trc and -colorspace to the FFmpeg command line options

microchip8
24th October 2019, 06:20
ChangeLog for ffxvid 1.5.4

* Add constant/non-constant matrix option to the video_csmisc_func() function

microchip8
25th October 2019, 06:36
ChangeLog for ffxvid 1.5.5

* Detect audio bit depth and add it to the audio metadata
* Added detection for DTS Express and DTS-HD HR for audio copy
* Use -show_entries instead of -show_streams for detecting audio properties with ffprobe. Removes piping to grep and awk
* Support setting the FLAC bit depth for encoding
* Minor restructuring and variables renaming in the audio code
* Updated the man page

microchip8
26th October 2019, 08:09
ChangeLog for ffxvid 1.5.6

* Renamed audio variable aid[i] to aidx[i] and moved it outside of the if conditional that decides the audio codec. This removes the same code in three places and now uses the global aidx[i] variable
* HE-AACv2 only supports 2 channels. Update the audio code to reflect that
* When running in batch mode, add a warning about automatic audio metadata and offer an option to enable/disable it
* Added -tmp option to MP4Box to store temp files in the output directory
* Some minor improvements to the audio options

microchip8
27th October 2019, 09:32
ChangeLog for ffxvid 1.5.7

* Use 16 bits as bit depth metadata when encoding to TrueHD audio
* Removed an unneeded if conditional in the audio bit depth code
* Add director and cast metadata for the MKV container
* Reorder some code for the output shell file
* Cosmetics

microchip8
28th October 2019, 06:34
ChangeLog for ffxvid 1.5.8

* Added support for director/cast metadata for MP4/MOV/M4V
* Added +use_metadata_tags to the $movflags variable for MP4/MOV/M4V
* Support ADPCM encoding for DTS audio
* Fixed an issue where asking for director/cast occured multiple times if remuxing to other containers was enabled

microchip8
29th October 2019, 07:18
ChangeLog for ffxvid 1.5.9

* Removed an unneeded check for audio codec in the conerror_func() function
* Removed a stale "" in the case statement that checks the channels for AC3
* Support setting the matrixed stereo type when resampling stereo input
* Support setting the filter type of the audio resample filter
* Cosmetics

microchip8
4th November 2019, 17:32
ChangeLog for ffxvid 1.6.0

* Merged two case statements in the metadata code for mkv/mp4/mov
* Bugfix: Using ADPCM encoding for DTS audio wasn't possible due to wrong variable used in the if conditional

microchip8
11th November 2019, 14:52
ChangeLog for ffxvid 1.6.1

* Added support for the (newer) deblock filter

microchip8
28th December 2019, 16:41
ChangeLog for ffxvid 1.6.2

* Add support for the noise video filter. Can be beneficial on (very) clean sources by applying some noise to avoid things like color/light banding in the encode

microchip8
23rd February 2020, 15:59
ChangeLog for ffxvid 1.6.3

* Use MPlayer for crop detection instead of FFmpeg which seems to have issues with 4k/UHD content

microchip8
5th March 2020, 22:09
ChangeLog for ffxvid 1.6.4

* Go back to FFmpeg for crop detection

microchip8
9th March 2020, 21:13
ChangeLog for ffxvid 1.6.5

* Bugfix: missing if conditional in the crop code

microchip8
23rd March 2020, 07:11
ChangeLog for ffxvid 1.6.6

* Add -max_muxing_queue_size switch to workaround possible issues when muxing Atmos/DTS-X audio

microchip8
16th June 2020, 20:09
ChangeLog for ffxvid 1.6.8

* Support TrueHD audio in the MP4 container

microchip8
21st June 2020, 16:11
ChangeLog for ffxvid 1.6.9

* Fixed a bug that prevents using TrueHD mono audio in the MP4 container

microchip8
27th December 2020, 19:34
ChangeLog for ffxvid 1.7.0

* Fixed a long standing bug where audio mapping values were incorrect for audio metadata resulting in incomplete or wrong values

microchip8
28th December 2020, 02:51
ChangeLog for ffxvid 1.7.1

* Fix a bug in the $vidtrack variable

microchip8
22nd January 2021, 09:01
ChangeLog for ffxvid 1.7.2

* Remove "a" from the -ac audio option
* Fix possible negative index in the audio option

microchip8
2nd February 2021, 15:07
ChangeLlog for ffxvid 1.7.3

* Replace the yadif deinterlacer with bwdif. It's faster and provides higher quality

microchip8
23rd January 2023, 11:38
ChangeLog for ffxvid 1.7.4

* Support more deinterlacing filters

Blue_MiSfit
1st February 2023, 09:27
I've never used this app, but I'll say thank you for folks who do! I appreciate your efforts :)

microchip8
1st February 2023, 10:41
I've never used this app, but I'll say thank you for folks who do! I appreciate your efforts :)

Thanks. It's just a Bash shell script I write mainly for myself as I spend many hours working in the terminal on Linux so I need something CLI/terminal-based for encoding too...

microchip8
17th August 2023, 04:48
ChangeLog for ffxvid 1.7.5

* Fix crop detection for HDR content
* Set Lanczos as default scaler option

microchip8
7th January 2024, 20:24
ChangeLog for ffxvid 1.7.6

* Improved compatibility with the BSDs
* Set the setpts + atempo option as default for FPS conversion
* Set side/wide audio channels as default
* Support the newly added channels for TrueHD audio
* Bugfix in the video_noise_func() function
* Improved FPS detection code

microchip8
4th February 2024, 17:49
ChangeLog for ffxvid 1.7.7

* Don't exit but warn about MP4Box/Mplayer missing from the user's system

microchip8
28th February 2024, 23:16
ChangeLog for ffxvid 1.8.0

* Initial support for zimg (z lib) scalers

microchip8
28th October 2024, 17:17
ChangeLog for ffxvid 1.8.1

* Updated the audio copy code to detect Dolby Atmos and use the correct name metadata
* Renamed a few variables

microchip8
30th October 2024, 21:57
ChangeLog for ffxvid 1.8.2

* Reduced duplication in the final audio params code variable
* Use kHz instead of Hz for audio sample rate metadata
* Slightly increased default value of the noise filter
* Updated the AUTHORS file (email address)

microchip8
1st November 2024, 15:39
ChangeLog for ffxvid 1.8.3

* Added support for copying only the DTS Core audio or the full DTS-HD MA audio track

microchip8
2nd November 2024, 10:20
ChangeLog for ffxvid 1.8.4

* Support copying full DTS-HD HRA audio or just the DTS Core in it
* Support copying full Dolby Atmos audio or just the AC-3/TrueHD Core in it

microchip8
3rd November 2024, 14:39
ChangeLog for ffxvid 1.8.5

* Support copying full DTS-X audio or only the DTS core

microchip8
6th November 2024, 11:19
ChangeLog for ffxvid 1.8.6

* Fixed a bug in the video_hdr_to_sdr_func() function
* Replaced the detelecine filter with a combination of the fieldmatch, bwdif and decimate filters
* Use 0 as default value for the tonemap desat filter option

microchip8
8th November 2024, 11:10
ChangeLog for ffxvid 1.8.7

* Support copying the DTS core-only from DTS 96/24 and DTS:X IMAX tracks
* Updated the AAC profile detection for audio copy

microchip8
11th November 2024, 12:35
ChangeLog for ffxvid 1.8.8

* Do colorspace conversion before scaling

microchip8
18th November 2024, 14:16
ChangeLog for ffxvid 1.8.9

* Fixed a bug in the audio metadata when copying the Dolby core audio that added "+ Atmos" to the metadata
* One-line micro-optimization in the Dolby metadata code

microchip8
21st November 2024, 16:17
ChangeLog for ffxvid 1.8.10

* Added support for disabling automatic metadata such as video title, audio codec names, etc through the config file

microchip8
26th November 2024, 12:02
ChangeLog for ffxvid 1.8.11

* Fixed a syntax error in the video_deinterlace_func() function. Reported by Christian Marillat

microchip8
6th June 2025, 21:26
ChangeLog for ffxvid 1.8.12

* Increased default noise value from 4 to 5
* Fix wrong default option for tonemap algo
* Delete side data when doing HDR -> SDR conversion
* Updated the AUTHORS, README and man page files

microchip8
15th November 2025, 15:01
ChangeLog for ffxvid 1.8.13

* Support setting the default zimg scaler in the config file
* Use Natural Bicubic Spline FFmpeg scaler as default in-script scaler and Spline36 scaler as default for zimg
* Minor improvements to the scaling code
* Updated the README and man page files

microchip8
28th November 2025, 21:19
ChangeLog for ffxvid 1.8.14

* Add support for Spline64 zimg zscale filter. Requires latest FFmpeg from git

microchip8
21st December 2025, 13:14
ChangeLog for ffxvid 1.8.15

* Bugfix in the zscale scale filter for Lanczos3/4

microchip8
22nd January 2026, 12:02
ChangeLog for ffxvid 1.8.16

* Use more accurate crop detection by using rounding of 4 instead of the default 16

microchip8
3rd March 2026, 08:06
ChangeLog for ffxvid 1.9.0

* Set Spline64 as default zimg scaler
* Remove dependency on MPlayer and use ffplay instead for crop previews
* Updated the man page

microchip8
27th May 2026, 07:56
ChangeLog for ffxvid 1.9.1

* Add support for encoding 7.1 channels E-AC-3 audio. Requires latest FFmpeg from git

microchip8
10th August 2026, 16:37
ChangeLog for ffxvid 1.9.2

* Add support for the AC-3 fixed point encoder
* Add support for disabling DRC (Dynamic Range Compression) for the AC-3/E-AC-3 audio codecs

microchip8
16th August 2026, 10:24
ChangeLog for ffxvid 1.9.3

* Disabling of (E)AC3 DRC is only possible when converting to the same or another codec. If doing stream copy, warn and disable the option in case input is (E)AC3

microchip8
19th August 2026, 09:59
ChangeLog for ffxvid 1.9.4

* Bugfix: detection code for disabling of (E)AC3 DRC was missing