Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
know exactly the size of the converted video
19 septembre 2014, par moderadorkl25I'm trying to know the size more accurately converted video using ffmpeg, I'm getting the actual size of the original video and output video and dividing the size of 2, the logic when I get the size of another video will multiply the value to know the result.
the purpose of this is because I want to make a progress bar using php and ajax, so by my logic would be.
<? $total = $select_result;// total original file $video = 'test.mp4'; //loop ajax $getID3 = new getID3; $file = $getID3->analyze($video); $current = $file['filesize']; $a = $total / $current; $b = $a * 100; print number_format($b,0).'%'; ?>
ffmpeg command will always be this
exec("ffmpeg -i $video -ar 22050 -ab 32 -f mp4 -s 320x240 teste1.mp4")
but by my logic does not work, each video is a different value, it is possible to do this calculation?
-
Build FFmpeg with xCode 5
19 septembre 2014, par Andreas BachmaierDoes anyone know how to compile FFmpeg with xCode 5?
My configure part:
./configure --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --enable cross-compile --arch=arm --target-os=darwin --enable-neon --disable-avfilter \ --disable-bsfs \ --enable-avresample --enable-swresample --disable-iconv --enable-gpl \ --disable-demuxers --enable-demuxer=rtsp --enable-demuxer=rtp --enable-demuxer=mpegts \ --disable-decoders --enable-decoder=mp2 --enable-decoder=mp3 --enable-decoder=mpeg2video --enable-decoder=ac3 - enable-decoder=dvbsub --enable-decoder=h264 \ --disable-parsers --enable-parser=mpegvideo - enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=dvbsub\ --disable-muxers --disable-encoders --disable-filters \ --disable-protocols --enable-protocol=http --enable-protocol=rtp --enable-protocol=udp --enable-protocol=tcp \ --disable-swscale-alpha \ --disable-armv5te \ --disable-armv6 \ --disable-armv6t2 \ --cc=/Applications/Xcode.app/Contents/Developer/usr/bin --as='/usr/local/bin/gas preprocessor/gas-preprocessor.pl /Applications/Xcode.app/Contents/Developer/usr/bin' --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk --cpu=cortex-a8 --extra-cflags='-arch armv7 -mfpu=neon -mfloat-abi=softfp' --extra-ldflags='-arch armv7 -mfpu=neon -mfloat-abi=softfp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk' --enable-pic --disable-bzlib
It works with xCode 4 (different Compiler-Path)
Error-Message:
./configure: line 3763: nm: command not found
-
Adding a image resource over video file from sd card using ffmpeg or MediaMuxer for android
18 septembre 2014, par AlinI am stuck in this area which I am not comfortable at all to work in.
Here is what I did so far:
- Made an Ubuntu VirtualBox machine
- Downloaded latest ffmpeg version which is 2.3.3
- Compiled ffmpeg to be compatible with armv7-a so in the end I get two folders: include and lib. In include I have the headers and in libs the *.so files (just as in http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/)
I have created a new android project and made a jni folder and this is how far I went... Even this, with all the struggle being new to linux and compiling took me almost a week to reach.
Adding a watermark in ffmpeg I believe it is done on libavfilter ? I have to dig on this matter, however the original ffmpeg I need to translate into my project is:
ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi
As far as I am studying now I need to do inside jni:
- create a add_watermark.c file in which I need to somehow call the function that does the filter overlay call
create Android.mk to load this and the ffmpeg needed libraries
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := add-watermark
LOCAL_SRC_FILES := add-watermark.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.3.3/android/armv7-a)
create Application.mk
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
run ndk-build and use the generated libraries in my android project.
I really need help on continuing, so every answer is received with great attention and pleasure.
Later Edit: Would it be possible to somehow build ffmpeg.exe as a library and call its main with the exact same parameters as the original exe ? I do not want to run ffmpeg as a standalone executable, but have it integrated within the project. Something like http://www.roman10.net/how-to-port-ffmpeg-the-program-to-androidideas-and-thoughts/ What downsides would this approach have ?
Later edit 2: if this is possible by using MediaMuxer or other APIs added in android 4.3 I am open to it you sample codes are provided. I did look over the MediaCodec and MediaMuxer samples also Grafik and haven't found a proper way to do what I wanted. I prefer ffmpeg approach better if it works
-
Applying filter complex fails with something related to audio
18 septembre 2014, par AlinI finally managed to build ffmpeg as detailed in here: https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/ and in the end, I have a ffmpeg library which accepts command arguments.
I am trying to apply a watermark image over the video so for it I am using preparing this ffmpeg command:
ffmpeg -i input.avi -i logo.png -filter_complex 'overlay=10:main_h-overlay_h-10' output.avi
I have first tried it on windows using ffmpeg.exe and the result was as expected.
I have tried it on android using the compiled android and the output is as follows:
09-17 22:03:34.455: I/Videokit(18419): Loading native library compiled at 22:33:10 Sep 15 2014 09-17 22:03:34.455: I/Videokit(18419): Option: ffmpeg 09-17 22:03:34.455: I/Videokit(18419): Option: -loglevel 09-17 22:03:34.455: I/Videokit(18419): Option: debug 09-17 22:03:34.455: I/Videokit(18419): Option: -i 09-17 22:03:34.455: I/Videokit(18419): Option: /storage/emulated/0/vid.mp4 09-17 22:03:34.455: I/Videokit(18419): Option: -i 09-17 22:03:34.455: I/Videokit(18419): Option: /storage/emulated/0/logo.png 09-17 22:03:34.455: I/Videokit(18419): Option: -qscale:v 09-17 22:03:34.455: I/Videokit(18419): Option: 1 09-17 22:03:34.455: I/Videokit(18419): Option: -filter_complex 09-17 22:03:34.455: I/Videokit(18419): Option: overlay=10:main_h-overlay_h-10 09-17 22:03:34.455: I/Videokit(18419): Option: /storage/emulated/0/outVid.mp4 09-17 22:03:34.455: I/Videokit(18419): Running main 09-17 22:03:34.463: D/Videokit(18419): Splitting the commandline. 09-17 22:03:34.463: D/Videokit(18419): Reading option '-loglevel' ... 09-17 22:03:34.463: D/Videokit(18419): matched as option 'loglevel' (set logging level) with argument 'debug'. 09-17 22:03:34.463: D/Videokit(18419): Reading option '-i' ... 09-17 22:03:34.463: D/Videokit(18419): matched as input file with argument '/storage/emulated/0/vid.mp4'. 09-17 22:03:34.463: D/Videokit(18419): Reading option '-i' ... 09-17 22:03:34.463: D/Videokit(18419): matched as input file with argument '/storage/emulated/0/logo.png'. 09-17 22:03:34.463: D/Videokit(18419): Reading option '-qscale:v' ... 09-17 22:03:34.463: D/Videokit(18419): matched as option 'qscale' (use fixed quality scale (VBR)) with argument '1'. 09-17 22:03:34.463: D/Videokit(18419): Reading option '-filter_complex' ... 09-17 22:03:34.463: D/Videokit(18419): matched as option 'filter_complex' (create a complex filtergraph) with argument 'overlay=10:main_h-overlay_h-10'. 09-17 22:03:34.463: D/Videokit(18419): Reading option '/storage/emulated/0/outVid.mp4' ... 09-17 22:03:34.463: D/Videokit(18419): matched as output file. 09-17 22:03:34.463: D/Videokit(18419): Finished splitting the commandline. 09-17 22:03:34.463: D/Videokit(18419): Parsing a group of options: global . 09-17 22:03:34.463: D/Videokit(18419): Applying option loglevel (set logging level) with argument debug. 09-17 22:03:34.463: D/Videokit(18419): Applying option filter_complex (create a complex filtergraph) with argument overlay=10:main_h-overlay_h-10. 09-17 22:03:34.463: D/Videokit(18419): Successfully parsed a group of options. 09-17 22:03:34.463: D/Videokit(18419): Parsing a group of options: input file /storage/emulated/0/vid.mp4. 09-17 22:03:34.463: D/Videokit(18419): Successfully parsed a group of options. 09-17 22:03:34.463: D/Videokit(18419): Opening an input file: /storage/emulated/0/vid.mp4. 09-17 22:03:34.612: D/Videokit(18419): Successfully opened the file. 09-17 22:03:34.612: D/Videokit(18419): Parsing a group of options: input file /storage/emulated/0/logo.png. 09-17 22:03:34.612: D/Videokit(18419): Successfully parsed a group of options. 09-17 22:03:34.612: D/Videokit(18419): Opening an input file: /storage/emulated/0/logo.png. 09-17 22:03:34.620: D/Videokit(18419): Successfully opened the file. 09-17 22:03:34.620: D/Videokit(18419): Parsing a group of options: output file /storage/emulated/0/outVid.mp4. 09-17 22:03:34.620: D/Videokit(18419): Applying option qscale:v (use fixed quality scale (VBR)) with argument 1. 09-17 22:03:34.620: D/Videokit(18419): Successfully parsed a group of options. 09-17 22:03:34.620: D/Videokit(18419): Opening an output file: /storage/emulated/0/outVid.mp4. 09-17 22:03:34.627: D/Videokit(18419): Successfully opened the file. 09-17 22:03:34.643: I/Videokit(18419): Conversion failed! 09-17 22:03:34.643: I/Videokit(18419): Stream mapping: 09-17 22:03:34.643: E/Videokit(18419): Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
The problem is Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height and this is somehow related to audio of the file. I have removed the audio and I get no error.
ffmpeg -i vid.mp4
returns this:Command line: ffmpeg -i vid.mp4 -report ffmpeg version N-66278-g91459bd Copyright (c) 2000-2014 the FFmpeg developers built on Sep 14 2014 22:05:07 with gcc 4.8.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.101 / 56. 4.101 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Splitting the commandline. Reading option '-i' ... matched as input file with argument 'vid.mp4'. Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'. Finished splitting the commandline. Parsing a group of options: global . Applying option report (generate a report) with argument 1. Successfully parsed a group of options. Parsing a group of options: input file vid.mp4. Successfully parsed a group of options. Opening an input file: vid.mp4. [mov,mp4,m4a,3gp,3g2,mj2 @ 040e38c0] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 [mov,mp4,m4a,3gp,3g2,mj2 @ 040e38c0] ISO: File Type Major Brand: isom [mov,mp4,m4a,3gp,3g2,mj2 @ 040e38c0] Before avformat_find_stream_info() pos: 19279 bytes read:32768 seeks:0 [mov,mp4,m4a,3gp,3g2,mj2 @ 040e38c0] All info found [mov,mp4,m4a,3gp,3g2,mj2 @ 040e38c0] After avformat_find_stream_info() pos: 41952 bytes read:65536 seeks:0 frames:2 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'vid.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf55.19.104 Duration: 00:00:14.58, start: 0.023222, bitrate: 1250 kb/s Stream #0:0(und), 1, 1/11988: Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x640 [SAR 1:1 DAR 1:1], 1099 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(und), 1, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 97 kb/s (default) Metadata: handler_name : SoundHandler Stream #0:2(eng), 0, 1/90000: Data: none (rtp / 0x20707472), 39 kb/s Metadata: handler_name : HintHandler Stream #0:3(eng), 0, 1/44100: Data: none (rtp / 0x20707472), 8 kb/s Metadata: handler_name : HintHandler Successfully opened the file. At least one output file must be specified [AVIOContext @ 040e3f40] Statistics: 65536 bytes read, 0 seeks
-
getting mulitple images from a single stream piped from ffmpeg stdout
18 septembre 2014, par PJ7I start a process to retrieve a few frames from a video file with ffmpeg,
ffmpeg -i "
.mp4" -frames:v 10 -f image2pipe pipe:1 and pipe the images to stdout -
var cmd = Process.Start(p); var stream = cmd.StandardOutput.BaseStream; var img = Image.FromStream(stream);
Getting the first image this way works, but how do I get all of them?