Author Archives: mafayyaz

How to avoid core dump when exiting the process in linux/unix

Sometimes in an application, we want to exit the process forcefully (no graceful termination), but do not want the core dump to be generated. One example could be a service that is being monitored by “monit” and if killed is … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , | Leave a comment

boost multithreading and shared mutex example: multiple reader, multiple writer

Here is a simple example of boost multithreading and shared mutex. Hope it helps. The code is quite simple and self explanatory: #include <iostream> #include <boost/thread.hpp> #include <boost/date_time.hpp> boost::shared_mutex g_mutex; using namespace std; void reader(string id) { cout << id … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

FFmpeg sample to decode video using libavformat API

Here is a very simple example to use libavformat and libavcodec library API to decode video: // ffmpeg_sample.c // Date: Sep 05, 2013 // Code based on a https://raw.github.com/phamquy/FFmpeg-tutorial-samples/master/tutorial01.c // Tested on CentOS 5.7, GCC 4.1.2,FFMPEG 0.10.1 // libavcodec.so.53.60.100 libavdevice.so.53.4.100 … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , | Leave a comment

View Y frames in Linux using mplayer

To view a file with only Y frames, following command can be used on Linux to view the frames: mplayer -demuxer rawvideo -rawvideo w=[LINESIZE]:h=[HEIGHT]:format=y8 in.raw -loop 0 To view all the formats available for rawvideo: mplayer -rawvideo format=help Reference: mplayer … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Writing Simple HTTP Server in Python (With REST and JSON)

There are many already existing powerful http servers that can be used in python e.g. gevent, twisted web server. However, they are a bit complex to use and you cannot start them in a thread other than the main thread. … Continue reading

Posted in Uncategorized | 11 Comments

FFMPEG stops receiving multicast stream after group membership lost

Recently I came across an issue under CENTOS 5.7 kernel 2.6.18 regarding multicast group membership. I was using ffmpeg 0.10 to receive udp stream over multicast sockets. There happened some disruption in the network and ffmpeg stopped receiving any incoming … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Checking multicast group membership

Following code can be used to check multicast group member under Linux. This code is only for ipv4, but can be extended for ipv6. Note: I have used netstat source as a reference to write this code. #define PATH_PROCNET_IGMP “/proc/net/igmp” … Continue reading

Posted in Uncategorized | Tagged , , , , | 1 Comment

How to compile VLC media player source on Ubuntu 10.10 Maverick

Recently I compiled VLC media player source in my Ubuntu 10.10 Maverick. Although there is an online documentation available at “http://wiki.videolan.org/UnixCompile&#8221;, yet I faced many dependencies problems during compilation. So, I decided to document most of those issues. The whole … Continue reading

Posted in Uncategorized | 3 Comments