Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
Extracting MP3 Data from Generic Movie Files using FFMPEG
21 février 2017, par MoonKnightI am using FFMPEG via MediaToolkit to extract MP3 data (to .mp3 file) from different movie files (merely .mp4 and .mov for now).
MediaToolkit is just a C# wrapper for FFMPEG which calls FFMPEG via
Process.Start
, so to do this I am using the methodpublic static string GenerateMp3FromVideoFile(string filePath) { string mp3Path = String.Empty; using (var engine = new Engine()) { mp3Path = Path.GetFileNameWithoutExtension(filePath); mp3Path = Path.Combine(Utils.GetBuildRoamingAppDataDirectory(), mp3Path); mp3Path = Path.ChangeExtension(mp3Path, ".mp3"); string paramString = String.Format( //"-i \"{0}\" -q:a 0 -map a \"{1}\"", //"-i \"{0}\" -ar 320K \"{1}\"", //"-i \"{0}\" -acodec libmp3lame -ar 44100 -b:a 192k -id3v2_version 3 -write_id3v1 1 \"{1}\"", //"-i \"{0}\" -vn -ar 44100 -ac 2 -ab 192k -f mp3 \"{1}\"", "-i \"{0}\" -acodec libmp3lame \"{1}\"", filePath, mp3Path); engine.CustomCommand(paramString); } return mp3Path; }
All of the options I have tried above for the command line arguments passed to FFMPEG have worked for .mp4 video files and create the desired .mp3 output. However, for the .mov file I have I am getting the following
System.Exception
69: video:0kB audio:1059kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.030074%Conversion failed!
I have tried a number of different methods to perform this extraction with varing control via the arguments passed to FFMPEG, but with no luck for the .mov file.
Looking at https://linuxconfig.org/ffmpeg-audio-format-conversions it seems as though there is not conversion to MP3 from .mov files, so I have looked at first converting the .mov to .mp4 via
ffmpeg -i mymovie.mov -vcodec copy -acodec copy out.mp4
and then extracting the audio, but this is expensive for large files. Is there a way of extracting the MP3 data directly from the .mov file?
Thanks for your time.
When the above command is run from FFMPEG.exe, the output is:
[aac @ 00000000021b00a0] Inconsistent channel configuration. [aac @ 00000000021b00a0] get_buffer() failed Error while decoding stream #0:1: Invalid argument [aac @ 00000000021b00a0] Reserved bit set. [aac @ 00000000021b00a0] Number of bands (6) exceeds limit (5). Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Number of bands (16) exceeds limit (13). Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] channel element 3.7 is not allocated Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] channel element 3.8 is not allocated Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Reserved bit set. [aac @ 00000000021b00a0] TNS filter order 28 is greater than maximum 12. Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Number of bands (26) exceeds limit (18). Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Sample rate index in program config element does not match the sample rate index configured by the container. [aac @ 00000000021b00a0] Too large remapped id is not implemented. Update your FFmpeg version to the newest one from Git . If the problem still occurs, it means that your file has a feature which has not been implemented. [aac @ 00000000021b00a0] If you want to help, upload a sample of this file to ftp://upload.ffmpeg.org/incoming/ and cont act the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org) Error while decoding stream #0:1: Not yet implemented in FFmpeg, patches welcome [aac @ 00000000021b00a0] Reserved bit set. [aac @ 00000000021b00a0] Prediction is not allowed in AAC-LC. Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Reserved bit set. [aac @ 00000000021b00a0] ms_present = 3 is reserved. Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Number of bands (3) exceeds limit (2). Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] SBR was found before the first channel element. [aac @ 00000000021b00a0] channel element 3.14 is not allocated Error while decoding stream #0:1: Invalid data found when processing input [aac @ 00000000021b00a0] Sample rate index in program config element does not match the sample rate index configured by the container.
-
mid-roll ads in HLS or mpeg-dash
21 février 2017, par evanI'm encoding my videos with ffmpeg and transcoding them into HLS videos. I want to add mid-roll ads to my converted videos.
I was wondering what is the best way to do it? should I just add the ads to my video and make a big video stream and then do the HLS thing? or I should break the HLs video and put the ads in the middle while playing?
My content is live streaming and I want to add mid-roll ads in the middle of my video while playing.
ffmpeg -i main720.MTS -movflags faststart -s 640*360 -r 24 -vcodec libx264 -preset slow -tune zerolatency -tune fastdecode -b:v 300k -maxrate 300k -bufsize 400k -g 96 -an hls3/main720_300.mp4 -s 1280*720 -r 24 -vcodec libx264 -preset slow -tune zerolatency -tune fastdecode -b:v 700k -maxrate 700k -bufsize 1000k -g 96 -an hls3/main720_700.mp4 -hls_time 4 -hls_segment_filename 'hls3/file%03d.ts' -hls_list_size 0 hls3/out.m3u8
-
ffmpeg - set variable video duration
21 février 2017, par VeeI use this command to convert files in batch plus crop and re-scale:
for i in $( ls *.mp4 ); do ffmpeg -y -i "$i" -acodec libfaac -ab 128k -ar 44100 -vcodec libx264 -b 850k -threads 0 -vf [in]crop=in_w-112:in_h-63:56:0,scale=1280:720[out] "../../archive/${i/.mp4/}.mp4" done
this command will start at second 15, and makes video 30 seconds long:
for i in $( ls *.mp4 ); do ffmpeg -ss 00:00:15 -t 30 -y -i "$i" -acodec libfaac -ab 128k -ar 44100 -vcodec libx264 -b 850k -threads 0 -vf [in]crop=in_w-112:in_h-63:56:0,scale=1280:720[out] "${i/.mp4/}_test.mp4" done
what I would like is a command that cuts off 15s from the beginning and 15s from the end of EACH video from the BATCH ... the trick is that each video has different duration, so "how long it is" must be a variable (duration minus 15s or minus 30s if I count 15s from the start as well)
video duration examples:
video 1 - 00:25:19 video 2 - 00:15:34 video 3 - 00:19:21 video 4 - 00:22:49 etc.
-
FFMPEG replace video audio with filter_complex
21 février 2017, par Chintan7027I wants such a output video where audio of output is created using ffmpeg -filter_complex mechanism,
/usr/local/Cellar/ffmpeg/3.2.2/bin/ffmpeg -i /uploads/videos/1487684390-lg9htt0RW2.mov -i /uploads/audios/1487664761-SCPbo6Tkac.mp3 -filter_complex " [0:a]atrim=0:8.70824980736,asetpts=PTS-STARTPTS[aud1]; [1:a]atrim=0:12.9567301273,asetpts=PTS-STARTPTS[aud2]; [0:a]volume=0.3,atrim=start=8.70824980736:21.6649799347,asetpts=PTS-STARTPTS[slow_aud]; [aud2][slow_aud] amerge=inputs=2[a_merged]; [0:a]atrim=start=21.6649799347:31.6410098076 [remaining_audio]; [aud1][a_merged][remaining_audio]concat=n=3:v=0:a=1[aout]" -map 0:v -map "[aout]" -c:v copy -acodec mp3 /uploads/output/1487684390-lg9htt0RW2.mov
Original Audio Recorded Based On UTC timestamp Vs Original Video Recorded Based on UTC timestamp
13:00-------- Original Event Audio -------- 13:20 12:50------------- Event Video Recorded --------------13:30
This is my requirement
So the audio of the output video should contains
- First 10 seconds(12:50 - 13:00) are Audio of Event Video Recorded
- Next 20 seconds (13:00 -13:20) are merged audio(Original Audio+ Original Video where Original video's audio volume is .3)
- Remaining 10 seconds(13:21-13:30) of video will play remaing audio of video
What I am getting by above commands
- First 10 seconds(12:50 - 13:00) are Audio of Event Video Recorded Achieved
- Next 20 seconds (13:00 -13:20) are merged audio(Original Audio+ Original Video where Original video's audio volume is .3) Achieved
- Remaining 10 seconds(13:21-13:30) of video will play remaining audio of video Not Achieved
-
ffmpeg webm encode for low powered devices
21 février 2017, par Max TkachenkoI want to play transparent video into my app using built-in player over phone's camera capture. I try to encode my video with alpha channel for android device:
ffmpeg -i "Comp.avi" -c:v libvpx -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" output.webm
The result is pretty good, but I have lags (freezing video from time to time) while playing it on my android phone. Is it any options to improve decode performance?
Some console output:
D:\SOFT\ffmpeg-20160207-git-9ee4c89-win64-static\bin>ffmpeg -i "d:\temp\cherti\Comp 1.avi" -c:v libvpx -pix_fmt yuva420p -metadata:s:v:0 alpha_mode="1" d:\temp\cherti\output.webm ffmpeg version N-80386-g5f5a97d Copyright (c) 2000-2016 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-nvenc --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-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib libavutil 55. 24.100 / 55. 24.100 libavcodec 57. 46.100 / 57. 46.100 libavformat 57. 38.100 / 57. 38.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 46.101 / 6. 46.101 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 1.100 / 2. 1.100 libpostproc 54. 0.100 / 54. 0.100 Input #0, avi, from 'd:\temp\cherti\Comp 1.avi': Metadata: date : 2017-02-18T14:10:42.00916 encoder : Adobe After Effects CC 2015 (Windows) Duration: 00:00:05.00, start: 0.000000, bitrate: 1592542 kb/s Stream #0:0: Video: rawvideo, bgra, 1080x1920, 1605907 kb/s, 24 fps, 24 tbr, 24 tbn, 24 tbc File 'd:\temp\cherti\output.webm' already exists. Overwrite ? [y/N] y [libvpx @ 0000000002593640] v1.5.0 [webm @ 00000000025a54e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead. Output #0, webm, to 'd:\temp\cherti\output.webm': Metadata: date : 2017-02-18T14:10:42.00916 encoder : Lavf57.38.100 Stream #0:0: Video: vp8 (libvpx), yuva420p, 1080x1920, q=-1--1, 200 kb/s, 24 fps, 1k tbn, 24 tbc Metadata: alpha_mode : 1 encoder : Lavc57.46.100 libvpx Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> vp8 (libvpx))