Log in

View Full Version : file2dvd for Linux


Pages : [1] 2

microchip8
10th February 2013, 14:10
Hi,

I wrote a small script for converting video files into DVD compliant encodes and structures. The main reason for writing it was so I can watch DVDs on my Medion TV which has an integrated DVD player, but doesn't support DivX/Xvid and co codecs. The output from the script works with no issues on my DVD player but I can't guarantee it will do the same on other DVD players. Best is to test and see.

Requires bc, MPlayer, ffmpeg (for encoding), dvdauthor and mkisofs (which should be a link to genisoimage)

http://sourceforge.net/projects/file2dvd/

PS: this script is dedicated to my mom, who's a big movie lover and who passed away from cancer on the 26th of January 2013.

Darksoul71
19th February 2013, 19:46
Hi there,

thanks for sharing this...it is always nice to see how other people solve their problems.
And sorry to hear about your mother. It always hurts when a beloved one goes away.

I must admit that I rather use Windows plus the Freemake Video Converter for such purposes. You simply drag in your source video(s), choose the output format and click on "go". :)

Just allow me a comment / question:
May I ask why you mainly use Bash scripting for your tools ?
Personally I always found Python more suitable and simpler for a lot of purposes (e.g. string processing, calculation). I often simply "glue" together a few bash arguments with Python and do things like string processing, comparison, etc in Python.

Here are three examples for my crappy scripts.

MKV DTS to AC3 converter (converts DTS to AC3 streams and strips DTS streams):
http://pastebin.com/w6JtVczr

MKV DTS to AC3 converter (which only adds AC3 streams to the MKV and leaves the DTS streams in place):
http://pastebin.com/0QaYSWFC

A simple multi process MP3 encoder:
http://pastebin.com/Cd71eU6a

microchip8
19th February 2013, 19:57
Hi Darksoul71

Thanks for the heads up. The reason why I use Bash is because it's the only thing I know at the moment and I lack the time to learn something new and probably better than shell scripting.

Darksoul71
19th February 2013, 20:28
Hi Darksoul71

Thanks for the heads up. The reason why I use Bash is because it's the only thing I know at the moment and I lack the time to learn something new and probably better than shell scripting.

Well, Python is pretty straight forward. Simply have a look at my three examples and all the other scripts around in the web.

Darksoul71
20th February 2013, 15:15
Just a short note:
Not all of the encoding parameters you use, are supported by the standard version of ffmpeg included with Ubuntu-based distro.

Using your script under the latest Linux mint version I get this error messages:

Unrecognized option 'mpv_flags'
Failed to set value '+cbp_rd' for option 'mpv_flags'

microchip8
20th February 2013, 15:20
Just a short note:
Not all of the encoding parameters you use, are supported by the standard version of ffmpeg included with Ubuntu-based distro.

Using your script under the latest Linux mint version I get this error messages:

Unrecognized option 'mpv_flags'
Failed to set value '+cbp_rd' for option 'mpv_flags'


Yes, I know. You need a more recent version like ffmpeg 1.0.x or higher. If you can't get it, modify the options at the top of the script

Darksoul71
20th February 2013, 17:22
So, in other words one is better off to use a pre-compiled static version of ffmpeg from pages like this:
http://ffmpeg.gusari.org/static/64bit/

:)

microchip8
20th February 2013, 17:24
Sure, but if your distro provides a supported version (1.0 and higher) you can use it instead. My openSUSE 12.2 has ffmpeg 1.0.4 and it works with no issues

Darksoul71
20th February 2013, 18:27
Yes, for sure ! :)
I just wanted to highlight this ! Those error messages about unsupported options are simply not self-explaining for people which are not skilled with the shell and / or the standard Linux AV tools such as ffmpeg or mencoder.
That's why I highlighted it.

microchip8
20th February 2013, 18:44
Yes, I understand that but on the other way, omitting them to support a broader range of ffmpeg versions sacrifices quality :P

microchip8
24th February 2013, 12:19
@Darksoul71

I looked at your Python scripts and I must say it looks Chinese to me, haha. I'm so used to Bash that I guess I'll have difficulties learning something else.

Darksoul71
24th February 2013, 12:21
@froggy1: Agreed....I had the benefit of a one week seminar about coding Python last year.
This was my entry...but I have to admit that my code is quite ugly....
In the end: It works for me and this is all what is important to me :)

microchip8
14th March 2013, 21:54
ChangeLog for version 1.6

* Use XML file for dvdauthor
* Be compatible with dvdauthor version 0.7.x

microchip8
15th March 2013, 18:38
ChangeLog for version 1.7

* Added resolution to the dvdauthor XML file
* Added chapter marks at every 5 minutes to the dvdauthor XML file
* Few typo fixes

microchip8
11th May 2013, 14:08
ChangeLog for version 1.8

* & character is often present in movie titles. Escape it in the dvdauthor XML file

microchip8
13th May 2013, 12:41
ChangeLog for version 1.9
* Added workaround for input files with spaces in their name

microchip8
14th May 2013, 16:09
ChangeLog for version 2.0

* Added one more preset (-nq - Normal Quality)
* Added -v option to display version
* Added -h option for help info. Currently this just calls the man page
* All presets now use a dash (eg, -vhq) for consistency reasons
* Use -vf scale instead of -s for resolution scaling
* Add Volume ID when creating ISO file
* Updated the man page

microchip8
15th May 2013, 09:26
ChangeLog for version 2.1

* Added support for a config file. It will be located in $HOME/.file2dvd. In the config file one can set the default output dir, default scaler,
default nice value and the paths to the programs
* Allow user to specify the passmode (ie, 1-pass or 2-pass encoding). This introduces the -1p and -2p switches
* Check status of ffmpeg. Abort and clean up if it's not successful and notify the user
* Check status of dvdauthor. If successful, proceed with ISO creation. If not successful, warn and exit
* Remove dvdauthor XML file upon success
* Updated the man page

microchip8
16th May 2013, 10:02
ChangeLog for version 2.2

* Added support for interlaced encoding and deinterlacing
* Use -trellis 2 for the -vhq, -ehq and -uhq presets
* Set GOP to 15 for PAL and 18 for NTSC

microchip8
17th May 2013, 09:35
ChangeLog for version 2.3

* Don't use -target pal|ntsc-dvd and instead go the "manual" way of config. This approach seems to eliminate buffer underflow messages on
older ffmpeg versions (eg, 1.0.x) and potentionally fixes freezes on some DVD players
* Minor quality optimizations to the presets
* Reworked the interlace/deinterlace code
* Use the clean_func() function when exiting upon error. That way we can remove the output directory which is no longer needed in such case

microchip8
18th May 2013, 09:57
ChangeLog for version 2.4

* Don't clean up in case dvdauthor exits with a status > 0
* Replaced some case statements by if conditionals in the aspect ratio code
* Added support for writing the ISO image to a DVD disc. This updates the config file version to 2 and adds the following variables:
DEFAULT_DVD_DEVICE, DVD_RW_FORMAT and GROWISOFS
* Renamed NICE_VALUE var in the config file to DEFAULT_NICE_VALUE
* Make file2dvd adaptable based on available programs. If a required program is missing, and that program is not critically needed, disable
the provided functionality. For example, if dvdauthor is missing, warn and disable creation of a DVD structure and subsequent ISO creation.
If mkisofs or genisoimage is missing, warn and disable creation of an ISO image and DVD burning capability
* Updated the man page

microchip8
19th May 2013, 11:48
ChangeLog for version 2.5

* Added support for MP2 audio encoding for PAL encodes
* Detect audio codec if user chooses to copy it. Based on detection, decide if we exit in case the audio codec isn't supported by the DVD standard
* Added option (nosound) to skip audio encoding
* Minor code optimizations

microchip8
20th May 2013, 09:56
ChangeLog for version 2.6

* Bugfix: in case nosound was selected as audio option, video bitrate couldn't be calculated
* Moved the audio detection code out of the audio copy option
* Detect and display audio channels
* Detect and display video aspect ratio
* Added support for encoding to LPCM audio
* Presets quality optimizations

microchip8
21st May 2013, 10:11
ChangeLog for version 2.7

* Added support for hard-telecining the encode and convert its frame rate from 23.976 to 29.970fps. Note that this requires the latest ffmpeg
from git as the telecine filter is a very recent addition
* Minor code optimizations
* Bugfix: 384 kbps option was missing for AC3 audio

microchip8
22nd May 2013, 08:08
ChangeLog for version 2.8

* Set GOP size to 15 for 23.976 fps NTSC
* Added support for the audio volume filter which can be used to increase or decrease the audio volume
* Added support for using MEncoder for encoding. This updates the config file version to 3 and adds the
following variables: DEFAULT_ENCODER and MENCODER
* Updated the man page

microchip8
23rd May 2013, 11:09
ChangeLog for version 2.9

* Minor code optimizations to the MEncoder code
* Added support for converting NTSC content to PAL and PAL to NTSC when using MEncoder as encoder
* Added support for the hqdn3d denoise filter
* Added the softskip and harddup filters for MEncoder
* Allow 50 fps and 59.940 fps as input and automatically convert it to supported FPS by DVDs

microchip8
24th May 2013, 07:50
ChangeLog for version 3.0

* Added support for the owdenoise and dctdnoiz denoise filters for ffmpeg. Requires latest ffmpeg from git
* Added support for the ow denoise filter for MEncoder
* Reduced the video filters code. Now all video filters are placed in one global variable called vidfilters
* Also accept codec names (ac3, mp2,...) in addition to the codec number
* Added support for the mcdeint deinterlacer when using MEncoder as encoder

microchip8
25th May 2013, 09:24
ChangeLog for version 3.1

* Added a custom MPEG-2 matrix, optimized for low to moderate bitrates (~2000-4000 kbps)
* Bugfix: in case video length must be manually provided when we fail to auto-detect it, video bitrate couldn't be calculated

microchip8
26th May 2013, 10:48
ChangeLog for version 3.2

* Print calculated video bitrate after user provides target size
* Minor optimizations
* Added support for hard-telecining 23.976fps to PAL when using ffmpeg as encoder
* Added support for enabling/disabling audio and video filters in the config file. This bumps up the version of the config file to 4

microchip8
27th May 2013, 08:03
ChangeLog for version 3.3

* Added -pix_fmt yuv420p to the ffmpeg options
* Added support for deblocking when using MEncoder as encoder

microchip8
30th May 2013, 16:10
ChangeLog for version 3.4

* Added three additional quant matrices (KVCD Notch, Bach1, HVS Best)
* Added support for using MPEG-style quantizers. Requires latest ffmpeg from git and mencoder from svn

microchip8
31st May 2013, 07:32
ChangeLog for version 3.5

* Fix the HVS Best matrix. There was a comma missing before the last value in both intra and inter vars

microchip8
1st June 2013, 22:09
ChangeLog for version 3.6

* Added one more custom quant matrix, QLB (Quenc Lower Bitrate)
* Added support for the mcdeint deinterlacer when using ffmpeg as encoder. Requires latest ffmpeg from git

microchip8
2nd June 2013, 12:13
ChangeLog for version 3.7

* Set field order to TFF when telecining with ffmpeg
* Added support for the kerndeint deinterlacer
* Added support for interlacing of 50/59.940 FPS content

microchip8
3rd June 2013, 11:19
ChangeLog for version 3.8

* Use tinterlace=4 when interlacing with MEncoder
* Added support for the tinterlace filter when using ffmpeg as encoder
* Added support for converting PAL content to NTSC and NTSC to PAL when using ffmpeg as encoder

microchip8
4th June 2013, 11:36
ChangeLog for version 3.9

* Don't ask for PAL -> NTSC conversion in case user has selected to Hard-Telecine to PAL
* Use the setpts filter together with the fps filter when doing NTSC <-> PAL conversions

microchip8
6th June 2013, 11:28
ChangeLog for version 4.0

* Added support for encoding to DTS audio when using ffmpeg as encoder

microchip8
6th June 2013, 11:41
I guess I was too fast to release :)

ChangeLog for version 4.1

* Fix audio codecs order

microchip8
7th June 2013, 15:18
ChangeLog for version 4.2

* Add missing and valid bitrates for DTS audio

microchip8
8th June 2013, 15:54
ChangeLog for version 4.3

* Detect and display audio sample rate

microchip8
11th June 2013, 23:36
ChangeLog for version 4.4

* Fix for when using audio copy with ffmpeg as encoder

microchip8
14th June 2013, 10:17
ChangeLog for version 4.5

* Added support for deblocking when using ffmpeg as encoder. Requires latest ffmpeg from git
* Cosmetics

microchip8
14th June 2013, 18:00
ChangeLog for version 4.6

* Added support for setting the amount of audio channels

microchip8
15th June 2013, 13:01
ChangeLog for version 4.7

* Ask for audio channels when user accepts the default audio codec

microchip8
28th July 2013, 11:49
ChangeLog for version 4.8

* Update DTS bitrates

microchip8
27th October 2013, 22:39
ChangeLog for version 4.9
* Added support for the Weston 3 Field Deinterlacing Filter for ffmpeg. Requires latest ffmpeg from git

microchip8
20th December 2013, 23:25
ChangeLog for version 5.0

* Detect Opus audio
* Set ffmpeg -threads option to 0 (auto-detect)

microchip8
10th May 2014, 11:59
ChangeLog for version 5.1

* Workaround for audio copy with MEncoder by using -mc 0 -msglevel demuxer=-1

microchip8
14th November 2014, 14:16
ChangeLog for version 5.2

* Clip the video bitrate to the auto-calculated value
* Set the buffer size to 1835k

microchip8
15th November 2014, 12:25
ChangeLog for version 5.3

* Detect TrueHD audio
* Fixed potential issue with min/maxrate
* Ask for which software scaler to use
* Tunings to the presets