Skip to main content

Posts

Showing posts with the label bash

How to re-encode an MP3 file for Camtasia 8.6 (or for a legacy MP3 editing tool).

Command: ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 192k -write_xing 0 -id3v2_version 0 output.mp3 Details: Camtasia 8.6 misunderstands VBR: Variable bit rate MP3 files. So Camtasia 8.6 shows the wrong MP3 audio length. To avoid this Camtasia 8.6 issue, use CBR: constant bit rate and invalidate new headers. (Or use a WAV file) Options: -b:a 192k : Constant bit rate to 192kbps -write_xing 0 : No Xing header. The Xing header records the timing information for the variable bit rate MP3 file. But when I use CBR, this is not needed. Camtasia 8.6 seems to have failed to recognize Xing VBR MP3 files. -id3v2_version 0 : Use id3v2 version 0 tag. Camtasia seems to have failed to recognize the ID3v2 header > 0 tag. This loses the metadata. To see the MP3 encoding info: ffmpeg -i input.mp3 mediainfo input.mp3 

Passing command line options that have white spaces to a bash script: $* and $@

I always try to simplify a command line parser implementation regardless any programming language: C++, bash, ... To do that, I restrict the command line option to a regular form only. All my arguments should be '-arg_key value' form. Even I want to specify a file name, my program needs an argument key, e.g., '-in_file input_filename. If you do in this way, each command line argument has the key, so I can put all the command line options to a map. This makes the command line parser simple. I usually don't need getopt library. Also I try to simplify the command line option support, means smaller number of command line options, and use a config file, which contains 'key = value' lines. This has two advantages: you can support negative values without confusing the command line option, easy to reproduce the test case. However, this method still has a problem when the command line option includes white space. If I could, I will only try to use config files,...