If the source is RGB, then you may choose the video codec libx264rgb rather than libx264. The video codec is specified by -codec:video, which is usually abbreviated as -c:v ( -codec:v or -c:video are also possible). And for image sequences starting at 086400 (captured at 24 fps with a timecode starting at 01:00:00:00) or at 090000 (captured at 25 fps with a timecode starting at 01:00:00:00), add the flag -start_number 86400 or -start_number 90000 before -i input_file_%06d.ext. The command must of course match the naming convention actually used.
#Ffmpeg mp4 h264 full
This allows to read in ascending order, one image after the other, the full sequence inside one folder. The regex %06d matches six digits long numbers, possibly with leading zeroes. The frame rate of sound film is 24 fps (frames per second) and the default frame rate of image2 is 25 fps, therefore we have to change it. Therefore the option -f image2 must precede the image sequence given as input. The parameters witch apply to the input files must precede them. output_file path, name and extension of the output file Discussion pix_fmt yuv420p The pixel format for “YUV” colour space with 4:2:0 chroma subsampling and planar colour alignment is chosen for best compatibility. crf constant_rate_factor A parameter of 18 means a “visually lossless” compression. preset preset_value A slower encoding preset means a better compression rate. pix_fmt yuv420p \ output_file Command syntax ffmpeg starts the command -f image2 forces the image file de-muxer for single image files -framerate frames_per_second sets the frame rate -i input_file_regex.ext path, name with regex and extension of the input files -c:v libx264 The library libx264 re-encodes the video stream using the H.264 video codec. pix_fmt yuv420p \ output_file General command ffmpeg \ Transcode an image sequence by using the H.264 codec for dissemination purposes. Where I used the ac3 audio codec at a bitrate of 640K and the expression "24/25" which is allowed here :NOTE: the 24/25 is the inverse of the itsscale value of 25/24(=1.Image sequence into H.264 / MPEG-4 AVC Problem If you have audio you would include an audio filter to rescale the audio without a pitch change by changing the tempo using the atempo settings, you should include a compressor and bit rate as well.įor subtitles, you just need to include the -codec:sįfmpeg -itsscale 1.0416667 -i "input file" -filter:a atempo="24/25" -codec:a ac3 -b:a 640k -vcodec copy -codec:s copy "output file" Going from 23.976 to 24 or going from 29.97 to 30 this value would be 0.999) This will scale the frame rate times from 25 to 24 fps, keeping the same number of frames, but lengthening the video by 1.0416667. The itsscale value of 1.0416667 is 25/24 as a float variable for ffmpeg (0.1234567 is the float values format - don't use 1.04166666666666666667 or a double value : note that you can't use the expression/formula "25/24" here) You can try for example (to convert from 25 fps to 24 fps)įfmpeg -itsscale 1.0416667 -i "your input file" -vcodec copy "output file" Be aware that your file size will increase by a rather large factor when you decompress into raw streams. #unsigned 8-bit and place the output #in an avi container to ease frame accurate editing.įfmpeg -i "$f" -c:v huffyuv -c:a pcm_u8 "$f".aviĬlearly this script expects all files in the current directory to be media files but can easily be changed to restrict processing to a specific extension of your choosing. #This script will decompress all files in the current directory, video to huffyuv and audio to PCM I use a script for this as reproduced below: #!/bin/bash If this doesn't fit your requirements I suggest that you try this answer although my experience has been that it still re-encodes the output file.įor the best frame accuracy you are still better off decoding to raw streams as previously suggested. You can accomplish the same thing at 6fps but as you noted the duration will not change (which in most cases is a good thing as otherwise you will lose audio sync). I used the command ffmpeg -i inputfile -r 25 outputfile which worked perfectly with a webm,matroska input and resulted in an h264, matroska output utilizing encoder: Lavc56.60.100 I had a 24fps file I wanted at 25fps to match some other material I was working with. To the best of my knowledge you can't do this with ffmpeg without re-encoding.