mplayer doesn't like popen suddenly? - c++

Been stumped over a problem with popen for a few days.
The code:
int main(){
FILE *fp = popen("mplayer /home/linaro/Music/cp.mp3", "r");
char buffer[1028];
while (fgets(buffer, 1028, fp) != NULL)
{
std::cerr<<buffer;
}
pclose(fp);
fp = 0;
return 0;
}
was run at the shop on a linaro embedded controller. Ran fine, no errors. Even though the code is simple (Just plays a coldplay song on execution and then quits) it seems to be causing me more grief than one would think.
If I copy and paste the command itself into a normal bash shell, it runs fine. And what's worse, is it ran fine up until it got plugged in somewhere else. I'm not sure if it is now being connected to via a headphone jack versus before it was in a line out jack.
Regardless, the error I get when I run it is (summarized down to the relevant part)
MPlayer svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlaye4
Team mplayer: could not connect to socket mplayer: No such file or
directory Failed to open LIRC support. You will not be able to use
your remote control.
Playing /home/linaro/Music/cp.mp3 libavformat version 53.21.1
(external) Mismatching header version 53.19.0 Audio only file format
detected. Clip info: Title: The Scientist Artist: Coldplay Album: A
Rush Of Blood To The Head Year: 2002 Comment: Genre: Unknown Load
subtitles in /home/linaro/Music/ Requested audio codec family [mpg123]
(afm=mpg123) not available. Enable it at compilation. Opening audio
decoder: [ffmpeg] FFmpeg/libavcodec audio decoders libavcodec version
53.35.0 (external) Mismatching header version 53.32.2 AUDIO: 44100 Hz, 2
ch, floatle, 256.0 kbit/9.07% (ratio: 32002->352800) Selected audio
codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio) Home
directory not accessible: Permission denied AO: [pulse] Init failed:
Connection refused Failed to initialize audio driver 'pulse' Home
directory not accessible: Permission denied [AO_ALSA] alsa-lib:
pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC1D0p' failed (-22):
Invalid argument [AO_ALSA] Playback open error: Invalid argument
Failed to initialize audio driver 'alsa' [AO SDL] Samplerate: 44100Hz
Channels: Stereo Format floatle [AO SDL] using aalib audio driver. [AO
SDL] Unsupported audio format: 0x1d. [AO SDL] Unable to open audio: No
available audio device Failed to initialize audio driver 'sdl:aalib'
Could not open/initialize audio device -> no sound. Audio: no sound
Video: no video
Again, if I copy and paste the exact command it executes via popen into the console, it begins playing. It fails if pass -ao alsa, -ao pulse, -ao oss as well, which has me completely stumped. Any help would be appreciated!
Edit:
Linux is linaro, based on Ubuntu 12.04 using arm CPU

Issue wound up being as Jonas and alk suggested -- permissions. Something along the way changed how it ran, but at the end of the day the dirty fix was to just include
su - user -c ' mplayer ... '
To the line being called.

Related

PlatformIO cannot open ftdi device (Arduino with esp32)

I am new to Arduino and using the esp32 and I am using PlatformIO to command my project in C++ through VSCode. I just downloaded my project folder and opened it in PlatformIO and attempted to run the existing code (over 1000 lines) which is meant to command an exoskeleton. When I run the program, however, I get error messages, as follows:
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '', serial '' at bus location ''
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '', serial '' at bus location ''
I feel like I am missing something very basic, but everything I search for gives me very advanced problems, and I am hoping someone could dumb this down for me.
Any help is appreciated, thank you.
By the way, I am actually using Mac, and the output when I enter the ls -ls /dev/tty.usbserial-1410 is:
0 crw-rw-rw- 1 root wheel 18, 2 7 Dec 14:13 /dev/tty.usbserial-1410
You may used a different type of esp32 module (there're lots of variants in the market) from the original design. You have 2 options,
If the software works and you don't want to modify it, then try to find the same type of esp32 module specified by design.
Find out vid/pid from your current esp32 module and update software to connect. Refer to below procedure.
The procedures to update usb serial binding,
Run lsusb to find out vid/pid
lsusb commands
update the existing rule specified with vid 0403 and pid 6010 to your current vid/pid, usually the rule file is under /etc/udev/rules.d/.
Run sudo udevadm control --reload-rules to activate.

VLCJ Output audio/video modules

Is there any abillity to change "Audio output module" and "Video output" in my java program?
My linux doesn't play video files when these options are set to "automatic". So in VLC Player I have chosen "ALSA" and "OpenGL GLX (XCB)", now my files are playing.
But when I use EmbeddedMediaPlayerComponent in my program, I think it chooses "automatic" mode for a/v threads. Then I'm getting a green screen (instead of my video) and an error in terminal:
[00007f691c112ac8] pulse audio output error: stream connection failure: Timeout
[00007f691c112ac8] core audio output error: module not functional
[00007f69081b6168] core decoder error: failed to create audio output
Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
Strange, but audio is playing...
Please, help! ;)
Change the MediaPlayerFactory initialisation arguments to specify the name of the audio/video output module that you want to use.
Something like:
String[] args = {"--vout=xcb", "--aout=alsa"});
From a command-line, vlc --list will give you the available module names.

MP3s playing at wrong bitrate on Debian VirtualBox Guest in OS X Host

Collection of mp3 files imported to VirtualBox (via binary ftp) from host sound very slow, so assume are playing at wrong bitrate.
Checksums match as per /usr/bin/openssl md5 *.mp3 (on OS X) and md5sum *.mp3 on debian.
Even tried moving a file back to OS X host and it plays at the correct rate, so I think the guest (debian) isn't recognizing the bitrate's correctly.
Tried playing the files with three different players: VCL, Movie PLayer and Rhythm Box. Same slow result.
Any recommendations for a next step?
Hmm. It's working now. I had changed the audio settings of the guest (debian) VM from
Host Audio Driver: CoreAudio
Audio Controller: ICH AC97
to
Host Audio Driver: Null Audio
Audio Controller: SoundBlaster16
At which point there was no audio output.
Went back to CoreAudio / ICH AC97 and sound is fine now.

Reading video files with OpenCV VideoCapture

I am having trouble being able top open any video files in OpenCV besides those encoded in MJPEG.
I have installed OpenCV using this script (which should compile OpenCV with support for ffmpeg) and an testing using the sample provided here.
When running with a h264 encoded video I get:
[mov,mp4,m4a,3gp,3g2,mj2 # 0x123ed80] multiple edit list entries, a/v desync might occur, patch welcome
[h264 # 0x12465e0] A non-intra slice in an IDR NAL unit.
[h264 # 0x12465e0] decode_slice_header error
Could not open the output video for write: test.mp4
When running with an MPEG-2 encoded video I get:
[mpegts # 0x1e92d80] PES packet size mismatch
[mpegts # 0x1e92d80] PES packet size mismatch
[mpegts # 0x1e92d80] max_analyze_duration reached
[mpegts # 0x1e92d80] PES packet size mismatch
Could not open the output video for write: test.mpeg
I am running x64 Ubuntu 12.04.
EDIT: I tried OpenCV 2.4.8 on a Ubuntu 13.10 x86 VM, ffmpeg works fine, however the sample code still fails, this time with the following error:
[h264 # 0x849ff40] A non-intra slice in an IDR NAL unit.
[h264 # 0x849ff40] decode_slice_header error
Could not find encoder for codec id 28: Encoder not foundOpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, file /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp, line 505
terminate called after throwing an instance of 'cv::Exception'
what(): /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp:505: error: (-210) Gstreamer Opencv backend doesn't support this codec acutally. in function CvVideoWriter_GStreamer::open
I am not sure about the main reason for this. But I guess this problem is relate to the decoder installed on your system. According to the install script from github, it removes your ffmpg and x264 then rebuilds them from source code. Before testing your OpenCV code, try simple "ffmpeg" command on your test video.
Such as: ffmpeg -i inputfile.avi -f image2 image-%3d.jpeg
The script you have used is quite old and installs old version of OpenCV (2.4.2, while the latest stable is 2.4.8), try to use this script - https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_8.sh or install OpenCV and ffmpeg on you own.
As rookiepig mentioned - check whether ffmpeg is working.
Try to use different codec - here http://www.fourcc.org/ is full list of options, of course testing all of them is useless - jsut try the most popular codecs.
I know that it's stupid, but on Windows some codecs works only in release mode(okay, probably they are working in both modes, but on my machine they used to work only in release mode). Try to compile you program in both modes and check whether there is some difference.
And show us you code, maybe there is something wrong in it.

mplayer mingw 64bit signal 11

with difficulty that I generated the executable. I get this error running
MPlayer interrupted by signal 11 in module: demux_open
MPlayer crashed by bad usage of CPU/FPU/RAM. Recompile MPlayer with --enable-debug and make a 'gdb' backtrace and disassembly.
Details in DOCS/HTML/en/bugreports_what.html#bugreports_crash.
MPlayer crashed. This shouldn't happen. It can be a bug in the MPlayer code or in your drivers or in your gcc version. If you
think it's MPlayer's fault, please read DOCS/HTML/en/bugreports.html
and follow the instructions there. We can't and won't help unless
you provide this information when reporting a possible bug.
with gdb
I do not understand why that path, it's not my mingw.
Program received signal SIGSEGV, Segmentation fault.
0x0000000001060853 in __gdtoa (fpi=, be=, bits=0x0, kindp=0x800, mode=0, ndigits=0, decpt=0x0, rve=0x0) at
c:/crossdev/src/mingw-w64-svn/mingw-w64-crt/gdtoa/gdtoa.c:630
630 c:/crossdev/src/mingw-w64-svn/mingw-w64-crt/gdtoa/gdtoa.c:
No such file or directory.
with new snapshot
libavformat version 54.35.100 (internal)
MPEG-PS file format detected. VIDEO: MPEG2 720x576 (aspect 3)
25.000 fps 9800.0 kbps (1225.0 kbyte/s) Load subtitles in ../ [VO_SDL] Using driver: windib.
========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 54.71.100 (internal) [mpeg2video #
00000000016D96C0]Warning: not compiled with thread support, using thread emulation
Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders [ac3
# 00000000016D96C0]Warning: not compiled with thread support, using
thread emulation
Program received signal SIGSEGV, Segmentation fault.
0x00000000009d4fee in decode_frame ()