0

I am writing a program to get the output of the video length played (time in seconds) in mplayer. Usually the output of mplayer is

Playing video.mp4.
Detected file format: QuickTime / MOV (libavformat)
[lavf] stream 0: video (h264), -vid 0
Clip info:
 major_brand: dash
 minor_version: 0
 compatible_brands: iso6avc1mp41
 creation_time: 2017-11-03 00:36:26
Load subtitles in .
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 [libavcodec]
Starting playback...
VIDEO:  1920x1080  23.976 fps  1343.8 kbps (168.0 kB/s)
VO: [x11] 1920x1080 => 1920x1080 Planar YV12
[swscaler @ 0xb5cea980]No accelerated colorspace conversion found from yuv420p to bgra.
[swscaler @ 0xb5cea980]using unscaled yuv420p -> bgra special converter
Colorspace details not fully supported by selected vo.
V:  78.0   0/  0  8% 117%  0.0% 0 0

I want the time output of the last line. i.e.78.0

I am saving the logs in a file using this command:

mplayer video.mp4 2>timing.log | grep V:

Which will be read by the python function running in parallel to the Thread function playing the same video.

Is there any way where I can store only the timings.

As I am unable to get the timings from the log file, as it returns me null.

1 Answer 1

0

You are redirecting the stderr Output (2> timing.log) of mplayer only. The 'V:' Values you are initerested in are in the stdout (1> timing.log).

Anyway I would use a cup of tee IMHO:

mplayer video.mp4 | tee -a timing.log; grep 'V:' timing.log

2
  • It prints all the data other than the last line.
    – ron123456
    Jan 16, 2019 at 5:30
  • Although using 'strace' I was able to do so. But it slowed my raspberry pi. strace mplayer video.mp4 2>&1 | grep V: | awk 'FNR=1 {print $3}' > timing.log
    – ron123456
    Jan 16, 2019 at 5:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .