Ffmpeg video converter: Difference between revisions

From Edgar BV Wiki
Jump to navigation Jump to search
Line 219: Line 219:
6) Open a command window where the image sequence is, and enter the command:
6) Open a command window where the image sequence is, and enter the command:
<pre>
<pre>
ffmpeg -framerate 1/9 -r 30 -i “img (%d).png” -q:v 1 -b:v 1500k timelapse.mp4
ffmpeg -framerate 1/2 -i "img (%d).jpg" -r 30 -c:v libx264 -pix_fmt yuv420p -crf 23 timelapse.mp4
</pre>
</pre>
(depreciated: ffmpeg -framerate 1/9 -r 30 -i "img (%d).png" -q:v 1 -b:v 1500k timelapse.mp4)


framerate 1/9 = 9 seconds per frame
framerate 1/9 = 9 seconds per frame
Line 229: Line 231:


From http://ludumdare.com/compo/2013/05/01/higher-quality-video-workaround-for-chronolapse/
From http://ludumdare.com/compo/2013/05/01/higher-quality-video-workaround-for-chronolapse/
== input and output framerates ==
https://video.stackexchange.com/questions/13066/how-to-encode-a-video-at-30-fps-from-images-taken-at-7-fps
There are two frame rates to consider: the input and the output.
By default the input frame rate is 25, and the output will use the same frame rate as the input unless you tell it otherwise.
=== Same frame rate for input and output ===
If you want to input and output to have the same frame rate, then just provide the input frame rate. This example will set a frame rate of 30000/1001 (NTSC video):
    ffmpeg -framerate 30000/1001 -i input output.mp4
Alternatively, in this example, you could use ntsc instead of 30000/1001, but don't use 29.97 because that is not accurate or correct. See other frame rate aliases.
Because the default input frame rate is 25, and if you only set an output frame rate, then frames will be dropped or duplicated to compensate. That is why the input frame rate is set in this situation.
=== Different frame rate for input and output ===
Sometimes you may want the input frame rate and output frame rate to differ. For example, you may want to input the frames at a certain rate, and then duplicate or drop frames so the output has a different frame rate. You may want to do this due to compatibility issues with your output format container, your player, and/or your device:
    ffmpeg -framerate 10 -i input -r 25 output.mp4
In this example frames will be duplicated to go from 10 to 25. The console output will tell you if frames are being dropped or duplicated.
The image file demuxer uses -framerate, while the output frame rate is set using -r.
You may have to add the -pix_fmt yuv420p option in some circumstances if you're outputting H.264 video (the ffmpeg console output will warn you if you do need to). This will use a chroma subsampling scheme that is compatible with all players.


== compileren op Lenny ==
== compileren op Lenny ==

Revision as of 08:28, 16 March 2018

To find out the video bitrate of a movie, do ffmpeg -i inputfile

Then you can use -b bitrate option to set the output bitrate in order to not lose quality. The -qscale 3 option also ensures a highter quality (nb if possible use -qscale 2 though)

Command lines

ffmpeg -y -i cb_d3_6.mpg -vcodec h264 -me_method full -b 700k -rc_max_rate 768 -an test.mp4

ffmpeg -y -i hoogenboom/reclame_golf.avi -vcodec libx264 -me_method full -b 700k -an test.mp4

ffmpeg -y -i hoogenboom/reclame_golf.avi -vcodec libx264 -me_method full -qscale 2 -s 1280x576 -aspect 20:9 -an reclame_golf.mp4

ffmpeg -y -i hoogenboom/reclame_onderhoud.avi -vcodec libx264 -me_method full -qscale 2 -s 1280x576 -aspect 20:9 -an reclame_onderhoud.mp4

ffmpeg -y -i hoogenboom/reclame_onderhoud.avi -vcodec msmpeg4 -vtag MP43 -qscale 2 -s 1280x576 -aspect 20:9 -an reclame_onderhoud.wmv

Output naar flash / flv

ffmpeg -i input.mp4 -b:v 583000 -ar 44100 -qscale 2 output.flv

(-b:v = video bitrate, -ar = audio bitrate, has to be one of a few possible values - you get these values from ffmpeg -i inputfile )

http://forum.doom9.org/archive/index.php/t-131369.html

Omzetten naar .TP

TP bestanden zijn MPEG2 bestanden geschikt voor streaming.

ffmpeg -i inputfile -vcodec copy -acodec copy output.ts

rename .ts -> .tp

Je kan checken of het goed is gegaan door in Media Player Classic in de properties (shift-F10) bij mediainfo tabblad te kijken of de format MPEG-TS is

of

TP bestanden zijn MPEG2 bestanden geschikt voor streaming. Om deze bestanden te maken moeten video's geconverteerd worden naar .TS bestanden (zelfde formaat, maar TP bestanden kennen veel converteer programma's niet). Deze .TS bestanden moeten hernoemt worden naar <filename>.TP. Andere bestanden worden NIET afgespeeld. Converteren kan met o.a. met Super en FFmpeg.

ffmpeg -i input_file.m4v -vcodec copy -acodec copy output_file.ts

NB kan ook ffmpeg -i input_file.mpeg2 -vcodec copy -acodec copy -f mpegts output.ts

OF

ffmpeg -y -threads 2 -i "input.avi" -ab 128k -b 2500k -r 25 -maxrate 8000k -bufsize 1000k -vcodec mpeg2video -s 4cif -acodec mp2 -map 0:0 -map 0:1 "output.ts"


Je kan checken of het goed is gegaan door in Media Player Classic in de properties (shift-F10) bij mediainfo tabblad te kijken of de format MPEG-TS is.


(zie ook http://www.shortword.net/blog/2009/12/18/converting-h-264-mpeg4-to-ts-with-ffmpeg/ en http://www.linuxquestions.org/questions/linux-newbie-8/how-do-you-convert-avi-or-anything-to-ts-727858/ voor meer info)

Meerdere video's

Bij omzetten van meerdere video's is het zetten van een batch variabele handig:

set params= -an -vcodec rawvideo -y  -s 1920x1080
ffmpeg.exe -i "G:\Cheil\20110804 Gateway video\aangeleverd\Hub_SmartTV_nl.mp4" %params% "G:\Cheil\20110804 Gateway 

Veelgebruikte regels

it turns out that ffmpeg refers to keyframes as GOP or group of pictures. You can set the keyframe encoding rate simply by using the command line switch -g. So in order to convert an uncompressed .mov file into a flv of the same quality with a keyframe at every frame, I used the following command:

  ffmpeg -i UncompressedMov.mov -sameq -g 1 OutputFile.flv 

-force_key_frames time[,time...]


Samsung WMV 2 ( voor schone XP installaties zonder codecs:)

set params= -vcodec wmv2 -qscale 2 -an -y 


Omzetten naar raw video 1080p voor gebruik in editor (levert grote bestanden op!)

-vcodec rawvideo -y -s 1920x1080


High quality h264 mp4 bestanden

ffmpeg.exe -i "input.avi" -vcodec libx264 -b 6000k -g 200 -y "output.mp4"

mp4 bestanden hebben vaak het probleem dat de moov atom (index met gegevens van het bestand) aan de achterkant van het bestand worden geplaatst. Met grote mp4 bestanden duurt het lang, want eerst moet het gehele bestand ingeladen worden voordat het bestand wordt afgespeeld. Om dit op te lossen moet qt-faststart gebruikt worden. meer hier. Deze kan in windows en linux gebruikt worden. Qt-faststart stopt de moov atom aan het begin van het bestand, zodat het direct afgespeeld kan worden.

Galaxy Tab 10.1

Settings that worked best for flv:

Resolution: 1024 x 600

ffmpeg -i inputfile -s 1024x600 -sameq -ar 44100 -g 1 -deinterlace output.flv

What should work but doesn't:

Encoder: H.264 / flv Resolution: 1280 x 720 Frame Rate: 30 FPS Video Bitrate: 2500 kbps

ffmpeg -i inputfile -s 1280x720 -q:v 2 -b:v 2500000 -ar 44100 output.flv

ffmpeg -i inputfile -s 1280x720 -q:v 2 -b:v 2500000 -codec libx264 output.mp4

also see Media:Encondigperf.pdf

Roteren

The MAN page for ffmpeg states the following use ffmpeg -i inputfile.mpg -vf "transpose=1" outputfile.mpg


The key being that you are not to use a degree variable, but a predefined setting variable from the MAN page.


0=90CounterCLockwise and Vertical Flip (default)

1=90Clockwise

2=90CounterClockwise

3=90Clockwise and Vertical Flip


Scalen

ffmpeg -i yoursourcefile -s 640x480 youroutputfile


Croppen

ffmpeg -i inputfile -vf crop=1280:752 -qscale 2 outputfile

Waar crop=1280:752 het gewenste outputformaat is en qscale de qualiteit behoudt. Zo werkt het croppen van het midden.

Knippen / Cut

ffmpeg -sameq -ss [start_seconds] -t [duration_seconds] -i [input_file] [outputfile]

Foutmeldingen

ffmpeg encoding 6 channel(s) is not allowed in mp2:

Try to put -ac 2 after -i inputfile, to set 2 audio channels on the output file or -an to cut out the audio

Fucked wmv bestanden moesten eerst naar mpeg toe re-encoded worden:

ffmpeg -vsync 0 -i input.wmv -vcodec mpeg2video -b:v 5000000 -acodec copy output.mpeg

dan van de mpeg naar flv geconverteerd.

ffmpeg -i input.mpeg -sameq output.flv

VAN FLA (CS5) timeline naar .MOV naar .AVI

* Ga in menubalk naar bestand / file
* Ga naar exporteren.
* Ga naar film exporteren
* In dialoogvenster kies "Save as Type:" Quick Time (*.mov)
* Klik save
* Klik "QuickTime-instellingen"

* Zorg dat video is aangevinkt
* Klik op settings
* Kies "compression type:" "Animation"
* Kies framerate: xx fps(aantal frames per seconden van je flash)
* Every xx frames
* evt. Compressor Depth: Millions of colors+
* evt. Quality best
* Klik op 'OK' 
* Klik op size
* Dimensions: 'Custom' breedte x hoogte (afmetingen van je fla)
* Klik 'OK
* Evt uitvinken "Prepare for internet Sharing)
* Klik 'OK' 

De film word nu gerenderd. FF wachten dus..

In je command Prompt kan je de .mov met FFMPEG  omzetten met de command: 

ffmpeg -i filmpje.mov -sameq -g 1 filmpje.avi

nieuwe versie :

ffmpeg -i filmpje.mov -qscale 0 -g 1 filmpje.avi

Mocht de playback choppy zijn:

Framerate heeeel laag zetten (bijv. 5 fps) en exporteren als mov (zie boven, met 5 fps). In Adobe premiere de mov importeren en selecteren en bij clip - speed/duration (ctrl R) de snelheid op 600% zetten (als je 30fps wilt hebben) en voila, hij is soepel. Deze exporteren als avi / mpeg2 (want met avi heb je soms kleurverlies) en dat mpegje gebruiken in het volgende project.

create stop motion from pictures

1) Use Chronolapse to create a sequence of images in a folder somewhere.

2) Download ffmpeg and extract it.

3) Find the encoder executable ffmpeg.exe in the bin folder.

4) Rename all the images in your time-lapse sequence to a format that ffmpeg can recognize:


Open the folder with your image sequence in Windows Explorer. Make sure there are no other files in the folder.

Single-click on the first file in the sequence to select it. Note: This step is very important and affects sort order.

Select all files with Ctrl + A.

Press F2 and type img, and then press Enter. The files will be renamed sequentially.


5) Place a copy of ffmpeg.exe in the same folder as your image sequence, or ensure that the executable is in the Windows path.

6) Open a command window where the image sequence is, and enter the command:

ffmpeg -framerate 1/2 -i "img (%d).jpg" -r 30 -c:v libx264 -pix_fmt yuv420p -crf 23 timelapse.mp4

(depreciated: ffmpeg -framerate 1/9 -r 30 -i "img (%d).png" -q:v 1 -b:v 1500k timelapse.mp4)

framerate 1/9 = 9 seconds per frame

7) After processing for some time, you should have a new video file of much higher quality than what Chronolapse produces. Unless you have the correct codecs installed, this will not play. If you’re having any problems, try the VLC Media Player.

8) Profit!

From http://ludumdare.com/compo/2013/05/01/higher-quality-video-workaround-for-chronolapse/

input and output framerates

https://video.stackexchange.com/questions/13066/how-to-encode-a-video-at-30-fps-from-images-taken-at-7-fps


There are two frame rates to consider: the input and the output.

By default the input frame rate is 25, and the output will use the same frame rate as the input unless you tell it otherwise.

Same frame rate for input and output

If you want to input and output to have the same frame rate, then just provide the input frame rate. This example will set a frame rate of 30000/1001 (NTSC video):

   ffmpeg -framerate 30000/1001 -i input output.mp4

Alternatively, in this example, you could use ntsc instead of 30000/1001, but don't use 29.97 because that is not accurate or correct. See other frame rate aliases. Because the default input frame rate is 25, and if you only set an output frame rate, then frames will be dropped or duplicated to compensate. That is why the input frame rate is set in this situation.

Different frame rate for input and output

Sometimes you may want the input frame rate and output frame rate to differ. For example, you may want to input the frames at a certain rate, and then duplicate or drop frames so the output has a different frame rate. You may want to do this due to compatibility issues with your output format container, your player, and/or your device:

   ffmpeg -framerate 10 -i input -r 25 output.mp4

In this example frames will be duplicated to go from 10 to 25. The console output will tell you if frames are being dropped or duplicated.

The image file demuxer uses -framerate, while the output frame rate is set using -r.

You may have to add the -pix_fmt yuv420p option in some circumstances if you're outputting H.264 video (the ffmpeg console output will warn you if you do need to). This will use a chroma subsampling scheme that is compatible with all players.

compileren op Lenny

Eerst faac, lame, x264, yasm en pkg-config (nb. versie 0.25!) downloaden en installeren. De configure die werkt voor ffmpeg zelf:

./configure --enable-version3 --enable-libmp3lame --enable-libx264 --enable-postproc --enable-libfaac --enable-pthreads --enable-gpl --enable-nonfree --enable-shared

waar ik mee zit te kutten ivm lenny package compile options:

./configure --enable-gpl --enable-x11grab --prefix=/usr --enable-libtheora --enable-libgsm --enable-libvorbis --enable-version3 --enable-libmp3lame --enable-libx264 --enable-postproc --enable-libfaac --enable-nonfree --enable-pthreads --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-altivec --disable-vis --enable-shared --disable-static