Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to join two ffmpeg commands

    26 novembre 2012, par Ambrose Bwangatto

    i have a script which uses this ffmpeg command's parameters for encoding videos.

    ffmpeg -i inputfile -acodec libfaac -keyint_min 20 -r 20 -vcodec libx264 -vpre hq -crf 25 -b 300k -bt 300k -y -v 0 -bf 16 -threads 0 outputfile
    

    and i have a custom command i would like to add to it, is like this

    ffmpeg -i inputfile -vf "movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputfile
    

    so i replaced main command like this

     ffmpeg -i inputfile -acodec libfaac -keyint_min 20 -r 20 -vcodec libx264 -vpre hq -crf 25 -b 300k -bt 300k -y -v 0 -bf 16 -threads 0 -vf "movie=watermark1.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputfile
    

    and tried it in command line, but this doesnt do anything, the output is nothing like this

    [root@www test1]#  ffmpeg -i test1800.mp4 -acodec libfaac -keyint_min 20 -r 20 -vcodec libx264 -vpre hq -crf 25 -b 300k -bt 300k -y -v 0 -bf 16 -threads 0 -vf "movie=watermark1.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputfile.mp4
    [root@www test1]#
    

    how do i solve this ?

    Thanks for your time.

    UPDATE My ffmpeg command details

    [root@www test1]# ffmpeg
    ffmpeg version N-47061-gbe2c0bc Copyright (c) 2000-2012 the FFmpeg developers
      built on Nov 25 2012 09:32:08 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-52)
      configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
      libavutil      52.  9.100 / 52.  9.100
      libavcodec     54. 77.100 / 54. 77.100
      libavformat    54. 37.100 / 54. 37.100
      libavdevice    54.  3.100 / 54.  3.100
      libavfilter     3. 23.102 /  3. 23.102
      libswscale      2.  1.102 /  2.  1.102
      libswresample   0. 17.101 /  0. 17.101
      libpostproc    52.  2.100 / 52.  2.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'
    

    thanks

  • ffmpeg crash after complaining about unreleased buffer ? [closed]

    26 novembre 2012, par twid

    I get following error in ffmpeg. And then ffmpeg crashes.....

    [mpeg4 @ 03b72ec0] Found 2 unreleased buffers!   
    Assertion i < avci->buffer_count failed at libavcodec/utils.c:603
    

    I want know why and what circumstances it crashing?

  • join audio file in specific time of the video ffmpeg

    25 novembre 2012, par George L.

    i am trying to use the code bellow to merge an audio file at specific time (6th second of my input video) and create a new video autput file but i cant make it work.

    <?php
    
    exec("/usr/local/bin/ffmpeg -sameq -i /home/xxx/public_html/xxx/video/full.mp4 -itsoffet 6 -i /home/xxx/public_html/xxx/sounds/names/george.mp3 /home/xxx/public_html/xxx/upload/sample.mpg");
    
    
    ?>
    

    Thank you a lot!

  • Exit Status with ffmpeg Command in Rails

    25 novembre 2012, par DragonFire353

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

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

    I was using purely paperclip before and making the user wait and it worked great, now I am having problems with the return of the error status for the command, I have tried editing to possible fix the command wondering if it was failing in the first place but I keep getting:

    undefined method `exitstatus' for nil:NilClass
    

    no matter what. I've tried looking this up and it's supposedly valid syntax that should work... Also I've commented out the actual spawn do part because I get another error if I leave that in:

    wrong number of arguments
    

    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
      include AASM
    
      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"
      #, :styles => { 
         # :video => { geometry: "800x480>", format: 'webm' },
         # :thumb => { geometry: "200x200>", format: 'png', time: 3 },
       # }, processors: [:ffmpeg], 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
    
      #acts as state machine plugin
      aasm state: :pending do
       state :pending, initial: true
       state :converting
       state :converted
       #, enter: :set_new_filename
       state :error
    
        event :convert do
         transitions from: :pending, to: :converting
       end
    
        event :converted do
         transitions from: :converting, to: :converted
       end
    
        event :failure do
          transitions from: :converting, to: :error
        end
      end
    
       # This method is called from the controller and takes care of the converting
      def convert
        self.convert!
    
        #spawn a new thread to handle conversion
        #spawn do
          success = delay.system(convert_command)
          logger.debug 'Converting File: ' + success.to_s
          if success && $?.exitstatus.to_i == 0
            self.converted!
          else
            self.failure!
          end
        #end
      end
    
      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
        def convert_command
          #construct new file extension
          webm =  "." + id.to_s + ".webm"
    
          #build the command to execute ffmpeg
          command = <<-end_command
            ffmpeg -i #{ RAILS_ROOT + '/public/users/:user_id/videos/:id/:basename_:style.:extension' }  -ar 22050 -ab 32 -s 1280x720 -vcodec webm -r 25 -qscale 8 -f webm -y #{ RAILS_ROOT + '/public/users/:user_id/videos/:id/:basename_.webm' }
    
          end_command
    
          logger.debug "Converting video...command: " + command
          command
        end
    
        handle_asynchronously :convert_command
    
        # 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.convert
            flash[:success] = "Uploaded Succefully!"
            redirect_to @video.user
        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
    
  • Video Slideshow from png files + mp3 audio

    25 novembre 2012, par James Evans

    I have a bunch of .png frames and a .mp3 audio file which I would like to convert into a video. Unfortunately, the frames do not correspond to a constant frame rate. For instance, one frame may need to be displayed for 1 second, whereas another may need to be displayed for 3 seconds.

    Is there any open-source software (something like ffmpeg) which would help me accomplish this? Any feedback would be greatly appreciated.

    Many thanks!