Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • ffmpeg progress is freezing frames when scene change

    19 août 2017, par Karol

    I'm capturing data from IP camera with RTSP protocol with ffmpeg with command:

    ffmpeg -rtsp_transport tcp -progress /media/kamip/stats.txt -i rtsp://192.168.1.220:554/live/h264/ch0 
    -c:v copy -c:a copy -strict 1 -map 0 -f segment -strftime 1 
    -segment_time 1800 /media/kamip/cam_%d_%m_%Y_%H_%M_%S.mkv
    

    I'm using this for 5 cameras. One is different type and it is in different location. Because ffmpeg does not support reconnect I'm writing status to /media/kamip/stats.txt file. In another script I'm parsing this output and every 30 seconds I'm checking if frame number changed, if yes - it is ok, if not, I'm restarting above command.

    The problem is only in the night. When is quite dark and suddenly lights on, for example when car is parking, the /media/kamip/stats.txt is showing the same frame number, so my script is recognizing this as a lost connection (video freeze)

    I tried "-strict 1" option and I think it is better (one false alarm per day instead of 10 per day), so I think this may be related to ffmpeg, not camera/video source, especially because the video is fine even frame number reported by ffmpeg is still the same. Also VLC does not have this kind of problem (but I cannot use it currently for this camera)

    I found that ffmpeg has build-in scene change detector, but it should works only when encoding video (I'm using "copy" option for audio and video)?

    I'm thinking about different way of analyzing the video capturing, but this "-progress" in ffmpeg should works fine - and it is working fine for other cameras for few years).

    I also do not see any errors, when I encoded one cutted file with "-loglevel debug" I saw only information like below:

    [libx264 @ 0x25d77a0] scene cut at 174 Icost:2049115 Pcost:2006553 
    ratio:0.0208 bias:0.1387 gop:54 (imb:3186 pmb:168)
    

    ffmpeg in latest version

    ffmpeg version 3.3.3-1ubuntu1~16.04.york0 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609

    any help will be appreciated

  • How to complex the video and gif and make the watermark loop in FFmpeg ?

    19 août 2017, par Wooi

    I had complex video and gif but the gif was play once time, I also set the loop param , It seem didn't work any more.

    ffmpeg -y -i /sdcard/Download/Test2/test2.mp4 -loop 1 -i /sdcard/Download/Test2/1.gif -loop 1 -i /sdcard/Download/Test2/2.gif -filter_complex [1:v]rotate=30*PI/180:c=none:ow=rotw(iw):oh=roth(ih)[rotete1];[0:v][rotete1]overlay=main_h-overlay_h-10:main_w-overlay_w-10[overlayout1];[2:v]rotate=30*PI/180:c=none:ow=rotw(iw):oh=roth(ih)[rotete2];[overlayout1][rotete2]overlay=20:20[out3] -map [out3] -map 0:a -codec:a copy /sdcard/Download/Test2/output.mp4
    
  • encoding yuv to mpeg-2 using ffmpeg

    19 août 2017, par aparajithhh_sai

    I want to encode my .yuv file using mpeg-2 encoder in ffmpeg. I am getting the errors " Picture size 0x0 is invalid"and Name of the input File: Invalid argument. Please help me with this issue.

    ffmpeg -i C:\Users\susee\Documents\dATAsET\bus_cif.yuv -s 352x288 -r 25 -
    codec:v mpeg2video -vf scale=704x396,interlace -b:v 4000k -codec:a mp2 -b:a 
    128k -ar 48000 C:\Users\susee\Documents\dATAsET\output1.mpg
    
  • Convert any type of video to mp4 then add the path to the database

    19 août 2017, par Dilak

    So here is my problem : On my website I want to allow users to upload any type of video. But with the HTML5 tag only .mp4 video can be used. So I want to convert any type of video submit by the user to MP4 then add the path to the databse.

    I've read something about FFmpeg but I can't figure out how to use it. I tried to use shell_exec("ffmpeg -i ".$vid." -vcodec libx264 -crf 20 out.mp4 2>&1") without success.

    The html

    The php script:

    if(file_exists($_FILES['media-vid']['tmp_name']) && is_uploaded_file($_FILES['media-vid']['tmp_name']))
    	{
    		
    		
    		
    		$targetvid = md5(time());
    		$target_dirvid = "videos/";
    		$target_filevid =  $targetvid.basename($_FILES["media-vid"]["name"]);
    		$uploadOk = 1;
    		$videotype = pathinfo($target_filevid,PATHINFO_EXTENSION);
    	
    		
    			
    		if ($_FILES["media-vid"]["size"] > 500000000) {
    		$uploadOk = 0;
    		echo "Sorry, your file is too large.";
    		}
    	
    	// Check if $uploadOk is set to 0 by an error
    	if ($uploadOk == 0) {
    		echo "Sorry, your video was not uploaded."; 
    	// if everything is ok, try to upload file
    		} else {
    		
    		 $target_filevid = strtr($target_filevid, 
    			  'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 
    			  'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
    		 $target_filevid = preg_replace('/([^.a-z0-9]+)/i', '_', $target_filevid);
    	   
    		if (!move_uploaded_file($_FILES["media-vid"]["tmp_name"], $target_dirvid. $target_filevid)) {
    		 
    			echo "Sorry, there was an error uploading your file. Please retry.";
    		}else{
    			
    			$vid= $target_dirvid.$target_filevid;
    	
    			shell_exec("ffmpeg -i ".$vid." -vcodec libx264 -crf 20  out.mp4 2>&1");
    
    		
    			}
    		}
    	}
    	
    	
  • ffmpeg image sequence specify input framerate

    19 août 2017, par Davide

    I am trying to set the input framerate of a sequence of images (many folders):

    if I am working with a single image sequence everything works properly:

    ffmpeg -framerate 30 -i folder01/img%05d.jpeg -filter:v "crop=640:360" -r 30 outfilm.mp4

    then, because I have more folders (and I was unable to get the -i concat:filesequence1|filesequence2 working) I tried to use:

    ffmpeg -framerate 30 -f concat -safe 0 -i filelist.txt -filter:v "crop=640:360" -r 30 outfilm.mp4

    but I receive an error:

    Option framerate not found.

    then if I omit the -framerate 30, everything runs smoothly, but ffmpeg defaults to a 25 fps value for the input image sequences.

    Any ideas on how to fix this?