VideoHelp Forum
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. Guys--I've been out of the technical game for a while (my last post was over 15 years ago and it reads like a different language!) so forgive me if my question is a little basic.

    I have a Motion JPEG .avi file that is 7min and 52sec (472 sec) long that I want to rotate as losslessly as possible. Windows 10 Explorer as well as VLC both tell me that the frame rate for this video is 30fps.

    So using ffmpeg, I found this line of code to extract the jpgs from the mjpg in my avi, so I that can rotate them manually:

    Code:
    ffmpeg -i mjpegvideo.avi -vcodec copy frame%d.jpg
    This produced 10,574 jpgs which translates to about 22.4 frames per second (10574 frames / 472 sec). There is a clock baked into the video as well--not sure if it's precise enough to use as timecode, but eyeballing it confirms that it is indeed 22-23 frames per second.

    I haven't gone any further yet, but I imagine that when I put the jpgs together, I'll have to specify a frame rate. But if I put 30 fps, then my video will be played too fast, no?

    Hoping you guys can explain what's going on to this ol' geezer newbie.
    -R
    Quote Quote  
  2. Originally Posted by wrawlind View Post

    Code:
    ffmpeg -i mjpegvideo.avi -vcodec copy frame%d.jpg
    If possible please add 'vsync 0' and perhaps 'mjpeg2jpeg' bitstream filter - it could be useful if you activate 'report' functionality and provide log if possible.

    Code:
    ffmpeg -report -i mjpegvideo.avi -c:v copy -bsf:v mjpeg2jpeg -vsync 0 frame%d.jpg
    Quote Quote  
  3. Maybe the video in your AVI is shorter than the audio? Ie, 472 seconds of audio but only ~352 seconds of video.

    If you can live with a mov file try a simple remux (no loss of quality) with rotation flag.

    Code:
    ffmpeg -i mjpeg.avi -c copy -metadata:s:v:0 rotate=90 mjpeg.mov
    If that's the wrong rotation direction try -90 or 270 instead. Note that not all players will obey the rotation flag.
    Quote Quote  
  4. Got tied up with work and wasn't able to work on your suggestions until now, but thanks for getting back to me so quickly, guys!

    Originally Posted by pandy View Post

    If possible please add 'vsync 0' and perhaps 'mjpeg2jpeg' bitstream filter - it could be useful if you activate 'report' functionality and provide log if possible.

    Code:
    ffmpeg -report -i mjpegvideo.avi -c:v copy -bsf:v mjpeg2jpeg -vsync 0 frame%d.jpg
    Done and attached. I can't really make heads or tails of the log, but you'll see that the video is 7min 52.23sec long @30fps but only 10,574 frames are produced.


    Originally Posted by jagabo View Post
    Maybe the video in your AVI is shorter than the audio? Ie, 472 seconds of audio but only ~352 seconds of video.
    Nope. Audio starts and stops with video.

    Originally Posted by jagabo View Post
    If you can live with a mov file try a simple remux (no loss of quality) with rotation flag.

    Code:
    ffmpeg -i mjpeg.avi -c copy -metadata:s:v:0 rotate=90 mjpeg.mov
    If that's the wrong rotation direction try -90 or 270 instead. Note that not all players will obey the rotation flag.
    Thanks for the tip! I'm not a huge fan of .mov files but this worked (tried replacing the '.mov' extension with '.avi' but that didn't work). Only thing is that part way through the original clip, the camera rotates to the correct orientation, so I thought by extracting the jpgs from the Motion JPEG that I could just rotate the frames that needed it. To really address this, I'd need a lossless way to split either the .avi or the .mov, and then concatenate it back again.

    In any case, thanks again. And standing by for whatever you guys can tell me about the attached log file.
    Image Attached Files
    Quote Quote  
  5. Mjpeg is an intra frame codec so you can split the video losslessly. Then rotate only the section that needs rotation. You might be able to avoid any reencoding by setting the mp4/mov rotation flag and have it retained when you join the sections back together again. Even if you do manage that not all players will play it properly though.

    Code:
    ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
    Last edited by jagabo; 4th May 2022 at 12:42.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!