« ブルーサムライとサムライブルーの違い | トップページ | 激ムズ。QWOPみたいなひたすら歩くゲーム「Daddy long legs」を攻略中。 »

2015年2月18日 (水)

Changing fps with ffmpeg

ffmpeg is nice but often we need to figure some hackish way around to do what you want...

I recorded a 30 min long video from webcame which is controlled by opencv (cv2 python binding). The video was created fine but the problem started when I wanted to change the fps of the video.

usually -r option is the way to go. This seems to work when input is either buffer through stdin or image sequence (001.png etc). But when the input is a video file (in my case avi container), r option alone does not seem to work as intended.

First try with vsync (playback is not fixed)

Here are the two tricks I had to do to change the fps.

(1) set vsync option to 3 (drop) to discard the timestamp information in the original file (2) set vframes option to specify the frame number to decode/encode.

With these, the muxer will create a fresh timestamp for the output video. The command looks like this:

ffmpeg -vframes 540000 -y -i input.avi -vsync 3 -r 30 out.avi

30 (min) x 60 (s) x 30 (fps) = 54000 so -vframes option is redundant but was needed for vsynch to work. -y option will just overwrite the output file if it already exists.

The webcame was capturing at 30 fps but the output video was set to 10 fps with -r option to slow it down for easy inspection of fast movements.

I still have a problem with this though. After converting this original video to 30 fps with the above command, I did get a 30 min length video but both VLC and the windows media player will still playback at 10 fps.

This can be actually handy for me, because I can seek the video with the correct time (the video length is not x3 longer than the actual time) but it still plays x3 slower which I wanted. But if I want to recover both the playback speed and timestamp then this is not enough.

Second try with video filter

Hence, the 2nd try here. I found a wiki "How to speed up slow down a video" in the official site, which recommend -filter option.

With -filter_complex, you can re-compute and update the timestamp information. Great! But my ffmpeg executable is old (from 2011) and did not like -filter_complex or -filter option, so I used -vf option (alias to -filter) which somehow worked ok.

ffmpeg -y -i -an input.avi -vf setpts=PTS/3.0 -r 30 out.avi

This sped up the original video x3. For sure, I will forget all these in 2 weeks, hence this blog article.

Could I just copy the video stream and only change the frame rate?

There is this -vcodec copy option to avoid decoding and re-encoding process. It would be nice if I can use this when changing just the frame rate.

To me, frame rate looks like just a metadata, no???? If so, why wouldn't we be able to just modify the metadata without compromising the video quality at all?

Sadly, the answer seems no. According to this post to the mailing list, [FFmpeg-user] Deinterlace and change framerate with -vcodec copy.

|   I would really like to do it
|   with -vcodec copy. Is is possible? If it is, which codecs
|   allow for framerate changes like this? Does h264 support it?

No. To change frame rate you have to decode, throw away 'baseband' 'I'
frames, and re-encode.

After all, the frame rate is part of video frame data that cannot be modified without decoding and re-encoding.

« ブルーサムライとサムライブルーの違い | トップページ | 激ムズ。QWOPみたいなひたすら歩くゲーム「Daddy long legs」を攻略中。 »

パソコン・インターネット」カテゴリの記事

英語」カテゴリの記事

コメント

https://www.wholesalejordanshoes.us.org/
https://www.airjordans1.us.com/
https://www.pandorasjewelrys.us.com/
https://www.outletstoreonlineshopping.com.co/
https://www.pandoraoutletscharms.us.com/
https://www.pandorasoutlet.us.com/
https://www.diorjordan1.us.com/
https://www.ferragamocom.us/
https://www.balenciagatriplessneakers.us.com/
https://www.nikecom.ca/
https://www.ferragamosbelt.us.com/
https://www.pandorass.us/
https://www.pandoraoutletscharms.us/
https://www.wholesalejordanshoes.us/
https://www.asicsgel-kayano.us.com/
https://www.trainersshop.uk.com/
https://www.pandorajewelrysofficialsite.us.com/
https://www.newshoes2021.us/
https://www.adidasshoescheap.us.com/
https://www.nikeoutlets.ca/
https://www.cheapshoesoutletonlines.us/
https://www.nikestorefactorys.us.com/
https://www.pandorascom.us.com/
https://www.nikesnkrs.ca/
https://www.shoesasicsoutlet.us.com/
https://www.nikecanada-shoes.ca/
https://www.wholesaleairjordanscheap.us/
https://www.pandorajewelry-officialsites.us/
https://www.pandorasrings.us.com/
https://www.airjordan1s.us.com/
https://www.monclersaleoutlets.us.com/
https://www.pandorashop.us.com/
https://www.nikeshoes-formen.us.com/
https://www.pandorabraceletscharms.us.com/
https://www.trainersforsale.uk.com/
https://www.airjordan1retro.us.com/
https://www.adidasnewshoes.us.com/
https://www.pandorasjewelryoff.us.com/
https://www.pandorajewelrysblackfriday.us.com/
https://www.pandorabraceletsclearance.us.com/
https://www.pandorasofficialsite.us.com/
https://www.adidasshoeswomen.us.com/
https://www.pandoraringsjewelry.us.com/
https://www.balenciagastore.us.com/
https://www.jordanretro1.us.com/
https://www.goyardbagsoutlet.us.com/
https://www.airjordan1low.us/
https://www.pandora-jewelryoutlets.us.com/
https://www.outletasics.us.com/
https://www.adidasofficialwebsite.us.com/
https://www.pandorasjewelryofficialsite.us.com/
https://www.asicsshoess.us.com/
https://www.nikesstore.us.com/
https://www.pandorajewelrysbracelets.us.com/
https://www.shoesferragamo.us.com/
https://www.charmspandoras.us/
https://www.yeezycanadashop.ca/
https://www.nikecanadaonlineshopping.ca/
https://www.adidasshoesfactory.us.com/
https://www.pandoracharmsstore.us.com/
https://www.cheapjordanshoeswholesale.us/
https://www.adidasshoesmen.us.com/
https://www.monclersjacketsoutlet.us.com/
https://www.asicsoutletshoes.us.com/
https://www.nikestoreoutlets.us.com/
https://www.balenciagashoess.us.com/
https://www.pandorasbraceletcharms.us.com/
https://www.jordan1shoes.us.com/
https://www.yeezysshoes.ca/
https://www.nikemensshoes.us.com/
https://www.pandorajewelrywebsites.us.com/
https://www.yeezycom.us/
https://www.nmd.us.com/
https://www.pandoracharms-bracelets.us.com/
https://www.nikecanadaonlines.ca/
https://www.jordan1high.us/
https://www.pandora-charmssaleclearance.us/
https://www.balenciagastores.us.com/
https://www.pandorabraceletsjewelry.us.com/
https://www.adidasstoreoutlets.us.com/
https://www.nikerunningshoessale.us.com/
https://www.pandorashops.us.com/
https://www.jordanones.us/
https://www.nikeoutletstoreonlineshopping.us.com/
https://www.monclersale.com.co/
https://www.airmax720.us.com/
https://www.asicssneakers.us.com/
https://www.monclercoat.com.co/
https://www.nikeshoes-forwomen.us.com/
https://www.ferragamosbelts.us.com/
https://www.pandoras-outlet.us.com/
https://www.pandorastores.us.com/
https://www.pandora-jewellery.us.com/
https://www.sneakersadidas.us.com/
https://www.monclercoatsjacketsoutlet.us.com/
https://www.pandorashops.us/
https://www.nikescanadaonlineshopping.ca/
https://www.pandoracharmss.us.com/
https://www.nikeairjordan1.us.com/
https://www.adidas-runningshoes.us.com/
https://www.goyardhandbagsoutlet.us.com/
https://www.balenciagashoesstore.us.com/
https://www.pandorajewelryoff.us.com/
https://www.pandoras-charms.us.com/
https://www.balenciagasneakerssales.us.com/
https://www.monclerjacket.com.co/
https://www.jordan1low.us.com/
https://www.pandoraoutlet-online.us.com/
https://www.nikesneakersformen.us.com/
https://www.pandoraofficialsites.us.com/
https://www.pandorasjewellery.us.com/
https://www.adidasshoes-canada.ca/
https://www.monclersfactory.us.com/
https://www.jordan1retro.us.com/
https://www.airjordan1shoes.us.com/
https://www.outletsmonclerjackets.us.com/
https://www.pumashoess.us.com/
https://www.asicsrunningshoess.us.com/
https://www.pandoraoutletjewelry.us.com/
https://www.pandora-outletcharms.us.com/
https://www.yeezys350.ca/
https://www.pandorasjewelrysite.us.com/
https://www.adidascanadaonline.ca/
https://www.adidassale.us.com/
https://www.pandoracharmsjewelrys.us/
https://www.pandorasjewelry-officialsite.us.com/
https://www.bestbasketballshoes.us/
https://www.cheapmoncler.com.co/
https://www.pandorasstore.us.com/
https://www.nike--shoes.ca/
https://www.nikeshoesnew.us.com/
https://www.nikeonline-canada.ca/
https://www.nikeshoess.ca/
https://www.adidass.ca/
https://www.jewelryspandora.us/
https://www.pandoraoutletsonline.us.com/
https://www.pandorajewelryshop.us.com/
https://www.salvatoreferragamos.us.com/
https://www.pandora-store.us.com/
https://www.nikeshoeswomen.us.com/
https://www.pandorasjewelrycharms.us.com/
https://www.pandorajewelrybracelets.us.com/
https://www.balenciagasneakersoutlet.us.com/
https://www.nikeoutletstore-onlineshopping.us.com/
https://www.pandoracharms-bracelets.us/
https://www.nikesneakersforwomen.us.com/

https://www.balenciagatriples.us.org/
https://www.nike-airmax2018.us.com/
https://www.huarachesnike.us.com/
https://www.jordan11red.us.com/
https://www.jordan-retro5.us/
https://www.pandorajewelryofficialsite.us.com/
https://www.jamesharden-shoes.us.org/
https://www.pandoracanadajewelry.ca/
https://www.pandorajewellery.us.com/
https://www.goldengoosesneakerss.us.com/
https://www.eccos.us.com/
https://www.sneakersgoldengoose.us.com/
https://www.newjordan11.us/
https://www.jordan-8.us/
https://www.nikeoutletshoes.us.com/
https://www.ferragamo-outlets.us/
https://www.kyrieirving-shoes.us.org/
https://www.jordan11sshoes.us/
https://www.jordan11winlike96.us/
https://www.pandorasjewelry.us.com/
https://www.jordanretro11mens.us/
https://www.air-jordans11.us.com/
https://www.moncleroutletstoreonline.us.com/
https://www.goldengoosessneakers.us.com/
https://www.pandoras.us.com/
https://www.air-max90.us.com/
https://www.jordansneakerss.us/
https://www.jordansretro3.us/
https://www.nikesales.us.com/
https://www.adidasyeezysshoes.us.com/
https://www.jordans-sneakers.us.com/
https://www.nikesnkrs.us.com/
https://www.nikeofficialwebsite.us.com/
https://www.jordans-4.us/
https://www.jameshardenshoes.com.co/
https://www.goldengoosemidstar.us.com/
https://www.ggdbshoes.us.com/
https://www.nikesoutletstoreonlineshopping.us.com/
https://www.louboutinsshoes.us.com/
https://www.airjordan6rings.us/
https://www.ferragamos.us.org/
https://www.outletgoldengoose.us.com/
https://www.nmds.us.com/
https://www.retro-jordans.us/
https://www.air-jordanssneakers.us/
https://www.jordan11ssneakers.us/
https://www.jacketsmoncleroutlet.us.com/
https://www.nike--shoes.us.com/
https://www.nikeshoesoutletfactory.us.com/
https://www.goldensgoose.us.com/
https://www.yeezys-shoes.us.com/
https://www.jordansretro12.us/
https://www.redbottomshoeslouboutin.us.com/
https://www.jordans5.us/
https://www.air-jordan12.us/
https://www.jordan-shoesformen.us.com/
https://www.fjallraven-kanken.us.com/
https://www.balenciagas.us.org/
https://www.air-jordansneakers.us/
https://www.newnikeshoes.us.com/
https://www.airjordanretro11.us.com/
https://www.valentinosshoes.us.org/
https://www.pandora-braceletcharms.us/
https://www.newjordansshoes.us.com/
https://www.jordan-12.us.com/
https://www.jordan14.us.com/
https://www.shoes-jordan.us.com/
https://www.jordanshoess.us.com/
http://www.pandorarings.us.com/
https://www.jordan12retros.us/
https://www.nikeairmax98.us/
https://www.birkin-bag.us.com/
https://www.airjordan11s.us.com/
https://www.pandoraringssite.us/
https://www.moncler-outletjackets.us.com/
https://www.jordanshoesretro.us.com/
https://www.ggdbsneakers.us.com/
https://www.goldengooseoutletfactory.us.com/
https://www.jordanretro-11.us.com/
https://www.airforceoneshoes.us.com/
https://www.pandorasjewelry.ca/
https://www.fitflopsclearance.us.com/
https://www.nikeair-maxs.us.com/
https://www.goldengooseshoess.us.com/
https://www.nikesfactory.us.com/
http://www.yeezys.com.co/
https://www.jordans11.us.com/
https://www.nikeshoes-cheap.us.com/
https://www.pandoraonline.us/
https://www.red-bottomsshoes.us.com/
https://www.yeezyonline.us.com/
https://www.retrosairjordan.us/
https://www.jordan1.us.com/
https://www.redbottomslouboutin.us.org/
https://www.jordan-4.us.com/
https://www.yeezy.us.org/
https://www.yeezys-shoes.us.org/
https://www.monclercom.us.com/
https://www.outletnikestore.us.com/
https://www.pandorascharms.us.com/
https://www.airmax270.us.org/
https://www.adidasnmdr1.us.org/
https://www.airjordan3s.us/
https://www.nikeairforce1.us.org/
https://www.jordan10.us.com/
https://www.airjordansneakers.us.com/
https://www.monclerstoreoutlet.us.com/
https://www.jordan-retro6.us/
https://www.air-jordan6.us/
https://www.monclerjacket.us.org/
https://www.jordans-11.us/
https://www.nikeairjordan.us.com/
https://www.ggdbs.us.com/
https://www.goldengoosesales.us.com/
https://www.shoeslouboutin.us.com/
https://www.soccercleats.us.com/
https://www.airjordan4s.us/
https://www.mensnikeshoes.us.com/
https://www.jordanretros.us.com/
https://www.jordanscheapshoes.us/
https://www.canadapandoracharms.ca/
https://www.monclerstores.us.com/
https://www.new-jordans.us.com/
https://www.monclerjacketsstore.us.com/
https://www.retrosjordans.us/
https://www.pandorajewelryofficial-site.us/
https://www.monclervest.us.com/
https://www.jordans4retro.us/
https://www.jordan13s.us/
https://www.nikeshoesforwomens.us.com/
https://www.airjordan5.us/
https://www.fitflop-shoes.us.org/
https://www.jordan9.us.com/
https://www.airmax-95.us.com/
https://www.jordan11low.us.com/
https://www.nikeoutletstoresonlineshopping.us.com/

コメントを書く

(ウェブ上には掲載しません)

トラックバック


この記事へのトラックバック一覧です: Changing fps with ffmpeg:

« ブルーサムライとサムライブルーの違い | トップページ | 激ムズ。QWOPみたいなひたすら歩くゲーム「Daddy long legs」を攻略中。 »

しろののツイッタータイムライン(凍結中)

オススメたち

2021年7月
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

はてブ

無料ブログはココログ