Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Realtime ffmpeg shell output PHP
26 septembre 2013, par matthew johnstonAlright, I've been fighting this problem for a few days. Works fine on my local windows machine but, can't seem to get it to work on my CentOS server. My script grabs the duration of the video being converted and also grabs the current seconds it has processed inside of ffmpeg. However, it is only grabbing the "input file" of the ffmpeg output and stopping there. I have tried using both pipes (STDOUT [1] & STDERR [2]) for some reason ffmpeg likes to output on the STDERR pipe. Weird.
$filename = "somefilename.tmp"; $descriptor = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w") ); $ffmpeg = "ffmpeg -i /var/www/spotloader/videos/flipped/tmp/".$file."_comb.ts -vcodec mpeg2video -acodec pcm_s16le -pix_fmt yuv422p -vtag xdvb -b:v 13000k -r 30000/1001 /var/www/spotloader/videos/flipped/tmp/".$file.".mov"; //open the process $process = proc_open($ffmpeg, $descriptor, $pipes, NULL, $_ENV); //if the process opened if ( is_resource( $process ) == true ) { //get process status $procStatus = proc_get_status( $process ); //if its running, let node know if ( $procStatus['running'] ) { //nodejs socket, nothing wrong here $this->_sendSocket('converting', array('filename' => str_replace('.tmp', '', $file))); } //while the process is running while( $procStatus['running'] === true ) { //there is output in the pipe if ( !feof( $pipes[1] ) ) { //get the output $data = fgets($pipes[1], 128); //match the outputs duration and save it. if(preg_match('/Duration:\s([0-9]{2}:[0-9]{2}:[0-9]{2})/', $data, $matches)) { static $duration; $duration = $this->_convertToSeconds($matches[1]); } //match the outputs current encoding time if(preg_match('/time=([0-9]{2}:[0-9]{2}:[0-9]{2})/', $data, $matches)) { //convert to seconds works fine, so it is not included. $curTime = $this->_convertToSeconds($matches[1]); //nodejs socket, nothing wrong here $this->_sendSocket('update', array('percent' => round( ($curTime / $duration) * 100), 'filename' => str_replace('.tmp', '', $file))); } } //update process status $procStatus = proc_get_status( $process ); } //nodejs socket, nothing wrong here $this->_sendSocket('converted', array('percent' => 100, 'filename' => str_replace('.tmp', '', $file))); }
FFMPEG output I receive using the PHP code above
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping libavutil 52. 18.100 / 52. 18.100 libavcodec 54. 92.100 / 54. 92.100 libavformat 54. 63.104 / 54. 63.104 libavdevice 54. 3.103 / 54. 3.103 libavfilter 3. 42.103 / 3. 42.103 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [mpegts @ 0x243c620] max_analyze_duration 5000000 reached at 5016000 microseconds Input #0, mpegts, from '/var/www/spotloader/videos/flipped/tmp/Wildlife10.tmp_comb.ts': Duration: 00:00:02.02, start: 1.389978, bitrate: 227018 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: mpeg2video (4:2:2) ([2][0][0][0] / 0x0002), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, 1 channels (FL+FR), s16p, 128 kb/s
FFMPEG output I'm expecting the "time=00:00:00" towards the end is what I need to capture in realtime. This is taken by running the FFMPEG command directly in the shell.
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4) configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping libavutil 52. 18.100 / 52. 18.100 libavcodec 54. 92.100 / 54. 92.100 libavformat 54. 63.104 / 54. 63.104 libavdevice 54. 3.103 / 54. 3.103 libavfilter 3. 42.103 / 3. 42.103 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [mpegts @ 0x10c9620] max_analyze_duration 5000000 reached at 5016000 microseconds Input #0, mpegts, from '/var/www/spotloader/videos/flipped/tmp/Wildlife10.tmp_comb.ts': Duration: 00:00:02.02, start: 1.389978, bitrate: 227018 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: mpeg2video (4:2:2) ([2][0][0][0] / 0x0002), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc Stream #0:1[0x101](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, 1 channels (FL+FR), s16p, 128 kb/s Channel layout 'stereo' with 2 channels does not match specified number of channels 1: ignoring specified channel layout Output #0, mov, to '/var/www/spotloader/videos/flipped/tmp/Wildlife10.tmp.mov': Metadata: encoder : Lavf54.63.104 Stream #0:0: Video: mpeg2video (xdvb / 0x62766478), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 13000 kb/s, 30k tbn, 29.97 tbc Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s Stream mapping: Stream #0:0 -> #0:0 (mpeg2video -> mpeg2video) Stream #0:1 -> #0:1 (mp2 -> pcm_s16le) Press [q] to stop, [?] for help Input stream #0:1 frame changed from rate:48000 fmt:s16p ch:1 chl:1 channels (FL+FR) to rate:48000 fmt:s16p ch:2 chl:stereo Input stream #0:1 frame changed from rate:48000 fmt:s16p ch:2 chl:stereo to rate:48000 fmt:s16p ch:1 chl:mono Input stream #0:1 frame changed from rate:48000 fmt:s16p ch:1 chl:mono to rate:48000 fmt:s16p ch:2 chl:stereo Input stream #0:0 frame changed from size:1920x1080 fmt:yuv422p to size:1280x720 fmt:yuv422p0 Input stream #0:1 frame changed from rate:48000 fmt:s16p ch:2 chl:stereo to rate:44100 fmt:s16p ch:2 chl:stereo frame= 741 fps= 52 q=2.6 size= 43866kB time=00:00:24.65 bitrate=14573.5kbits/s dup=5 drop=0
Any ideas? What needs changing from the switch from Windows to CentOS?
EDIT: I got this to work using popen instead. It also reduced my code. If anyone else does have a solution go ahead and post it. Thanks!
-
How to compile avconv with libx264 on Ubuntu 12.04.?
26 septembre 2013, par KugutsumenIs there any step by step guide on how to compile avconv in Ubuntu?
It seems hard to search for any tutorial with avconv compared to ffmpeg. -
How to use FFMPEG commands
26 septembre 2013, par Shashank AgarwalIn android i am making an app in which it will record an video and crop the video from center for doing so i found FFMPEG over google. I followed http://dmitrydzz-hobby.blogspot.in/2012/04/how-to-build-ffmpeg-and-use-it-in.html
It works fine but i want to know how to use this `ffmpeg -y -i /sdcard/videokit/short.mp4 -vf crop=100:100:0:0 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 /sdcard/videokit/out.mp4
` video cropping command and Where to write this command.
I have tried this (for concatenation just to check about how to use ffmpeg command )
public class MainActivity extends Activity { private static native int logFileInfo(String[] args); String pathOut = "/storage/sdcard/12.mp3"; String pathInM = "/storage/sdcard/23.mp3"; String pathIn = "/storage/sdcard/out.mp3"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] args = {"ffmpeg", "-i", "concat:", pathOut, "|",pathInM ,pathIn}; logFileInfo(args); //logFileInfo("/storage/sdcard/12.mp3"); } static { System.loadLibrary("mylib"); }
But i dont know what to write in mylib.c to execute this.somebody Please help
-
The .mp4 video does not play, which is created from ffmpeg library (not command line)
25 septembre 2013, par user1914692I use ffmpeg library to encode frames to a .mp4 video. The program runs smoothly without error. But the output .mp4 video does not play. Properties of the file does not even show it is a video file, no any information of video stream.
The related code is:
const char* ouVideoFileName = "output.mp4"; AVCodecID ouCodec_id = CODEC_ID_H264;
But if I change it to:
const char* ouVideoFileName = "output.avi"; AVCodecID ouCodec_id = CODEC_ID_H264;
The .avi video plays correctly.
What's wrong with .mp4 video?
-
Execute FFmpeg commands in android
25 septembre 2013, par user2816350I have all the ffmpeg´s files compiled in my android project, but I don´t know how to call ffmpeg commands. How can I get the "executable" file of the compiled library? What is it exactly? Thanks!!