Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Ffmpeg/Fluent-Ffmpeg : Output File Does Not Reflect Input Parameters
17 août 2017, par Code SherpaUse Case
When a user records an audio file and uploads to firebase storage, run a trigger that crops a clip of that file and saves it to a "preview" directory.
Problem
When the file arrives on the server, it is just dead air before the start time (10 seconds) and then doesn't stop after the duration of 10 seconds is exceeded. Whatever I put in the "-t" and "-ss" arguments seems to have no impact on the output file - not cropping correctly.
Environment
- mac client / firebase storage
- node v8.1.0
- ffmpeg v3.2.2
- fluent-ffmpeg v2.1.2
Node Code
var command = new ffmpeg({ source: tempFilePath, timeout: 0 }) .setFfmpegPath(ffmpegPath) .setFfprobePath(ffprobePath) .inputOption('-t', '10') .inputOption('-ss', '10') .outputOption('-acodec', 'copy') .on('start', function(commandLine) { console.log('Spawned Ffmpeg with command: ', commandLine); }) .on('end', function() { console.log('Preview file cropping done successfully'); }) .on('error', function(err, stdout, stderr) { var build = err; if (!stdout === '') { build = build + '\n' + stdout; } build = build + '\n' + stderr; console.log(build); }).save(tempFilePath);
Ffmpeg Command
Spawned Ffmpeg with command: ffmpeg -t 10 -i /tmp/2EB100B0-6C1E-4D51-9087-764CA653AFC720170711232034.aac -y -acodec aac /tmp/2EB100B0-6C1E-4D51-9087-764CA653AFC720170711232034.aac
Console Output
$ ffmpeg -t 10 -i E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac -y -acodec aac output.aac -loglevel debug ffmpeg version 3.2.2 Copyright (c) 2000-2016 the FFmpeg developers built with llvm-gcc 4.2.1 (LLVM build 2336.11.00) configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --disable-doc --arch=x86_64 --enable-runtime-cpudetect libavutil 55. 34.100 / 55. 34.100 libavcodec 57. 64.101 / 57. 64.101 libavformat 57. 56.100 / 57. 56.100 libavdevice 57. 1.100 / 57. 1.100 libavfilter 6. 65.100 / 6. 65.100 libswscale 4. 2.100 / 4. 2.100 libswresample 2. 3.100 / 2. 3.100 libpostproc 54. 1.100 / 54. 1.100 Splitting the commandline. Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '10'. Reading option '-i' ... matched as input url with argument 'E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac'. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'aac'. Reading option 'output.aac' ... matched as output url. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option loglevel (set logging level) with argument debug. Successfully parsed a group of options. Parsing a group of options: input url E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac. Applying option t (record or transcode "duration" seconds of audio/video) with argument 10. Successfully parsed a group of options. Opening an input file: E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac. [file @ 0x7fe42f700420] Setting default whitelist 'file,crypto' [aac @ 0x7fe431000000] Format aac probed with size=2048 and score=51 [aac @ 0x7fe431000000] Before avformat_find_stream_info() pos: 0 bytes read:32928 seeks:4 nb_streams:1 [aac @ 0x7fe431000000] All info found [aac @ 0x7fe431000000] Estimating duration from bitrate, this may be inaccurate [aac @ 0x7fe431000000] After avformat_find_stream_info() pos: 37888 bytes read:98464 seeks:4 frames:50 Input #0, aac, from 'E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac': Duration: 00:01:24.28, bitrate: 335 kb/s Stream #0:0, 50, 1/28224000: Audio: aac (LC), 44100 Hz, stereo, fltp, 335 kb/s Successfully opened the file. Parsing a group of options: output url output.aac. Applying option acodec (force audio codec ('copy' to copy stream)) with argument aac. Successfully parsed a group of options. Opening an output file: output.aac. [file @ 0x7fe42f7016e0] Setting default whitelist 'file,crypto' Successfully opened the file. detected 4 logical cores [graph 0 input from stream 0:0 @ 0x7fe42f701880] Setting 'time_base' to value '1/44100' [graph 0 input from stream 0:0 @ 0x7fe42f701880] Setting 'sample_rate' to value '44100' [graph 0 input from stream 0:0 @ 0x7fe42f701880] Setting 'sample_fmt' to value 'fltp' [graph 0 input from stream 0:0 @ 0x7fe42f701880] Setting 'channel_layout' to value '0x3' [graph 0 input from stream 0:0 @ 0x7fe42f701880] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3 [audio format for output stream 0:0 @ 0x7fe42f702060] Setting 'sample_fmts' to value 'fltp' [audio format for output stream 0:0 @ 0x7fe42f702060] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350' [AVFilterGraph @ 0x7fe42f6101a0] query_formats: 5 queried, 12 merged, 0 already done, 0 delayed Output #0, adts, to 'output.aac': Metadata: encoder : Lavf57.56.100 Stream #0:0, 0, 1/44100: Audio: aac (LC), 44100 Hz, stereo, fltp, delay 1024, 128 kb/s Metadata: encoder : Lavc57.64.101 aac Stream mapping: Stream #0:0 -> #0:0 (aac (native) -> aac (native)) Press [q] to stop, [?] for help cur_dts is invalid (this is harmless if it occurs once at the start per stream) Last message repeated 1 times [output stream 0:0 @ 0x7fe42f701ee0] EOF on sink link output stream 0:0:default. No more output streams to write to, finishing. [aac @ 0x7fe431001200] Trying to remove 344 more samples than there are in the queue size= 160kB time=00:00:10.00 bitrate= 130.9kbits/s speed=20.2x video:0kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.881580% Input file #0 (E506FE2E-DC81-4DD8-B751-211F7FD9A25820170816160502.aac): Input stream #0:0 (audio): 432 packets read (398208 bytes); 432 frames decoded (442368 samples); Total: 432 packets (398208 bytes) demuxed Output file #0 (output.aac): Output stream #0:0 (audio): 431 frames encoded (441000 samples); 432 packets muxed (160716 bytes); Total: 432 packets (160716 bytes) muxed 432 frames successfully decoded, 0 decoding errors [AVIOContext @ 0x7fe42f611040] Statistics: 0 seeks, 432 writeouts [aac @ 0x7fe431001200] Qavg: 4508.253 [AVIOContext @ 0x7fe42f7004c0] Statistics: 458912 bytes read, 4 seeks
-
Psychopy gives the ffmpeg error and does not play the videos
17 août 2017, par I.NuelI want to create an experiment with Psychopy in which I will present randomly video that participant will have to evaluate.
I have created a routine with my MovieStim and my Rating response and a Loop with my conditions file (in which are my video files videoname.wmv). All my videos are in the same folder as my experiment.
I have specified the MovieStim with a variable refering to my Loop's column ($Stimulus).
But when I run the experiment I have this message.
Running: E:\Thèse ESPRIT\Approach_Aversion\Experience_AA\Approach_Aversion_lastrun.py pyo version 0.8.0 (uses single precision) WARNING:root:Warning: could not find imageio's ffmpeg executable: [Error 5] Accès refus: 'C:\\Program Files (x86)\\PsychoPy2\\lib\\site-packages\\imageio\\resources\\ffmpeg\\ffmpeg.win32.exe' Traceback (most recent call last): File "E:\Thèse ESPRIT\Approach_Aversion\Experience_AA\Approach_Aversion_lastrun.py", line 105, in
depth=0.0, File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\contrib\lazy_import.py", line 120, in __call__ return obj(*args, **kwargs) File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\visual\movie3.py", line 124, in __init__ self.loadMovie(self.filename) File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.84.2-py2.7.egg\psychopy\visual\movie3.py", line 170, in loadMovie self._mov = VideoFileClip(filename, audio=(1 - self.noAudio)) File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 55, in __init__ reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt) File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 32, in __init__ infos = ffmpeg_parse_infos(filename, print_infos, check_duration) File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 237, in ffmpeg_parse_infos proc = sp.Popen(cmd, **popen_params) File "C:\Program Files (x86)\PsychoPy2\lib\subprocess.py", line 710, in __init__ errread, errwrite) File "C:\Program Files (x86)\PsychoPy2\lib\subprocess.py", line 958, in _execute_child startupinfo) WindowsError: [Error 2] Le fichier spécifié est introuvable It seems to be something wrong with the ffmpeg executable but I don't understand what.
Do you have any idea ?
Thank you very much fo advance !
Have a nice day.
Ivane
-
Adding metadata to mp3 file by PHP-FFMpeg doesn't save
17 août 2017, par saeedhbiI'm using PHP-FFMpeg plugin for converting and saving mp3 files uploaded to my server and everything works great but metadata.
This is my code
$ffmpeg = FFMpeg\FFMpeg::create(); $audio = $ffmpeg->open($file_tmp); $f_audio = new FFMpeg\Format\Audio\Mp3(); $f_audio->setAudioKiloBitrate($new_bitrate); $audio->filters()->addMetadata(["title" => 'my title']); $audio->save($f_audio, $path);
File is created by custom bitrate but none of metadata has been assigned to file.
Thanks for your help.
-
create thumbnails for mp4 using ffmpeg
17 août 2017, par user1411837Iam using ffmpeg with php to create thumbnails for videos on the fly .It saves the thumbnails to a particular file and then i retrieve it using php. I want to create thumbnails for all types of videos possible. The problem with ffmpeg that iam facing is that iam not able to create thumbnails for videos with .mp4 extensions.
<? $ffmpeg = '/usr/bin/ffmpeg/ffmpeg'; //to load the extension ffmpeg $video = '/path/to/video'.$file_thumb; //path to the video $image = '/store/it/here'; //path to store the thumbnail $interval = 5; $size = '640x480'; //It runs with the below command $cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";
?>
-
How to cut and merge avi videos with java
17 août 2017, par MonticleI want to cut and merge some avi videos(same codec, same resolution, same fps) using java library.
Now I am trying this using Humble video(https://github.com/artclarke/humble-video), which is based on ffmpeg.
I want to use the seek function to cut the input video first, but the result is not correct.
this is my code.
public void cutjob(String input, String output, int starttime) { final Demuxer demuxer = Demuxer.make(); final Muxer muxer = Muxer.make(output, null, "avi"); try { demuxer.open(input, null, false, true, null, null); final MuxerFormat format = MuxerFormat.guessFormat("avi", null, null); int n = demuxer.getNumStreams(); final Decoder[] decoders = new Decoder[n]; for (int i = 0; i < n; i++) { final DemuxerStream ds = demuxer.getStream(i); decoders[i] = ds.getDecoder(); final Decoder d = decoders[i]; if (d != null) { if (format.getFlag(MuxerFormat.Flag.GLOBAL_HEADER)) d.setFlag(Coder.Flag.FLAG_GLOBAL_HEADER, true); d.open(null, null); muxer.addNewStream(d); } } muxer.open(null, null); demuxer.seek(-1, Long.MIN_VALUE, (long)starttime* Global.getDefaultTimeBase().getDenominator(), Long.MAX_VALUE, Demuxer.SeekFlag.SEEK_ANY.swigValue()); final MediaPacket packet = MediaPacket.make(); long dts = -1; while (demuxer.read(packet) >= 0) { System.out.println("dts:"+packet.getDts() + ",pts:"+packet.getPts()); final Decoder d = decoders[packet.getStreamIndex()]; if (packet.isComplete() && d != null) { dts = dts == -1 ? packet.getDts() : dts; packet.setDts(packet.getDts() - dts); packet.setPosition(-1); muxer.write(packet, false); } } muxer.close(); demuxer.close(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
The video source is about 190 seconds long, and I set the "starttime" as 180, want to cut the last 10 seconds and write to a new avi file.
The output avi file is 10 seconds long, but only the last 5s of the video is correct, the first 5s seems no data.
Is there any wrong in my code. Thanks.