changing frame rate in mjpeg file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

changing frame rate in mjpeg file

Alex-277
I have a mjpeg file that is recorded at 59.94 fps. I want to change the
frame rate by 1/2, i.e. 29.97 fps.  However I do NOT wish to retain the
original length of the movie.  I want to keep all the frames, meaning
the movie should end up being twice the length.

I have been able to do this by exporting the individual frames and then
re-creating the movie from the jpg frames. However, during re-encoding,
it appears that, even with the -sameq parameter, ffmpeg is recompressing
the jpg frames. Or at least it appears that way, because when I compare
the first frame from the original and the new movies, the new movie's
first frame has more artifacts than the original.

So I suppose my questions are:

1. Is this the best approach to change the frame rate of a mjpeg file
(keeping in mind that I DO want to change the length).

2. How can I tell ffmpeg to just copy the jpeg frames into a mjpeg movie
without recompressing them?

Here are the commands I'm using:

# extract

ffmpeg -i original.avi -vcodec copy -o frames/out.%08d.jpg
FFmpeg version SVN-r11218, Copyright (c) 2000-2007 Fabrice Bellard, et al.
   configuration: --enable-gpl --enable-pp --enable-libvorbis
--enable-liba52 --enable-libgsm --enable-libmp3lame --enable-pthreads
   libavutil version: 49.6.0
   libavcodec version: 51.49.0
   libavformat version: 52.2.0
   built on Dec 15 2007 09:20:44, gcc: 4.1.3 20070929 (prerelease)
(Ubuntu 4.1.2-16ubuntu2)
Input #0, avi, from 'original.avi':
   Duration: 00:00:46.6, start: 0.000000, bitrate: 7578 kb/s
     Stream #0.0: Video: mjpeg, yuvj422p, 320x240 [PAR 0:1 DAR 0:1],
59.94 tb(r)
     Stream #0.1: Audio: pcm_u8, 11024 Hz, mono, 88 kb/s
Output #0, image2, to 'frames/out.%08d.jpg':
     Stream #0.0: Video: mjpeg, yuvj422p, 320x240 [PAR 0:1 DAR 0:1],
q=2-31, 59.94 tb(c)
Stream mapping:
   Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 2798 fps=1897 q=0.0 Lsize=      -0kB time=46.7 bitrate=
-0.0kbits/s
video:42614kB audio:0kB global headers:0kB muxing overhead -100.000050%

# reconstruct

ffmpeg -i frames/out.%08d.jpg -vcodec mjpeg -sameq -an new.avi
FFmpeg version SVN-r11218, Copyright (c) 2000-2007 Fabrice Bellard, et al.
   configuration: --enable-gpl --enable-pp --enable-libvorbis
--enable-liba52 --enable-libgsm --enable-libmp3lame --enable-pthreads
   libavutil version: 49.6.0
   libavcodec version: 51.49.0
   libavformat version: 52.2.0
   built on Dec 15 2007 09:20:44, gcc: 4.1.3 20070929 (prerelease)
(Ubuntu 4.1.2-16ubuntu2)
Input #0, image2, from 'frames/out.%08d.jpg':
   Duration: 00:01:51.9, start: 0.000000, bitrate: N/A
     Stream #0.0: Video: mjpeg, yuvj422p, 320x240 [PAR 0:1 DAR 0:1],
25.00 tb(r)
File 'new.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'new.avi':
     Stream #0.0: Video: mjpeg, yuvj422p, 320x240 [PAR 0:1 DAR 0:1],
q=2-31, 200 kb/s, 25.00 tb(c)
Stream mapping:
   Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 2798 fps=264 q=3.0 Lsize=   32789kB time=111.9
bitrate=2400.0kbits/s
video:32716kB audio:0kB global headers:0kB muxing overhead 0.221550%

Don't know if this is necessary, but here are the commands I used to
extract the first frame from each movie for comparison:

ffmpeg -i original.avi -vframes 1 -vcodec png -an \
     -f rawvideo  frame1_orig.png

ffmpeg -i new.avi  -vframes 1 -vcodec png -an \
     -f rawvideo  frame1_new.png


Any help would be appreciated.

Cheers,

Alex
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: changing frame rate in mjpeg file

Benoit Fouet
Hi,

Alex wrote:

> I have a mjpeg file that is recorded at 59.94 fps. I want to change the
> frame rate by 1/2, i.e. 29.97 fps.  However I do NOT wish to retain the
> original length of the movie.  I want to keep all the frames, meaning
> the movie should end up being twice the length.
>
> I have been able to do this by exporting the individual frames and then
> re-creating the movie from the jpg frames. However, during re-encoding,
> it appears that, even with the -sameq parameter, ffmpeg is recompressing
> the jpg frames. Or at least it appears that way, because when I compare
> the first frame from the original and the new movies, the new movie's
> first frame has more artifacts than the original.
>
> So I suppose my questions are:
>
> 1. Is this the best approach to change the frame rate of a mjpeg file
> (keeping in mind that I DO want to change the length).
>
> 2. How can I tell ffmpeg to just copy the jpeg frames into a mjpeg movie
> without recompressing them?
>
>  

use -vcodec copy

> [snip]
>
>  

--
Ben
Purple Labs S.A.
www.purplelabs.com
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: changing frame rate in mjpeg file

Alex-277
Benoit Fouet wrote:

>> 2. How can I tell ffmpeg to just copy the jpeg frames into a mjpeg movie
>> without recompressing them?

 >
 > use -vcodec copy
 >

Sigh. I've been trying so many combinations of command line arguments
that I thought I had already tried that option on the frames -> video
step.  It worked as expected.

Thanks,

Alex


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-user