Hack57.Probe Video Settings

Hack 57. Probe Video Settings

The tcprobe utility included with transcode provides an easy way to get specifications on a video using the command line.

As you begin to experiment with converting videos from one format to another you will find yourself searching for more detailed information about the video than simply whether it ends in .mpg or .avi. For instance, my portable media player is capable of playing a few different video formats up to a certain resolution, so before I copy videos to it, it helps to probe them beforehand to make sure they meet its specifications. Also to do video conversion you often need information such as resolution, video and audio bitrate, codec used, and so forth. There are a number of ways to retrieve this information on Linux. One way is to simply open up the video in your favorite GUI video player and check the file properties. Another is to play the video in mplayer and dig through the verbose output it creates for clues. Probably the fastest and easiest way however is to use the tcprobe utility included with the transcode suite of tools.

Information about the installation and use of transcode is covered in [Hack #63]. Once transcode is installed, it includes a number of useful tools that it uses when processing video, including tcprobe. tcprobe is pretty simple to use. The following command gives you general information about a video file named sample.mpg:

 $ tcprobe -i sample.mpg [tcprobe] MPEG program stream (PS) [tcprobe] summary for sample.mpg, (*) = not default, 0 = not detected import frame size: -g 480x576 [720x576] (*)  aspect ratio: 4:3 (*)    frame rate: -f 25.000 [25.000] frc=3           PTS=0.4494, frame_time=40 ms, bitrate=2450 kbps     audio track: -a 0 [0] -e 44100,16,2 [48000,16,2] -n 0x50 [0x2000] (*) PTS=0.4494, bitrate=224 kbps -D 0 --av_fine_ms 0 (frames & ms) [0] [0] 

The -i argument is used to specify the input file (otherwise it defaults to scanning STDIN). The input file can be an actual file, directory, device, or mount point. tcprobe provides you with a lot of information, but all of the labels make it easy to parse. To start it tells you that this is an MPEG stream. Next you see that the video itself is 480 x 576 pixels and has a 4:3 aspect ratio. Following that you get frame rate information telling you that this video is 25 frames per second and that the video has a bit rate of 2,450 kbps. tcprobe also provides you with information about the audio track such as the fact that it has a 44,100 Hz sample rate with 16 bits per sample and 2 channels (or stereo). You can also see that the video is encoded at 224 kbps.

Notice that a lot of the tcprobe output is in transcode argument form. If you look through the transcode man page, you will notice that each of the tcprobe arguments (such as -g 480x576) correspond to transcode arguments. This makes it easy to cut and paste these settings directly into a transcode command. Although for the most part this is unnecessary since transcode will probe for these settings itself, sometimes it can be handy as a basis to then override what transcode detects. These settings can also be handy when changing video formats for specific devices such as personal video players (see "Create Archos-Compatible Video" [Hack #64] for more information).

For most videos, tcprobe will work just fine with the -i argument. tcprobe provides some extra options though so you can work around problems with certain videos you might have. For instance, by default tcprobe will scan the first megabyte of video data to gather information. Certain videos, though, don't have all of the information (such as subtitle or audio tracks, for instance) in the first megabyte. For these files you can use the -H option followed by the number of megabytes to scan. So, to scan the first 10 megabytes of a VOB file, you would type:

 $ tcprobe -i /mnt/dvd/VIDEO_TS/VTS__01_1.VOB -H 10 

When you scan DVDs, you might want to scan a particular title for the DVD. tcprobe provides the -T argument, followed by the title number for this purpose. On certain files, you might need to skip ahead a certain number of bytes in the input stream before scanning (for instance to skip past file corruption). To do this, use the -s argument followed by the number of bytes.

Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net