Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7072

Difference behaviour between Ubuntu and Windows for popen, _popen

$
0
0

I need to open FFMPEG pipe and write frames data to that pipe. I am using this code:

#ifdef _WIN32#define POPEN _popen#define PCLOSE _pclose#else#define POPEN popen#define PCLOSE pclose#endif// FFmpeg command to receive raw BGR24 data and encode with libx264std::ostringstream oss;oss << "ffmpeg -y -f rawvideo -pixel_format bgr24 "<< "-video_size " << width << "x" << height << " "<< "-framerate " << fps << " -i - "<< "-c:v libx264 -preset ultrafast "<< "" << video_path << "";std::string cmd = oss.str();        #ifdef _WIN32auto mode = "wb";#elseauto mode = "w";#endifpipe_ = POPEN(cmd.c_str(), mode);if (!pipe_) {    throw std::runtime_error("[FFmpegWriter::FFmpegWriter] FFmpeg pipe could not be oppnened");}

The writing (in loop) looks like:

size_t written = fwrite(img.data, 1, img.total() * img.elemSize(), pipe_);

This works fine but it is much slower on Ubuntu (while writing frames) than it is on Windows.The wb option does not work on ubuntu and return empty pipe_.What exactly the problem here:

  1. Why wb does not work on Ubuntu?
  2. if w is the way to go on Ubuntu, why it is much slower than windows (2-3X)?

Viewing all articles
Browse latest Browse all 7072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>