Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
FFMPEG - showfreqs and showwaves over background image ?
11 décembre 2015, par JeremyI'm wanting to get FFMPEG to export my podcast audio to a file I can upload to youtube that is visually interesting.
currently I am using the following piece of code, which I don't fully grasp:
ffmpeg -i E04_ProphetsPrey.wav -filter_complex \ " [0:a]showfreqs=mode=line:ascale=log:fscale=rlog:s=1280x518,pad=1280:720[vs]; \ [0:a]showfreqs=mode=line:ascale=log:fscale=rlog:s=1x1[ss]; \ [0:a]showwaves=s=1280x202:mode=p2p[sw]; \ [vs][ss]overlay=w[bg]; \ [bg][sw]overlay=0:H-h,drawtext=fontfile=/usr/share/fonts/TTF/Vera.ttf:fontcolor=white:x=10:y=10:text='\"Rated80s Prophets Prey\" by Comics On Film'[out]" \ -map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy -threads 0 output.mkv
what I would like to do is set a (branded) background image, and have showfreqs render over it on the top half and showwaves render over it on the bottom half.
Is that possible, and if so could you provide me a detailed example?
(I'm on arch linux)
-
How to get video frame for a specific time from mp4
11 décembre 2015, par man-ri have an mp4 video byte array and i need to generate a thumbnail for it using its middle frame (e.g. if the video length is 10 seconds then i need to get the picture from 5th second).
i managed to parse through the file and extract its boxes (atom). i have also managed to get the video length from the mvhd box. also i managed to extract 1. the time-To-Sample table from stts box, 2. the sample-To-Chunk table from stcs box, 3. the chunk-Offset table from stco box, 4. the sample Size table from stsz box, 5. the Sync Sample table from stss box
i know that all the actual media are available in the mdat box and that i need to correlate the above table to find the exact frame offset in the file but my question is how? the tables data seems to be compressed (specially the time-To-Sample table) but i don't know how decompress them.
any help is appreciated.
below are code samples
code to convert byte to hex
public static char[] bytesToHex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for ( int j = 0; j < bytes.length; j++ ) { int v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; } return hexChars; }
code for getting the box offset
final static String MOOV = "6D6F6F76"; final static String MOOV_MVHD = "6D766864"; final static String MOOV_TRAK = "7472616B"; final static String MOOV_TRAK_MDIA = "6D646961"; final static String MOOV_TRAK_MDIA_MINF = "6D696E66"; final static String MOOV_TRAK_MDIA_MINF_STBL = "7374626C"; final static String MOOV_TRAK_MDIA_MINF_STBL_STSD = "73747364"; final static String MOOV_TRAK_MDIA_MINF_STBL_STTS = "73747473"; final static String MOOV_TRAK_MDIA_MINF_STBL_STSS = "73747373"; final static String MOOV_TRAK_MDIA_MINF_STBL_STSC = "73747363"; final static String MOOV_TRAK_MDIA_MINF_STBL_STCO = "7374636F"; final static String MOOV_TRAK_MDIA_MINF_STBL_STSZ = "7374737A"; static int getBox(char[] s, int offset, String type) { int typeOffset = -1; for (int i = offset*2; i-1) { break; } } i+=(size*2); } return typeOffset; }
code for getting the duration and timescale
static int[] getDuration(char[] s) { int mvhdOffset = getBox(s, 0, MOOV_MVHD); int timeScaleStart = (mvhdOffset*2) + (4 + 4 + 1 + 3 + 4 + 4)*2; int timeScaleEnd = (mvhdOffset*2) + (4 + 4 + 1 + 3 + 4 + 4 + 4)*2; int durationStart = (mvhdOffset*2) + (4 + 4 + 1 + 3 + 4 + 4 + 4)*2; int durationEnd = (mvhdOffset*2) + (4 + 4 + 1 + 3 + 4 + 4 + 4 + 4)*2; String timeScaleHex = new String(Arrays.copyOfRange(s, timeScaleStart, timeScaleEnd)); String durationHex = new String(Arrays.copyOfRange(s, durationStart, durationEnd)); int timeScale = Integer.parseInt(timeScaleHex, 16); int duration = Integer.parseInt(durationHex, 16); int[] result = {duration, timeScale}; return result; }
code to get the time-To-Sample table
static int[][] getTimeToSampleTable(char[] s, int trakOffset) { int offset = getBox(s, trakOffset, MOOV_TRAK_MDIA_MINF_STBL_STTS); int sizeStart = offset*2; int sizeEnd = offset*2 + (4)*2; int typeStart = offset*2 + (4)*2; int typeEnd = offset*2 + (4 + 4)*2; int noOfEntriesStart = offset*2 + (4 + 4 + 1 + 3)*2; int noOfEntriesEnd = offset*2 + (4 + 4 + 1 + 3 + 4)*2; String sizeHex = new String(Arrays.copyOfRange(s, sizeStart, sizeEnd)); String typeHex = new String(Arrays.copyOfRange(s, typeStart, typeEnd)); String noOfEntriesHex = new String(Arrays.copyOfRange(s, noOfEntriesStart, noOfEntriesEnd)); int size = Integer.parseInt(sizeHex, 16); int noOfEntries = Integer.parseInt(noOfEntriesHex, 16); int[][] timeToSampleTable = new int[noOfEntries][2]; for (int i = 0; icode>
-
FFmpeg ubuntu auto transcoding script [on hold]
11 décembre 2015, par SambirHi guys i want to create an ffmpeg script which picks up files from one folder transcodes them then deletes the source.
So think of the following scenario:
I place file A.mp4 and A.srt in folder input I also place file B.mp4 and B.srt in folder input
In the night a script is executed which picks up these files places them in the folder "transcoding" then starts to transcode the movies one by one. So not parallel.
When finished new files should be created in the output folder by the ffmpeg script. And the files in the folder "transcoding" should be deleted.
Can anyone help me out here. It does not seem to be that complex but since I am not that good at coding any help is appreciated :)
-
Why does console output "illegal aspect ratio" when program reads a flv file?
11 décembre 2015, par xiaolanI use program to read a flv file. After it executed the avformat_find_stream_info() function, the console outputs some error information. Here is detailed error information.I want to know reasons. In fact, the file with flv format is made by myself. The producing process is: I encode a H.264 packet, then write it into a flv file, including the process of avformat_write_header(flv_ofmt_ctx, NULL),av_interleaved_write_frame(flv_ofmt_ctx, &p->pkt),av_write_trailer(flv_ofmt_ctx)……
-
Allow internet access for ffmpeg in android
11 décembre 2015, par Can GokdereI have compiled a ffmpeg binary for android, now I am trying record hls stream with it. For this, I am using Runtime.exec() commands. This is the command I am passing to binary:
./ffmpeg -i VIDEO_URL -c copy -bsf:A aac_adtstoasc OUTPUT.mp4
However, when I run this command I see "Cannot resolve host" error for any given url. My app has internet and access network state permissions, But I think that since ffmpeg binary is another process, android does not grant it with same permissions as my app.
So my question is that, how can I give the binary Internet permission without root access.
If this is not possible, can you guide me what other ways I can do to download a hls stream?
Thanks