Swiss File Knife
a command line
free external tools,
- download the free Swiss File Knife Base from Sourceforge. - open the Windows CMD command line, Mac OS X Terminal or Linux shell. - OS X : type mv sfk-mac-i686.exe sfk and chmod +x sfk then ./sfk - Linux: type mv sfk-linux.exe sfk and chmod +x sfk then ./sfk OS X and Linux syntax may differ, check the help within the tool.
sfk media infile.mpg -keep n1-n2 -cut n3-n4 -tofile out.mpg sfk media infile.m3u -keepbook -tofile out.mpg sfk list mydir .m3u +media -keepbook -to outdir\$base.mpg cuts mpeg2 video or other binary file(s), by keeping or dropping parts given as absolute byte positions in the file. sfk media does not interpret, decode or encode any video data, and knows nothing about the file format. it simply copies blocks of bytes, which may or may not work, depending on the file format (mpeg2 is best), media player (VLC is best) and installed codecs of the operating system. This command is not suitable for mpeg4 or any format using file headers. Splitting or reducing an mpeg2 file usually keeps the result playable in media players. Joining multiple mpeg2 files into one file strictly requires post processing by ffmpeg, to recalculate PCR time stamps required for playback. parameters for cutting and post processing -keep n1-n2 keep this part of the file, from byte offset n1 until before n2 (excluding offset n2), and cut everything before and after. keep must be given before any "cut" parameters. n1 means an absolute byte position like 12345. one "keep" can be followed by multiple n-n. -cut n1-n2 cut this part. multiple cut parameters can be given, and they can refer to an area within a "keep" range. infile.m3u use a VLC player bookmark file instead of specifying file and positions manually. takes only the last entry in that file. file must contain an even number of start/end positions of sections to keep. -keepbook only with .m3u files: keep all parts marked by a bookmark at start and end of part -joinraw join all input files or parts into one output. with mpeg video, the output file will NOT work correctly in players due to wrong timestamps and therefore requires post processing like: ffmpeg -i in.mpg -target pal-dvd -c copy out.mpg (without -target, the output will have no sound) -fix parm create a temporary file (with -tmp in filename) then run ffmpeg to fix the output file by re- rendering timestamps. "parm" is passed to ffmpeg as is, except for two special values which are extended like: pal-dvd = -target pal-dvd (for pal output) ntsc-dvd = -target ntsc-dvd (for ntsc output) use -fix "" to pass no extra parameters. requires ffmpeg 1.2 in the PATH. -keeptmp keep temporary files produced by option -fix. default is to clean them up. -joinfull p run joinraw and -fix p in one go. required to produce mpeg2 video suitable for playback. -tmpdir d specify a folder to use for temporary files, and create unique filenames within. -keepall keep whole content of input file(s). used only with -joinraw. note: - all output files are overwritten without asking back, including temporary files. check the simulation output. - check free disk space by "sfk space" before processing. options -fix or -joinfull will use double disk space. general options -tofile f write output to a single file with name f -to outmask write multiple input files to output names given by a mask, like -to outdir\$file "sfk help opt" for details. -movesrcto x after processing, move every video input file to an output folder x. move is done by rename, so x must be on same file system as input. if an output file of same name exists already then add option -force to overwrite. -yes really create or overwrite output file -quiet do not print part and progress infos -verbose[=2] tell more details about what is done recommended process for video cutting 1. download the VLC media player installer, run the tool and open an mpeg2 .mpg file. 2. select Playback / Custom bookmarks / manage (CTRL+B). for every section to keep, create a bookmark at the start and end of that section. 3. make sure there is an even number of bookmarks. 4. select Media / Save Playlist (CTRL+Y), select file type M3U (not m3u8) and save, e.g., to cut01.m3u (if you used the VLC installer, it will remember M3U as the preferred export type.) 5. sfk media cut01.m3u -keepbook -tofile out.mpg with .mts files and ffmpeg in your path, try instead: sfk media cut01.m3u -keepbook -tofile out.mts -fix "" 6. if you process further files in the same VLC session, the M3U files may contain references to many files, but only the last (newest) entry is used. see also sfk partcopy - copy a single part of a file sfk space [d] - tell free disk space available in current of given directory d web reference http://stahlworks.com/sfk-media examples sfk media in.mpg -keep 100000-200000 -cut 150000-160000 -tofile out.mpg keep area from offset 100000 to 200000 (with a length of 100000 bytes) except for 10000 bytes inbetween. sfk media in.mpg -keep 120578-301436 518297-783591 -tofile out.mpg keep the two sections and drop the rest. sfk media in.m3u -keepbook -tofile out.mpg keep areas listed in the bookmark M3U file. sfk select mydir .m3u +media -keepbook -to out\$base.mpg execute all .m3u files from mydir, write output files to a folder out, with the same relative name as the input .M3U, but with an .mpg output extension. sfk select n:\dvd1\part1.vob n:\dvd1\part2.vob +media -joinraw -tofile out.mpg join two .vob files into one out.mpg without any modifications. out.mpg will need post processing before it can be used in a media player. sfk sel -sort d:\ .vob +media -joinfull pal-dvd -tofile out.mpg -tmpdir c:\tmp join all .vob files of a PAL dvd, sorted by name, into one out.mpg and call ffmpeg to fix timestamps. uses a temporary file in c:\tmp. sfk sel -sort d:\ .vob +media -joinfull "-target pal-dvd -map 0:0 -map 0:2" -tofile out.mpg -tmpdir e:\tmp -keeptmp similar to above, but explicitely passing several parameters to ffmpeg, selecting dvd output and to mix channels 0:0 (e.g. video) and 0:2 (e.g. an audio track with alternative language). temporary file is stored on another drive and kept, in case post processing fails and must be done manually.
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.