Giter Club home page Giter Club logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
Do NOT use AV_PIX_FMT_YUV422P9LE. Instead please try to use AV_PIX_FMT_YUV420P.

And please post your questions on the mailing list next time if possible, thank 
you.

Original comment by [email protected] on 23 Nov 2014 at 1:28

  • Changed state: Done
  • Added labels: Type-Other
  • Removed labels: Type-Defect

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
Hi Samual

Alright,I will make sure I use mailing list from now onwards . 
AV_PIX_FMT_YUV420P did the trick . Looks like I need to go back to basics . BTW 
recording worked but no sound was there. Any Ideas ?

Thanks
Arvind

Original comment by [email protected] on 23 Nov 2014 at 7:47

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
To get sound, we have to record audio from somewhere. There's a sample for 
Android here for that:
https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java
But nothing for Java SE yet. If you'd like to provide a sample that works with 
Java Sound:
https://docs.oracle.com/javase/tutorial/sound/capturing.html
It would be very welcome. Let me know! Thanks

Original comment by [email protected] on 23 Nov 2014 at 12:47

from javacv.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
There are wonderful people on the internet, I found this recording code . Will 
work more on this, 

package com.volcare.audiosys;

import javax.sound.sampled.*;
import java.io.*;

/**
 * A sample program is to demonstrate how to record sound in Java
 * author: www.codejava.net
 */
public class JavaSoundRecorder {
    // record duration, in milliseconds
    static final long RECORD_TIME = 10000;  // 1 minute

    // path of the wav file
    File wavFile = new File("/home/arvind/RecordAudio.wav");

    // format of audio file
    AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;

    // the line from which audio data is captured
    TargetDataLine line;

    /**
     * Defines an audio format
     */
    AudioFormat getAudioFormat() {
        float sampleRate = 16000;
        int sampleSizeInBits = 8;
        int channels = 2;
        boolean signed = true;
        boolean bigEndian = true;
        AudioFormat format = new AudioFormat(sampleRate, sampleSizeInBits,
                                             channels, signed, bigEndian);
        return format;
    }

    /**
     * Captures the sound and record into a WAV file
     */
    void start() {
        try {
            AudioFormat format = getAudioFormat();
            DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);

            // checks if system supports the data line
            if (!AudioSystem.isLineSupported(info)) {
                System.out.println("Line not supported");
                System.exit(0);
            }
            line = (TargetDataLine) AudioSystem.getLine(info);
            line.open(format);
            line.start();   // start capturing

            System.out.println("Start capturing...");

            AudioInputStream ais = new AudioInputStream(line);

            System.out.println("Start recording...");

            // start recording
            AudioSystem.write(ais, fileType, wavFile);

        } catch (LineUnavailableException ex) {
            ex.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    /**
     * Closes the target data line to finish capturing and recording
     */
    void finish() {
        line.stop();
        line.close();
        System.out.println("Finished");
    }

    /**
     * Entry to run the program
     */
    public static void main(String[] args) {
        final JavaSoundRecorder recorder = new JavaSoundRecorder();

        // creates a new thread that waits for a specified
        // of time before stopping
        Thread stopper = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(RECORD_TIME);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
                recorder.finish();
            }
        });

        stopper.start();

        // start recording
        recorder.start();
    }
}

Original comment by [email protected] on 24 Nov 2014 at 12:48

from javacv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.