Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout slow when piped #112

Closed
skiqh opened this issue Dec 13, 2013 · 5 comments
Closed

stdout slow when piped #112

skiqh opened this issue Dec 13, 2013 · 5 comments

Comments

@skiqh
Copy link

skiqh commented Dec 13, 2013

When playing a video from the console with the --stats parameter, omxplayer sends its status information quite frequently (around 4 to 5 times a second). However, when issueing the same command but to be piped (to a file or named pipe), the intervals between status outputs become rather large (about 6 seconds).
Also, time to first output (except for the clear-screen) increases significantly (from around 2 to 8 seconds).

Testcase:

# unpiped start
omxplayer --stats videofile

# takes ca. 2 seconds
> Video codec omx-h264 width 1280 height 720 profile 100 fps 23.976025
> Audio codec aac channels 2 samplerate 44100 bitspersample 16
> Subtitle count: 0, state: off, index: 1, delay: 0
> V:PortSettingsChanged: 1280x720@23.98 interlace:0 deinterlace:0v:     0k Ca:     0k
# this line refreshes quite frequently
> M: 4045785 V:  6.38s   4720k/  4800k A:  0.95   4.46s/  2.00s Cv: 10222k Ca:   851k



# piped start
omxplayer --stats videofile | cat

# takes ca. 8 seconds
> Video codec omx-h264 width 1280 height 720 profile 100 fps 23.976025
> Audio codec aac channels 2 samplerate 44100 bitspersample 16
> Subtitle count: 0, state: off, index: 1, delay: 0
> V:PortSettingsChanged: 1280x720@23.98 interlace:0 deinterlace:0v:     0k Ca:     0k
# this line refreshes merely every 6 seconds
> M: 5551415 V:  5.42s   4800k/  4800k A:  0.93   4.18s/  2.00s Cv: 10234k Ca:   821k
@popcornmix
Copy link
Owner

stdout is line buffered.
Piping will use larger (e.g. 4K) buffers. This is standard linux stuff and not really to do with omxplayer.

@skgsergio
Copy link

Dont know what do you want to do but maybe this works for you:

script -qc "omxplayer --stats videofile" /dev/null | cat

@skiqh
Copy link
Author

skiqh commented Dec 14, 2013

Thank you both for your fast response!

My intention was to spawn omxplayer from nodejs, channel commands to its stdin and read from its output to fetch the current status*. (Maybe a duplicate of #10 ?)

@popcornmix 4K seems quite right; cat's output (using -v) is 4049 bytes for each of the 6-second-bursts.
@skgsergio It does. The ouput's speed is quite the same as without piping. However, I cannot use this from node, as the script process terminates immediately after launch.

Any idea how to go about this, as the 4K-buffer flushes come to infrequent?

Thanks again for your time, I am very grateful for the effort you put into omxplayer!

*) I looked into following the logfile, but I cannot use that in its current state, as the logfile grows quite fast, and it is hardcoded to go into a newly created ./omxplayer.log file. Maybe I should file an issue for this?

@popcornmix
Copy link
Owner

I think this is another instance where connecting to omxplayer through dbus is the best solution.
Look at what this code does:
https://github.com/popcornmix/omxplayer/blob/master/Keyboard.cpp

You should be able to control omxplayer and read back status using that interface.
If there is information missing, it should be possible to add.

@skiqh
Copy link
Author

skiqh commented Dec 19, 2013

Okay, I'll look into that. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants