Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • Audio is not playing properly in ffmpeg player

    23 septembre 2013, par user1241903

    I need to create a player which will decrypt the input on-fly and play the content. I have choosen ffmpeg libs (libav*) to create player and to start I have followed this link

    but audio is not playing properly,video is playing fine. I am using ubuntu 12.04LTS 64bit OS with the following ffmpeg version,

    admin@vz-X401A1:~$ ffmpeg 
    ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
      built on Sep 11 2013 13:46:26 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
      configuration: --prefix=/home/admin/ffmpeg_build --extra-cflags=-I/home/admin/ffmpeg_build/include --extra-ldflags=-L/home/admin/ffmpeg_build/lib --bindir=/home/admin/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
      libavutil      52. 43.100 / 52. 43.100
      libavcodec     55. 31.101 / 55. 31.101
      libavformat    55. 16.102 / 55. 16.102
      libavdevice    55.  3.100 / 55.  3.100
      libavfilter     3. 84.100 /  3. 84.100
      libswscale      2.  5.100 /  2.  5.100
      libswresample   0. 17.103 /  0. 17.103
      libpostproc    52.  3.100 / 52.  3.100
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
    
    Use -h to get full help or, even better, run 'man ffmpeg'
    admin@vz-X401A1:~$
    

    and downloaded tutorial07.c from this link

    still, with this also, sound is not playing properly.

    I need help to solve the following issues,

    1. How can I fix this audio issue(I have gone through similar question in StackOverflow and installed old ver. of ffmpeg, but issue still remains).

    2. And also suggest some steps or tutorial, how to implement on-fly decryption process (in C) and integrate this with the player.

  • Displaying an AVFrame on the screen with SDL 2.0

    22 septembre 2013, par jsp99

    I am working on some code with the help of this tutorial and using the latest development libraries of ffmpeg and SDL. I am stuck at the point where I have to display the decoded frame (AVFrame) on the screen. I am inclined to do the above task i.e, Displaying the AVFrame on screen using the latest API of SDL 2.0 (Using Renderers and Textures alongside the usage of SDL_Window). Frankly speaking, I am not an expert in SDL_Renderer, SDL_Texture and the functions associated with them. But I am reading the documentation in the official site of SDL 2.0 and working my way through them.

    Is there a way to do the following using SDL 2.0 API :

    • Convert the native frame format to a flavour of YUV and display it.

      (OR)

    • If it is possible, display the frame without having to convert it from native format.

    I want to do the above using Renderers and Textures. There doesn't seem to be an easy way to work with them.

    Can anyone guide me through the steps to do the above tasks?

    PS : Though I have not explicitly tried it, I came across some ways to display AVFrame on the screen by converting the AVFrame format(native) to RGB. But I do not want the native frame format (which is mostly YUV) to RGB conversion, as it is computationally expensive.

    Converting between formats is done by sws_scale()

  • cPanel - does installing modules via easyapache overwrite php.ini ?

    22 septembre 2013, par i.h4d35

    I have a little script in bash which automates the installation of ffmpeg and ffmpeg's php module on a server. At the end of this, it appends extension=ffmpeg.so to the end of php.ini and restarts the httpd service.

    My question is, in cPanel servers, say the user installs some other module using easy apache, would that overwrite the php.ini file. In which case, how do I make sure that the extension=ffmpeg.so is always added at the end?

    One possible solution I thought of was to have a cron set which periodically checks the php.ini file but that doesn't look like the right solution.

  • ffmpeg - rendering images and sound into video with transparent background

    22 septembre 2013, par Adam

    I got lots of images and a sound file.

    I want to convert all these images into a video (with the wav file as the sound of the movie). The images have a transparent background and I want the movie's background to be transparent too.

    How do I tell ffmpeg to render with a transparent background?

    P.S - I keep getting the following error:

    Error while opening encoder for output stream #255:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    

    Sincerely,

    Adam.

  • I wonder why logcat says "NO SUCH A FILE OR DIRECTORY(2)"

    22 septembre 2013, par autoexebat

    I wanna play audio on Android with ffmpeg. But when I run this project, error has occurred

    what should I do?

    java SIDE

    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import android.app.Activity;
    import android.media.AudioFormat;
    import android.media.AudioManager;
    import android.media.AudioTrack;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.os.SystemClock;
    
    public class FFmpegBasic extends Activity
    {
        private AudioTrack track;
        private FileOutputStream os;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            createEngine();
    
            int bufSize = AudioTrack.getMinBufferSize(44100,
                                                      AudioFormat.CHANNEL_CONFIGURATION_STEREO, 
                                                      AudioFormat.ENCODING_PCM_16BIT);
    
    
            track = new AudioTrack(AudioManager.STREAM_MUSIC, 
                                   44100, 
                                   AudioFormat.CHANNEL_CONFIGURATION_STEREO, 
                                   AudioFormat.ENCODING_PCM_16BIT, 
                                   bufSize,
                                   AudioTrack.MODE_STREAM);
    
            byte[] bytes = new byte[bufSize];
    
            try {
                os = new FileOutputStream("/sdcard/a.out",false);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
            String result = "/mnt/sdcard/Wildlife.mp3";
            loadFile(result,bytes);
    
            try {
                os.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    
        void playSound(byte[] buf, int size) {  
            if(track.getPlayState()!=AudioTrack.PLAYSTATE_PLAYING)
                track.play();
            track.write(buf, 0, size);
    
            try {
                os.write(buf,0,size);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    
    
        private native void createEngine();
        private native void loadFile(String file, byte[] array);
    
        /** Load jni .so on initialization*/ 
        static {
             System.loadLibrary("avutil"); 
             System.loadLibrary("avcore"); 
             System.loadLibrary("avcodec");
             System.loadLibrary("avformat");
             System.loadLibrary("avdevice");
             System.loadLibrary("swscale");
             System.loadLibrary("avfilter");
             System.loadLibrary("ffmpeg");
             System.loadLibrary("basicplayer");
        }
    }
    

    c SIDE


    #include 
    #include 
    #include 
    #include log.h>
    
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "avcodec.h"
    #include "avformat.h"
    
    
    
    
    void Java_net_jbong_FFmpegBasic_FFmpegBasic_createEngine(JNIEnv* env, jclass clazz)
        {
            //avcodec_init();
    
            av_register_all();
    
    
        }
    
    void Java_net_jbong_FFmpegBasic_FFmpegBasic_loadFile(JNIEnv* env, jobject obj, jstring file, jbyteArray array)
    {
    
        AVFormatContext *gFormatCtx = NULL;
        AVCodecContext *gAudioCodecCtx = NULL;
        AVCodec *gAudioCodec = NULL;
        int gAudioStreamIdx = -1;
        char *gAudioBuffer = NULL;
        int i, outsize = 0;
        AVPacket packet;
        const char *str; 
        str = (*env)->GetStringUTFChars(env, file, NULL); 
        jclass cls = (*env)->GetObjectClass(env, obj); 
        jmethodID play = (*env)->GetMethodID(env, cls, "playSound", "([BI)V"); 
    
        if (gFormatCtx != NULL)
            return -1;
        if (av_open_input_file(&gFormatCtx,str,NULL,0,NULL)!=0)
            return -2;
        if (av_find_stream_info(gFormatCtx) < 0)
            return -3;
    
        for(i=0; inb_streams; i++)
        {
            if(gFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
            {
                gAudioStreamIdx = i;
                break;
            }
        }
    
        if (gAudioStreamIdx == -1)
            return -4;
        gAudioCodecCtx = gFormatCtx->streams[gAudioStreamIdx]->codec;
        gAudioCodec = avcodec_find_decoder(gAudioCodecCtx->codec_id);
    
        if (gAudioCodec == NULL)
            return -5;
    
        if (avcodec_open(gAudioCodecCtx, gAudioCodec)<0)
            return -6;
    
    
        gAudioBuffer = (char *)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE *2); 
        int decode = 0;
    
        while (av_read_frame(gFormatCtx, &packet) >= 0)
        {
         if (gFormatCtx-> streams[packet.stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
         {
             int data_size = AVCODEC_MAX_AUDIO_FRAME_SIZE * 8; 
             gAudioBuffer = (char *)av_malloc(data_size);
             int size=packet.size;
             while(size > 0)
             {
              int len = avcodec_decode_audio3(gAudioCodecCtx,
                (short *) gAudioBuffer, &data_size, &packet);
              if (data_size > 0)
              {
                        jbyte *bytes = (*env)->GetByteArrayElements(env, array, NULL);
                           memcpy(bytes + decode, (int16_t *)gAudioBuffer, size);
                           (*env)->ReleaseByteArrayElements(env, array, bytes, 0);
                           (*env)->CallVoidMethod(env, obj, play, array, data_size); 
                           decode += size;
                           size -= len;
    
              }
             }
         }
         av_free_packet(&packet);
        }
    
        av_close_input_file(gFormatCtx);
        return 0;
    }
    

    Why my android logcat show me this message ? "error opening trace file: No such file or directory (2)"