Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109690 > unrolled thread

movie from pictures

Started bynevzat.guler@gmail.com
First post2016-06-08 15:11 -0700
Last post2016-06-11 19:26 +0200
Articles 7 — 7 participants

Back to article view | Back to comp.lang.python


Contents

  movie from pictures nevzat.guler@gmail.com - 2016-06-08 15:11 -0700
    Re: movie from pictures Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-08 17:32 -0700
      Re: movie from pictures Nev <nevzat.guler@gmail.com> - 2016-06-09 08:54 -0700
        Re: movie from pictures Peter Otten <__peter__@web.de> - 2016-06-09 20:58 +0200
        Re: movie from pictures MRAB <python@mrabarnett.plus.com> - 2016-06-09 20:25 +0100
        Re: movie from pictures alex wright <wrightalexw@gmail.com> - 2016-06-10 17:31 -0400
        Re: movie from pictures Karim <kliateni@gmail.com> - 2016-06-11 19:26 +0200

#109690 — movie from pictures

Fromnevzat.guler@gmail.com
Date2016-06-08 15:11 -0700
Subjectmovie from pictures
Message-ID<e2c6ea94-99da-45ee-a2a9-fd3613b1a318@googlegroups.com>
Dear Users, 
I am trying to combine several pictures to create a movie file. I create the pictures in a loop. I would like to add each picture to a movie within the loop, like it is done in MATLAB. However, it is also acceptable to create all the picture in the loop, afterwards use some ffmpeg command to combine them into a picture. I actually tried the latter option but i ran into trouble with paths because the picture location and python code are in different places. The former method is also better because I would like to use variable name for the picture names, instead of their given name, which are long and have spaces, special characters in them.. I will appreciate any guidance here.

[toc] | [next] | [standalone]


#109692

FromLawrence D’Oliveiro <lawrencedo99@gmail.com>
Date2016-06-08 17:32 -0700
Message-ID<7e57c662-a6c2-441d-a46e-49458439250f@googlegroups.com>
In reply to#109690
On Thursday, June 9, 2016 at 10:11:16 AM UTC+12, Nev wrote:

> ... afterwards use some ffmpeg command to combine them into a picture.

This is a very common use case for FFmpeg.
1) Generate your frames in some high-quality lossless format, like PNG.
2) Name them sequentially “0001.png”, “0002.png” etc. (Assuming 4 digits is enough here.)
3) Use an FFmpeg command like

    ffmpeg -i /input-dir/%04d.png «output settings» «output filename»

to generate the final movie.

By keeping the full-quality frames from step 2, you can retry step 3 with different encoding settings to see which works best. You can even try two-pass encoding for best quality.

[toc] | [prev] | [next] | [standalone]


#109754

FromNev <nevzat.guler@gmail.com>
Date2016-06-09 08:54 -0700
Message-ID<16301530-a24b-42c6-bcf6-007c4eb85aca@googlegroups.com>
In reply to#109692
Thank you for your reply. I tried something like this in python code:

from subprocess import call
call(["ffmpeg -framerate 4/1 -start_number 1 -i C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p C:\\Projects\\data2\\movie.mp4"])

But it did not work. I get FileNotFoundError: [WinError 2] The system cannot find the file specified..

On the other hand, in-loop solution would be more preferable since it lets me to use variable names of the images and paths.. 

[toc] | [prev] | [next] | [standalone]


#109760

FromPeter Otten <__peter__@web.de>
Date2016-06-09 20:58 +0200
Message-ID<mailman.122.1465498697.2306.python-list@python.org>
In reply to#109754
Nev wrote:

> Thank you for your reply. I tried something like this in python code:
> 
> from subprocess import call
> call(["ffmpeg -framerate 4/1 -start_number 1 -i
> C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p
> C:\\Projects\\data2\\movie.mp4"])
> 
> But it did not work. I get FileNotFoundError: [WinError 2] The system
> cannot find the file specified..

You have to pass the command-line arguments as separate items in the list:

call(["ffmpeg", 
      "-framerate", "4/1",
      "-start_number", "1",
      "-i", "C:\\Projects\\data2\\img_%05d.png",
      ... # and so on
      ])

> On the other hand, in-loop solution would be more preferable since it lets
> me to use variable names of the images and paths..

[toc] | [prev] | [next] | [standalone]


#109761

FromMRAB <python@mrabarnett.plus.com>
Date2016-06-09 20:25 +0100
Message-ID<mailman.123.1465500343.2306.python-list@python.org>
In reply to#109754
On 2016-06-09 19:58, Peter Otten wrote:
> Nev wrote:
>
>> Thank you for your reply. I tried something like this in python code:
>>
>> from subprocess import call
>> call(["ffmpeg -framerate 4/1 -start_number 1 -i
>> C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p
>> C:\\Projects\\data2\\movie.mp4"])
>>
>> But it did not work. I get FileNotFoundError: [WinError 2] The system
>> cannot find the file specified..
>
> You have to pass the command-line arguments as separate items in the list:
>
> call(["ffmpeg",
>       "-framerate", "4/1",
>       "-start_number", "1",
>       "-i", "C:\\Projects\\data2\\img_%05d.png",
>       ... # and so on
>       ])
>
You should also give it the full path of ffmpeg.

>> On the other hand, in-loop solution would be more preferable since it lets
>> me to use variable names of the images and paths..

[toc] | [prev] | [next] | [standalone]


#109800

Fromalex wright <wrightalexw@gmail.com>
Date2016-06-10 17:31 -0400
Message-ID<mailman.143.1465594319.2306.python-list@python.org>
In reply to#109754
I find shlex.split to be most useful to make my arguments a list in these
cases.
On Jun 9, 2016 3:28 PM, "MRAB" <python@mrabarnett.plus.com> wrote:

> On 2016-06-09 19:58, Peter Otten wrote:
>
>> Nev wrote:
>>
>> Thank you for your reply. I tried something like this in python code:
>>>
>>> from subprocess import call
>>> call(["ffmpeg -framerate 4/1 -start_number 1 -i
>>> C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p
>>> C:\\Projects\\data2\\movie.mp4"])
>>>
>>> But it did not work. I get FileNotFoundError: [WinError 2] The system
>>> cannot find the file specified..
>>>
>>
>> You have to pass the command-line arguments as separate items in the list:
>>
>> call(["ffmpeg",
>>       "-framerate", "4/1",
>>       "-start_number", "1",
>>       "-i", "C:\\Projects\\data2\\img_%05d.png",
>>       ... # and so on
>>       ])
>>
>> You should also give it the full path of ffmpeg.
>
> On the other hand, in-loop solution would be more preferable since it lets
>>> me to use variable names of the images and paths..
>>>
>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#109822

FromKarim <kliateni@gmail.com>
Date2016-06-11 19:26 +0200
Message-ID<mailman.1.1465666010.2288.python-list@python.org>
In reply to#109754

On 10/06/2016 23:31, alex wright wrote:
> I find shlex.split to be most useful to make my arguments a list in these
> cases.
> On Jun 9, 2016 3:28 PM, "MRAB" <python@mrabarnett.plus.com> wrote:
>
>> On 2016-06-09 19:58, Peter Otten wrote:
>>
>>> Nev wrote:
>>>
>>> Thank you for your reply. I tried something like this in python code:
>>>> from subprocess import call
>>>> call(["ffmpeg -framerate 4/1 -start_number 1 -i
>>>> C:\\Projects\\data2\\img_%05d.png -c:v libx264 -r 30 -pix_fmt yuv420p
>>>> C:\\Projects\\data2\\movie.mp4"])
>>>>
>>>> But it did not work. I get FileNotFoundError: [WinError 2] The system
>>>> cannot find the file specified..
>>>>
>>> You have to pass the command-line arguments as separate items in the list:
>>>
>>> call(["ffmpeg",
>>>        "-framerate", "4/1",
>>>        "-start_number", "1",
>>>        "-i", "C:\\Projects\\data2\\img_%05d.png",
>>>        ... # and so on
>>>        ])
>>>
>>> You should also give it the full path of ffmpeg.
>> On the other hand, in-loop solution would be more preferable since it lets
>>>> me to use variable names of the images and paths..
>>>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
Why not use the split() method on the string of the command line.

Karim

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web