Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • create video editor error stream specifier [on hold]

    25 mai 2018, par Oussama

    I am a beginner in ffmpeg, and I started by creating a video editor, but I encountered an error while executing an ffmpeg command:

    'Stream specifier' ' in filtergraph description .... matches no streams'

    Here is the command:

    'ffmpeg -y -i icone1.jpg -i icone2.jpg -i icone3.jpg -i icone4.jpg -loop 1 -framerate 24 -t 5 -i image1.jpg -loop 1 -framerate 24 -t 5 -i image2.jpg -i song.mp3 -filter_complex " color=black@0:1365x701,format=yuva444p[c0]; color=black@0:1365x701,format=yuva444p[c1]; [c0][4]scale2ref[ct0][mv0]; [c1][5]scale2ref[ct1][mv1]; [ct0]setsar=1,split=2[t00][t01]; [ct1]setsar=1,split=1[t10]; [t00]drawtext=fontfile='arial':text='azaazzaza':fontcolor=red:fontsize=30[tfi00]; [t01]drawtext=fontfile='arial':text='drtgfh':fontcolor=red:fontsize=30[tfi01]; [t10]drawtext=fontfile='arial':text='uygfdsdsqds':fontcolor=blue:fontsize=30[tfi10]; [mv0][tfi00]overlay=x=55.0000:y=12.0000:shortest=1[mv0]; [mv0][tfi01]overlay=x=55.0000:y=12.0000:shortest=1[mv0]; [mv1][tfi10]overlay=x=55.0000:y=55.0000:shortest=1[mv1]; [0]scale=500:500,setsar=sar=1[img0]; [1]scale=500:500,setsar=sar=1[img1]; [2]scale=40:50,setsar=sar=1[img2]; [3]scale=500:500,setsar=sar=1[img3]; [mv0][img0]overlay=20.0000:20.0000[mv01]; [mv01][img1]overlay=12.0000:12.0000[mv02]; [mv1][img2]overlay=20.0000:12.0000[mv12]; [mv12][img3]overlay=55.0000:12.0000[mv13]; [mv02]scale=1280:720,setsar=sar=1[fram0]; [mv13]scale=1280:720,setsar=sar=1[fram1]; [5]atrim=duration=10[a1]; [fram0][fram1]concat=n=2:v=1:a=0[all]" -map [all] -map [a1] video-8.mp4'

  • How convert video file from vp8 to h264 in java ?

    25 mai 2018, par tostao

    I can do it via command line:

    ffmpeg -fflags +genpts -i in.mp4 -r 24 out.mp4

    but I am not able to do it in java. I tried to do this via javacv:

    FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(bis);
                grabber.setOption("fflags", "genpts");
                grabber.start();
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                FFmpegFrameRecorder2 recorder = new FFmpegFrameRecorder2(out, grabber.getImageWidth(), grabber.getImageHeight(), grabber.getAudioChannels());
                recorder.setVideoCodecName("h264");
                recorder.setAudioCodecName("aac");
                recorder.setFormat("mp4");
                recorder.setFrameRate(grabber.getFrameRate());
    //          recorder.setOption("-fflags +genpts -i", " ");
    //          recorder.setOption("movflags" ,"frag_keyframe+genpts");
                recorder.setOption("r", "23");
                recorder.setSampleRate(grabber.getSampleRate());
                recorder.start();
                Frame frame;
                while ((frame = grabber.grabFrame()) != null) {
                    recorder.record(frame);
                }
                recorder.stop();
                grabber.stop();
    

    But can not add parameters from command line above. I tried jcodec but looks like wp8 is not supportet.

    Any advice, tip how can I do it?

  • Using FFMPEG concat to produce a short output video

    25 mai 2018, par MGM

    I need to concatenate 306 images using FFMPEG. so, I proceed with the following script shell :

    touch input.txt
    
    for i in `seq 0 305`;
    do
      echo "file $i.png" >> input.txt
      echo "duration 1" >> input.txt
    done
    
    echo "file 305.png" >> input.txt
    
    ffmpeg -f concat -i input.txt -vf fps=10 -vsync vfr -pix_fmt yuv420p video.mp4
    
    1. I can't find the right parameters for concat.
    2. I searching about duration, I can't find if it's possible to specify less than 1 second.
    3. Every time, I change fps, the duration of output video became so big; example: if fps = 10 , output video duration = 3060 seconds

    also, I tried :

     1. ffmpeg -f concat -i input.txt -vf fps=10 -vsync vfr -pix_fmt yuv420p
        video.mp4
     2. ffmpeg -f concat -i input.txt -y -vf fps=1 -crf 22 -threads 2
        -preset veryfast video.mp4
    

    I tried also, with duration 1 for all images, the final video show only 1 image.

    I need to concat those images and produce a short output video.

    any idea

  • FFmpeg - Multiple videos with 4 areas and different play times

    25 mai 2018, par Robert Smith

    I have videos as follows

    video   time
    ======= =========
    Area 1:
    video1a    0-2000
    video1b 2500-3000
    video1c 3000-4000
    
    Area 2:
    video2a  300- 400
    video2b  800- 900
    
    Area 3:
    video3a  400- 500
    video3b  700- 855
    
    Area 4:
    video4a  400- 500
    video4b  800- 900
    

    Basically these are security camera outputs and should display in 4 areas:

    So far I have the following:

    ffmpeg
        -i 1.avi -i 2.avi -i 3.avi -i 4.avi
        -filter_complex "
            nullsrc=size=640x480 [base];
            [0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft];
            [1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright];
            [2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft];
            [3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright];
            [base][upperleft] overlay=shortest=1 [tmp1];
            [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];
            [tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3];
            [tmp3][lowerright] overlay=shortest=1:x=320:y=240
        "
        -c:v libx264 output.mp4
    

    But there are two things I am missing:

    • The above is only for 4 video files, I need a way to add additional files to each area (for example video1b should play at its corresponding time after video1a in the same area)
    • How do I specify the beginning/ending time as shown above for each file?
  • ffmpeg break up videos with frame persecond

    25 mai 2018, par jameshwart lopez

    Theres a command to extract images of a video providing frame per seconds

    ffmpeg -i "vide.mp4" -vf fps=1 frames/frame_%04d.png -hide_banner
    

    Is there a command in ffmpeg to cut video providing fps and save it as video(.mp4 / avi) file like the command above?

    What i currently have is i created a method to cut the videos with start and endtime but i firstly created a method to get the length of a video so that i could cut the video base on how many frames that was generated by the above command.

     def get_length(self):
            """
            Gets the length of a video in seconds
    
            Returns:
                float : Length of the video
            """
    
            print("Getting video length: " + self.video_string_path)
            command = 'ffprobe -i "'+self.video_string_path+'" -show_entries format=duration -v quiet -of csv="p=0"'
            self.command = command
            length = str(cmd.execute(command)).strip()
            print("lenght: "+length+" second(s)")
            return float(length)
    
    def cut(self, start_time, duration, output_file_name = 'output_file_name.mp4', save_to =''):
            """
            Cut a video on a specific start time of the video and duration.
            Check ffmpeg documentation https://ffmpeg.org/ffmpeg.html for more information about the parameters
    
            Parameters:
                start_time : string
                    is the value of ffmpeg -ss with the format: 00:00:00.000
    
                duration : string | int | float
                    is the end point where the video will be cut. Can be the same with start_time format but it could also handle integer as in seconds
    
                output_file_name : string
                    is the file name once the file is save in the hardisk
    
                save_to : string | optional
                    is the directory where the file will be saved
    
            Returns:
                string: file location of the cutted video
    
            """
    
            self.make_sure_save_dir_exits(save_to)
            print('Cutting ' + self.video_string_path + ' from ' + start_time + ' to ' + str(duration))
            print('Please wait...')
            file = '"' + self.save_to + output_file_name + '"'
            command = 'ffmpeg -i "' + self.video_string_path + '" -ss ' + str(start_time) + ' -t ' + str(duration) + ' -c copy -y ' + file
            self.command = command
            cmd.execute(command)
    
            file_loc = self.get_save_to_dir() + output_file_name
            print('Done: Output file was saved to "' + file_loc + '"')
    
            return file_loc + output_file_name