Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Why does Android kill a process spawned by the developed application ?

    23 octobre 2013, par uprego

    I have a weird problem that I posted as a comment in Understanding Android Tight loops / Spin-On-Suspend error without any useful further comment.

    Let be here the reproduced comment:

    Is it possible for this to be happening also to android native codes, abstracting
     which piece of software would be causing it? It's the only reason I know ffmpeg 
    (static binary custom compilation, n2.0.1 tag mint as it clones) is failing to me
     on some devices and not in others (but fails in no device when launched over a v
    algrind!! that, am now supposing, traps frequently the inner program)
    

    The problem, briefly, is that a compiled ffmpeg n2.0.1 is running OK in emulator and a Sony device, but failing with a segmentation violation in a Samsung device. The program was ran then from valgrind in that Samsung device, with no fail.

    • I have some clues about what could be happening here. But do you know what is happening?
    • Can this Samsung phone run this ffmpeg compilation the same good the emulator and the Sony phone do? If not, what are the next steps (trying - when possible - to avoid the use of the NDK)?
  • syntax error on accessing a structure variables

    23 octobre 2013, par JAYANTHI

    This is my code

    typedef struct AVInputFormat {
    /**
     * A comma separated list of short names for the format. New names
     * may be appended with a minor bump.
     */
    const char *name;
    
    /**
     * Descriptive name for the format, meant to be more human-readable
     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
     * to define it.
     */
    const char *long_name;
    
    /**
     * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
     * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
     */
    int flags;
    
    /**
     * If extensions are defined, then no probe is done. You should
     * usually not use extension format guessing because it is not
     * reliable enough
     */
    const char *extensions;
    
    const struct AVCodecTag * const *codec_tag;
    
    const AVClass *priv_class; ///< AVClass for the private context
    
    /*****************************************************************
     * No fields below this line are part of the public API. They
     * may not be used outside of libavformat and can be changed and
     * removed at will.
     * New public fields should be added right above.
     *****************************************************************
     */
    struct AVInputFormat *next;
    
    /**
     * Raw demuxers store their codec ID here.
     */
    int raw_codec_id;
    
    /**
     * Size of private data so that it can be allocated in the wrapper.
     */
    int priv_data_size;
    
    /**
     * Tell if a given file has a chance of being parsed as this format.
     * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
     * big so you do not have to check for that unless you need more.
     */
    int (*read_probe)(AVProbeData *);
    
    /**
     * Read the format header and initialize the AVFormatContext
     * structure. Return 0 if OK. Only used in raw format right
     * now. 'avformat_new_stream' should be called to create new streams.
     */
    int (*read_header)(struct AVFormatContext *);
    
    /**
     * Read one packet and put it in 'pkt'. pts and flags are also
     * set. 'avformat_new_stream' can be called only if the flag
     * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
     * background thread).
     * @return 0 on success, < 0 on error.
     *         When returning an error, pkt must not have been allocated
     *         or must be freed before returning
     */
    int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
    
    /**
     * Close the stream. The AVFormatContext and AVStreams are not
     * freed by this function
     */
    int (*read_close)(struct AVFormatContext *);
    
    /**
     * Seek to a given timestamp relative to the frames in
     * stream component stream_index.
     * @param stream_index Must not be -1.
     * @param flags Selects which direction should be preferred if no exact
     *              match is available.
     * @return >= 0 on success (but not necessarily the new offset)
     */
    int (*read_seek)(struct AVFormatContext *,
                     int stream_index, int64_t timestamp, int flags);
    
    /**
     * Get the next timestamp in stream[stream_index].time_base units.
     * @return the timestamp or AV_NOPTS_VALUE if an error occurred
     */
    int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
                              int64_t *pos, int64_t pos_limit);
    
    /**
     * Start/resume playing - only meaningful if using a network-based format
     * (RTSP).
     */
    int (*read_play)(struct AVFormatContext *);
    
    /**
     * Pause playing - only meaningful if using a network-based format
     * (RTSP).
     */
    int (*read_pause)(struct AVFormatContext *);
    
    /**
     * Seek to timestamp ts.
     * Seeking will be done so that the point from which all active streams
     * can be presented successfully will be closest to ts and within min/max_ts.
     * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
     */
    int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
    } AVInputFormat;
    
    AVInputFormat ff_yop_demuxer = {
    .name           = "yop",                                               //error here
    .long_name      = NULL_IF_CONFIG_SMALL("Psygnosis YOP"),
    .priv_data_size = sizeof(YopDecContext),
    .read_probe     = yop_probe,
    .read_header    = yop_read_header,
    .read_packet    = yop_read_packet,
    .read_close     = yop_read_close,
    .read_seek      = yop_read_seek,
    .extensions     = "yop",
    .flags          = AVFMT_GENERIC_INDEX,
    };
    

    Getting error like,

    3>c:\users\awki6\desktop\ffmpeg\libavformat\yop.cpp(235): error C2143: syntax error : missing '}' before '.' 3>c:\users\awki6\desktop\ffmpeg\libavformat\yop.cpp(235): error C2143: syntax error : missing ';' before '.' 3>c:\users\awki6\desktop\ffmpeg\libavformat\yop.cpp(235): error C2059: syntax error : '.' 3>c:\users\awki6\desktop\ffmpeg\libavformat\yop.cpp(245): error C2143: syntax error : missing ';' before '}' 3>c:\users\awki6\desktop\ffmpeg\libavformat\yop.cpp(245): error C2059: syntax error : '}'

    Please help me to solve those errors

  • Background Video Processing with Rails

    23 octobre 2013, par Matthew Snyder

    I am trying to get uploaded videos to be converted in the background, running windows. Some of what I am using:

    gem 'paperclip'
    gem 'delayed_job_active_record'
    gem 'ffmpeg'
    

    I have edited the registry to allow the ffmpeg command to be ran from anywhere, I get a popup that I assume is ffmpeg because it goes away too quickly, guess the command is wrong so if anyone knows what's wrong with it please let me know. But the real problem is that it just hangs there, it says:

    [2012-12-09 22:47:03] ERROR invalid body size.
    [2012-12-09 22:47:03] ERROR Errno::ECONNABORTED: An established connection was a
    borted by the software in your host machine.
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `write'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `<<'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:396:i
    n `_write_data'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:368:i
    n `send_body_string'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:249:i
    n `send_body'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpresponse.rb:152:i
    n `send_response'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:110:in
    `run'
            C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `blo
    ck in start_thread'
    

    Does anyone know how to properly get this working? I've went through a few tutorials that have bits and pieces of what I need but I can't get them working together. Here's what I have so far, lemme know if you need more:

    Model:

    class Video < ActiveRecord::Base
    
      belongs_to :user
      has_many :comments, dependent: :destroy
      attr_accessible :video, :user_id, :video_file_name, :title, :public, :description, :views
    
      has_attached_file :video, url: "/users/:user_id/videos/:id/:basename_:style.:extension"
    
      #process_in_background :video #causes death
    
      validates :video, presence: true
      validates :description, presence: true, length: { minimum: 5, maximum: 100}
      validates :title, presence: true, length: { minimum: 1, maximum: 15 }
    
      validates_attachment_size :video, less_than: 1.gigabytes
      validates_attachment :video, presence: true
    
      default_scope order: 'created_at DESC'
    
      Paperclip.interpolates :user_id do |attachment, style|attachment.instance.user_id
      end
    
      #before_post_process do |video|
       # false if video.status == "converting"
      #end
    
      def perform
        command = <<-end_command
          start ffmpeg -i #{ '/public/users/:user_id/videos/:id/:basename_:style.:extension' }  -ar 22050 -ab 32 -s 1280x720 -vcodec webm -r 25 -qscale 8 -f webm -y #{ '/public/users/:user_id/videos/:id/:basename_.webm' }
    
        end_command
        success = system(command)
        logger.debug 'Converting File: ' + success.to_s
        if success && $?.exitstatus.to_i == 0
          #self.converted!
          self.status = "converted"
        else
          #self.failure!
          self.status = "failed"
        end
      end
    
      handle_asynchronously :perform
    
      def self.search(search)
        if search
          find(:all, conditions: ["public = 't' AND title LIKE ?", "%#{search}%"], order: "created_at DESC")
        else
          find(:all, conditions: ["public = 't'"], order: "created_at DESC")
        end
      end
    
      def self.admin_search(search)
        if search
          find(:all, conditions: ['title LIKE ?', "%#{search}%"], order: "created_at DESC")
        else
          find(:all, order: "created_at DESC")
        end
      end
    
      private
    
        # This updates the stored filename with the new flash video file
        def set_new_filename
          #update_attribute(:filename, "#{filename}.#{id}.webm")
          update_attribute(:content_type, "video/x-webm")
        end
    
    end
    

    Controller:

    class VideosController < ApplicationController
        before_filter :signed_in_user, only: [:upload, :update, :destroy]
        before_filter :admin_user, only: :admin_index
    
        def upload
            @video = Video.new
            # generate a unique id for the upload
            @uuid = (0..29).to_a.map {|x| rand(10)}
        end
    
        def create
            @video = Video.new(params[:video])
            @video.user_id = current_user.id
    
            if @video.save
                @video.delay.perform
                flash[:success] = "Uploaded Succefully!"
                redirect_to @video.user
                Delayed::Worker.new.start
            else
                render 'upload'
            end
        end
    
        def show
            @video = Video.find(params[:id])
            @comments = @video.comments.paginate(page: params[:page], per_page: 6)
            if !@video.public
                if !signed_in? || current_user.id != @video.user_id  && !current_user.admin && !current_user.approved?(@video.user)
                flash[:notice] = "Video is private"
                redirect_to root_path
            end
        end
        end
    
        def update
            @video = Video.find(params[:id])
            if @video.update_attributes(params[:video])
          flash[:success] = "Video preferences saved"
        else
            flash[:fail] = "Failed to update video preferences"
        end
        redirect_to :back
      end
    
        def destroy
            @video = Video.find(params[:id])
            @video.destroy
            flash[:deleted] = "Deleted Succefully!"
            redirect_to :back
        end
    
        def index
            @videos = Video.paginate(page: params[:page], per_page: 6).search(params[:search])
        end
    
        def admin_index
            @videos = Video.paginate(page: params[:page], per_page: 6).admin_search(params[:search])
        end
    
        def ajax_video_comments
            @video = Video.find(params[:id])
            @comments = @video.comments.paginate(page: params[:page], per_page: 6)
    
            respond_to do |format|
            format.js   { render partial: 'shared/comments', content_type: 'text/html' }
        end
        end
    
        def ajax_video_watched
            @video = Video.find(params[:id])
            @video.views += 1
            @video.save
        end
    
        private
    
        def signed_in_user
            redirect_to root_path, notice: "Please Login." unless signed_in?
        end
    
        def admin_user
            redirect_to(root_path) unless current_user.admin?
        end
    
    end
    
  • Live Video Streaming from android device to server [on hold]

    23 octobre 2013, par Android_sp

    hey friends i want your help

    i search a lot and study lots of code available for streaming for android but yet i can't get clear idea for me. i want simple one thing to pass stream from android device to wowza server in H.264 encoding for video and AAC for Audio.

    here some links which i already serf :

    Which not anwser :Link 1

    i also refer this most popular question from our site : Link 2

    but this useful but at some level ..

    1) Native side by using FFmpeg library i can able to send video stream but can't find a way how to encode video in H.264 format : Downloaded from here

    2) SPYdroid demo i found but from this i can send video stream to particular server : Downloaded from Here

    so guys if you know some thing please help me so i can find a way.

  • RTP server for audio stream

    23 octobre 2013, par NetCoder89

    I'm in the mid of my project where I'm trying to send the audio data over RTP using ffmpeg in VC++. but I'm unable to do that. My start up code is:

    setRTPOutputAddr("127.0.0.1");
        setRTPOutputPort(9985);
        av_register_all();
        avformat_network_init();
        formatCtx= avformat_alloc_context();
    
        //av_dump_format(formatCtx,0,"rtp",1);
                avio_open_dyn_buf(&ioctx);
                avio_open(&formatCtx->pb, "rtp", AVIO_FLAG_WRITE);
                //av_dump_format(formatCtx,0,"rtp",1);
                formatCtx->pb = ioctx;
    
                rtpCtx = avformat_alloc_context();
                rtpCtx->oformat = av_guess_format("rtp",0,0);
                AVStream *fakeVideo = 0;
                fakeVideo = avformat_new_stream(rtpCtx,0);
                avcodec_get_context_defaults3(fakeVideo->codec, NULL);
                fakeVideo->codec->codec_id = AV_CODEC_ID_MPEG2TS;
                rtpCtx->audio_codec_id = AV_CODEC_ID_NONE;
                rtpCtx->video_codec_id = AV_CODEC_ID_MPEG2TS;
                // avformat_write_header(rtpCtx,0);
    
                char *url = new char[1024];
                sprintf(url,"rtp://%s:%d",rtpOutputAddr,rtpOutputPort);
                printf("will output to url:%s\n",url);
                avio_open(&rtpCtx->pb,url,AVIO_FLAG_WRITE);
                avformat_write_header(rtpCtx, NULL);
                delete url;
    
    
                if (avio_open(&formatCtx->pb, "rtp", AVIO_FLAG_WRITE) < 0)
                {
                        fprintf(stderr, "Could not open '%s'\n", formatCtx->filename);
            return -1;
        }
                else
                {
    
                printf("succeed \n");
                }
    
    
    Error Here:    avformat_write_header(formatCtx, NULL); //program Crashes
    

    Do anyone having any idea where I'm doing wrong?

    Thanks!