TS convert using ffmpeg

From QuartzWiki

Jump to: navigation, search

Contents

Getting FFMPEG

Linux

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Windows version

Download from http://arrozcru.no-ip.org/ffmpeg_builds/ or http://www.videohelp.com/tools?tool=ffmpeg

Converting HUMAX file to MPEG-1

To convert the TS file in to MPEG-1 8Mbit/s and using stereo audio, leave most settings at default and use:

ffmpeg -y -i <input file>.ts -b 8000000 -bt 2000000 -ac 2 <output file>.mpg

Where:

  • -y = overwrite output files
  • -b = <int> E.VA. set video bitrate (in bits/s)
  • -bt = <int> E.V.. set video bitrate tolerance (in bits/s)
  • -i filename = input file name
  • -ac channels = set number of audio channels

NOTE:

It's important to use -ac 2 because, without it, ffmpeg insists on creating mono audio (or 0 channels and aborting in some cases!)

For example:

ffmpeg -y -i test_file.ts -b 8000000 -bt 2000000 -ac 2 test_6M.mpg

FFmpeg version SVN-r7215, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration:  --extra-cflags=-I/shared/include --extra-ldflags=-L/shared/lib --enable-memalign-hack --enable-shared
--disable-static --enable-mp3lame --enable-xvid --enable-a52 --enable-libogg --enable-vorbis --enable-faac --enable-faad
--enable-x264 --enable-pp --enable-amr_wb --enable-amr_nb --enable-avisynth --enable-dts --enable-libgsm --enable-gpl
 libavutil version: 49.1.0
 libavcodec version: 51.25.0
 libavformat version: 51.6.0
 built on Dec  3 2006 00:47:05, gcc: 3.4.6
Input #0, mpegts, from 'test_file.ts':
 Duration: 00:01:47.7, start: 90496.539144, bitrate: 3180 kb/s
 Stream #0.0[0x230]: Video: mpeg2video, yuv420p, 704x576, 10000 kb/s, 25.00 fps(r)
 Stream #0.1[0x231](eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
 Stream #0.2[0x232](eng): Audio: mp2, 48000 Hz, mono, 64 kb/s
 Stream #0.3[0x233](eng): Subtitle: dvbsub
Output #0, mpeg, to 'test_6M.mpg':
 Stream #0.0: Video: mpeg1video, yuv420p, 704x576, q=2-31, 8000 kb/s, 25.00 fps(c)
 Stream #0.1: Audio: mp2, 48000 Hz, stereo, 64 kb/s
Stream mapping:
 Stream #0.0 -> #0.0
 Stream #0.1 -> #0.1
Press [q] to stop encoding


Smaller, but still acceptable quality, is to encode to 1Mbit/s:

ffmpeg -y -i <input file>.ts -b 2000000 -ac 2 <output file>.mpg


Converting HUMAX file to DVD

Simplest method is to use -target dvd option and leave the other settings as defaults:

ffmpeg -y -target dvd -i <input file>.ts -ac 2 <output file>.mpg

Where:

  • -target type = specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd", "ntsc-svcd", ...)


FFmpeg version SVN-r7215, Copyright (c) 2000-2006 Fabrice Bellard, et al.
 configuration:  --extra-cflags=-I/shared/include --extra-ldflags=-L/shared/lib --enable-memalign-hack --enable-shared
--disable-static --enable-mp3lame --enable-xvid --enable-a52 --enable-libogg --enable-vorbis --enable-faac --enable-faad
--enable-x264 --enable-pp --enable-amr_wb --enable-amr_nb --enable-avisynth --enable-dts --enable-libgsm --enable-gpl
 libavutil version: 49.1.0
 libavcodec version: 51.25.0
 libavformat version: 51.6.0
 built on Dec  3 2006 00:47:05, gcc: 3.4.6
Input #0, mpegts, from 'test_file.ts':
 Duration: 00:01:47.7, start: 90496.539144, bitrate: 3180 kb/s
 Stream #0.0[0x230]: Video: mpeg2video, yuv420p, 704x576, 10000 kb/s, 25.00 fps(r)
 Stream #0.1[0x231](eng): Audio: mp2, 48000 Hz, stereo, 192 kb/s
 Stream #0.2[0x232](eng): Audio: mp2, 48000 Hz, mono, 64 kb/s
 Stream #0.3[0x233](eng): Subtitle: dvbsub
Assuming PAL for target.
Output #0, dvd, to 'test_dvd.mpg':
 Stream #0.0: Video: mpeg2video, yuv420p, 720x576, q=2-31, 6000 kb/s, 25.00 fps(c)
 Stream #0.1: Audio: ac3, 48000 Hz, stereo, 448 kb/s
Stream mapping:
 Stream #0.0 -> #0.0
 Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=  255 q=2.0 Lsize=    5826kB time=9.5 bitrate=5004.9kbits/s
video:5066kB audio:522kB global headers:0kB muxing overhead 4.264575%

Notes:

  1. The video is now MPEG-2 (which some software players have trouble showing), rather than MPEG-1
  2. The audio is now AC3 rather than MP2

The above generates the mpeg at 6Mbit/s, which is perfectly watchable, but for better quality set the bit rate:

ffmpeg -y -target dvd  -b 8000000 -bt 2000000 -i <input file>.ts -ac 2 <output file>.mpg


Converting HUMAX file to NTSC

 C:\gui4ffmpeg\ffmpeg.exe" -i %1 -hq -target ntsc-dvd -b 6000 -aspect 4:3 -s 640x352 
   -padbottom 64 -padtop 64 -padleft 32 -padright 32 
   -acodec ac3 -ab 448 -ac 6 -mbd 2 -qmin 2 -async 1 -y %2

(See: http://www.tivocommunity.com/tivo-vb/archive/index.php/t-283650.html)


Audio conversion

To extract audio from a file and generate an MP3:

 ffmpeg -i inputfile -f mp3 -acodec mp3 -ab 128 -ar 44100 -vn outputfile.mp3

Where:

  • -f fmt = force format
  • -vn = disable video
  • -ab bitrate = set audio bitrate (in kbit/s)
  • -ar rate = set audio sampling rate (in Hz)

Converting DVD file to PSP

ffmpeg -y -i <input file>.VOB -title "VTS_01_1" -timestamp "2007-01-04 06:00:34" -bitexact -vcodec xvid -s 368x208 -r 14.985 -qscale 4 -acodec aac -ac 2 -ar 24000 -ab 32 -f psp -muxvb 512 <output file>.MP4


Linux Journal Article

http://www.linuxjournal.com/article/8517


Personal tools