Wednesday, August 20, 2014

Video is not streaming in Safari and Iphone

This may happen due to

RequestHeader unset Range
Header unset Accept-Ranges

>>Why do we need above configuration?
We do this to fix "Range header DoS vulnerability Apache HTTPD 1.3/2.x" issue. For details please check @

>>Does iPhone/iPad Safari require 'Accept-Ranges' header for video?
Yes. It requires these headers.Please find the apple documentation for the same.

>>Any other solution?
Actually we can use another fix as suggested @ . It is as below.

SetEnvIf Range (,.*?){5,} bad-range=1
RequestHeader unset Range env=bad-range

Here we are rejecting request when more than 5 ranges. But we can put very high value too.Please check these lines in same document.

The number 5 is arbitrary. Several 10's should not be an issue and may be
required for sites which for example serve PDFs to very high end eReaders
or use things such complex http based video streaming.

We will enable "Accept-Ranges" at .htaccess file for .mp4 videos only as below.


Header set Accept-Ranges bytes


other ffmpeg help link-

Issue 1: Audio was not playing
Cause: Sample rate of the audio file did not match with the sample rate of the video.
Check videos sample rate-- ffmpeg -i video.mp4
Use the flag -ar to specify Sample rate of audio.

Issue 2: Video was not streaming.
~~~~~: Video should be "Progressive" in nature. Video should provides its meta info at the beginning so that it playback as soon as possible.
Use the following command:

qt-faststart output.mp4 output1.mp4


Final commands:
1) ffmpeg -i video.mp4 -i test.mp3 -vcodec copy -acodec aac -strict experimental -shortest output.mp4
2) qt-faststart output.mp4 output1.mp4

Wednesday, May 14, 2014

How to enable old closing position in Vim

Please add below lines in Vimrc

if has("autocmd")
   au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
         \| exe "normal! g'\"" | endif

Saturday, March 29, 2014

virtualBox ERROR - Kernel driver not installed (rc = -1908)

1.This command will display modules of virtualbox
#cat /etc/sysconfig/modules/VirtualBox.modules
2.Now  i want fix this problem using ‘systemd-modules-load.service’.insert this in “virtualbox.conf”
## vi /usr/lib/modules-load.d/virtualbox.conf
#Loading VirtualBox modules
and restart service
# systemctl restart systemd-modules-load.service # systemctl status systemd-modules-load.service
finally reboot and it will work fine. without any error!!!

Saturday, February 15, 2014

Stack Implementation using Linked List

using namespace std;

//class for each node of stack
class Node{
        Node* nextNode;
        string data;
        friend class Stack;

//Stack Class
class Stack {
        Node* top;

        Stack() {
            top = NULL;
        int push(string data);
        string pop();
        int traverse();

//push operation - insertion at top
int Stack::push(string data) {
    Node* temptr = new Node();
    temptr->data = data;
    //if not adding first node
    if(top != NULL) {
        temptr->nextNode = top;
    } else {
        temptr->nextNode = NULL;
    top = temptr;
    return 0;

//pop operation -- deletion from top
string Stack::pop() {
    string data = top->data;
    Node* temptr = top;
    top = top->nextNode;
    return data;

//traverse the stack elements
int Stack::traverse() {
    Node* temptr = top;
    while(temptr != NULL){
        cout<< temptr->data <<endl;
        temptr = temptr->nextNode;
    return 0;

int main() {
    Stack* so = new Stack();
    cout<<"Display Stack::\t"<<endl;
    cout<<"Popped Item::\t"<<so->pop()<<endl;
    cout<<"Display Stack::\t"<<endl;

Monday, January 13, 2014

Send HTML mail with embedded Image using Javamail API

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class Testmail
   public static void main(String [] args)
      // Recipient's email ID needs to be mentioned.
      String to = "";
      //String to = "";
      //String to = "";

      // Sender's email ID
      String from = "";

      // sending email from localhost
      String host = "localhost";

      // Get system properties
      Properties properties = System.getProperties();

      // Setup mail server   ""
      properties.setProperty("", host);

      // Get the default Session object.
      Session session = Session.getDefaultInstance(properties);

         // Create a default MimeMessage object.
         MimeMessage message = new MimeMessage(session);

//Create multipart message
MimeMultipart multipart = new MimeMultipart("related");

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
                                  new InternetAddress(to));

         // Set Subject: header field
         message.setSubject("This is my Subject");

         //add text part
BodyPart bodyPart = new MimeBodyPart();
         String htmlText = "<html><body><img src='cid:myimageid' /><p>this is my html body</p></body></html>";
bodyPart.setContent(htmlText, "text/html");

//add image part
MimeBodyPart imagePart = new MimeBodyPart();
imagePart.setDataHandler(new DataHandler(new FileDataSource("/home/gauravp/mail/NSAwarnsofpowergridshutdown.jpg")));

         // Send message

         System.out.println("Sent message successfully....");
      }catch (Exception e) {