Help Needed
Author Message
Posted : Sat, 10 January 2009 18:23:16
Subject : Help Needed
I just want to print a last line of output of command during its execution time. Is there a way to do this ? [b]For example[/b] $ ./tt.sh /home/JHON/Videos/Ala_sinistra.avi FFmpeg version git-5a82e37, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: libavutil 49.12. 0 / 49.12. 0 libavcodec 52. 3. 0 / 52. 3. 0 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 built on Nov 17 2008 15:13:29, gcc: 3.3.5 (Debian 1:3.3.5-13) Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1) Input #0, avi, from '/home/waqasdaar/Videos/Ala_sinistra.avi': Duration: 00:04:07.28, start: 0.000000, bitrate: 754 kb/s Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 25.00 tb(r) Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 160 kb/s File 'temp.m2v' already exists. Overwrite ? [y/N] y Output #0, mpeg2video, to 'temp.m2v': Stream #0.0: Video: mpeg2video, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 4000 kb/s, 25.00 tb(c) Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers. [i][b]frame= 625 fps=103 q=1.6 size= 12151kB time=24.96 bitrate=3988.0kbit[/i]s/s[/b] I just want to print the last line which is italic. Can any one help me? Thanks in Advanced
Mr. Shawn H. Corey
Posted : Sat, 10 January 2009 18:33:05
Subject : Help Needed
If you want only the last line, see `man tail`.
thobbs
Posted : Sat, 10 January 2009 19:05:59
Subject : Re: Help Needed
Specifically, you can pipe the other command into tail. Like such:[code=xml]$ ./tt.sh /home/JHON/Videos/Ala_sinistra.avi | tail -1[/code]The [b]tail -1[/b] indicates that you want to print the last [b]1[/b] line. You could make it any number you want.
waqasdaar
Posted : Sat, 10 January 2009 19:27:04
Subject : Help Needed
thanks for your reply but it does not work. :( I have tried.
waqasdaar
Posted : Sat, 10 January 2009 19:29:54
Subject : Help Needed
frame= 625 fps=103 q=1.6 size= 12151kB time=24.96 bitrate=3988.0kbits When I execute my script last line continusely changing its value and I just want to print that its does nor work with 'tail' command. Even I have tried with 'sed', tried to only print the line starting with 'frame=' but it also does not work. any new idea?
proopnarine
Posted : Sun, 11 January 2009 04:04:34
Subject : Help Needed
Why not just pipe the output to a file and then print, or are you running the command a lot?
thobbs
Posted : Sun, 11 January 2009 22:12:36
Subject : Re: Help Needed
I'm not sure exactly what you need, but I think proopnarine is suggesting something like this:[code=xml]./tt.sh /home/JHON/Videos/Ala_sinistra.avi > temp; tail -1 temp[/code]
waqasdaar
Posted : Mon, 12 January 2009 16:10:02
Subject : Help Needed
I am using "ffmpeg" which is a command line tool to convert multimedia files between formats. In a script (tt.sh) i am using the ffmpeg comand like this ffmpeg -i $1 -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k temp.m2v > temp; tail -1 temp After that when I run the script ./tt.sh /home/JHON/Videos/Ala_sinistra.avi It print some thing like this FFmpeg version git-5a82e37, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: libavutil 49.12. 0 / 49.12. 0 libavcodec 52. 3. 0 / 52. 3. 0 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 built on Nov 17 2008 15:13:29, gcc: 3.3.5 (Debian 1:3.3.5-13) Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1) Input #0, avi, from '/home/waqasdaar/Videos/Ala_sinistra.avi': Duration: 00:04:07.28, start: 0.000000, bitrate: 754 kb/s Stream #0.0: Video: mpeg4, yuv420p, 320x240 [PAR 1:1 DAR 4:3], 25.00 tb(r) Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 160 kb/s File 'temp.m2v' already exists. Overwrite ? [y/N] Y Output #0, mpeg2video, to 'temp.m2v': Stream #0.0: Video: mpeg2video, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 4000 kb/s, 25.00 tb(c) Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers. [B]frame= 777 fps=102 q=2.0 size= 15120kB time=31.04 bitrate=3990.4kbits/s[/B] The bold line continusely changing its value after converting the whole media file it prints at the end [I][B]video:120686kB audio:0kB global headers:0kB muxing overhead 0.000000%[/B][/I] I just trying to achieve that it only prints the Bold line. after it finish script return me the control back. Hope now you understand the problem. Sorry guys if I didnot mention the problem clearly. Thanks in Advanced.
blinky
Posted : Mon, 12 January 2009 17:12:17
Subject : Re: Help Needed
Use the -v option to control the verbosity of the output ("-v 0 " outputs just the last two lines when the command has completed. You need the redirection, I think ffmpeg uses the standard error stream for it's output eg. rc=`ffmpeg -v 0 -i test-media/Atomic_Kitten.mpg /tmp/Atomic_Kitten_1.avi 2>&1 | grep "frame="` echo $rc or ffmpeg -v 0 -i test-media/Atomic_Kitten.mpg /tmp/Atomic_Kitten_1.avi 2>&1 | grep "frame=
waqasdaar
Posted : Mon, 12 January 2009 17:44:39
Subject : Help Needed
Thanks brother I have tried your command but it also prints the whole output, which i dont want that any other idea ?
blinky
Posted : Mon, 12 January 2009 19:52:41
Subject : Re: Help Needed
Don't know what your setup is but on Fedora 8, when I run the command rc=`ffmpeg -v 0 -i test-media/Atomic_Kitten.mpg /tmp/Atomic_Kitten_5.avi 2>&1 | grep "frame="` echo $rc in an xterm I only get the frame line see screen dump [url]http://homepage.ntlworld.com/balbir.sanghera/sc.jpeg[/url]