Convert JPEG file to MPEG still frame format - mpeg

Anyone know how to convert a JPEG image to MPEG still frame format? I'd love to do it in java but a linux command line process would be ok. (I saw something on code project that does this for c sharp).

I haven't done it myself but here is an overview of converting JPEG's into MPEG's. I would take a look at using FFMPEG.
Overview Link: http://electron.mit.edu/~gsteele/ffmpeg/
FFMPEG: http://ffmpeg.mplayerhq.hu/

Related

Libavformat- Passing an object of images to libavformat to generate a video

I am trying to generate a video with libavformat/Libavcodec with a bunch of images that are in memory.
Can someone point me in the right direction, please?
Thanks in advance.
First, the basics of creating a video from images with FFmpeg is explained here.
If you simply want to change/force the format and codec of your video, here is a good start.
For the raw FFmpeg documentation you could use the Video and Audio Format Conversion, the Codec Documentation, the Format Documentation the and the image2 demuxer documentation (this demuxer will manage images as an input).
If you just want to take images and make a simple video out of it, just look at the 2 first links. FFmpeg's documentation gives you powerful tools but don't use them if you don't need them.
A sample command to create a video from images is:
ffmpeg -i image-%03d.png video.mp4
This will take all the files in sequence from image-000.png to the highest number available and make a video out of it.
You can force the format with the extension of the output file. To force the video codec use -c:v followed by a codec name available in the codec documentation.

Decode JPEG image stripped from inside a PDFs file

I have code that decompresses jpgs into bit maps which works fine for JPEG files, however when I feed the code a JPEG I have stripped directly from a PDFs XObject I get errors.
Adobe reader displays the image fine so I don't believe it's corrupted. I have read through JPEG and PDFs documentation and don't find any obvious problems.
My question is this, is there anything different in the "JPEG" embedded inside a PDFs stream and a normal JPEG? And if so what is it?
Note: I can manually open the PDFs, copy the image, paste into paint, and save...when I do this everything works....my problem is I need this automated.
When my code parses the PDFs, strips out the image stream, dumps the binary to a file, and then I try and open this file, it does not work. What am I missing?
My errors seem to be occurring in the Huffman decoding process, the cdt and Huffman tables appear to be read in fine.
Pardon my using the answer section but I overflowed the comment section:
My questions:
1. What code is failing to decode the JPEG? You say you "have code" but where did that come from? Why do you think that it is reliable?
What is the file format of the JPEG stream? JFIF, ADOBE, EXIF, none specified?
Could there be something in the file format that your decoder cannot handle? Does your encoder check for different types of APPn markers?
What is the JPEG format? What type of SOS marker?
Does this encoder source handle all the normally formats? Baseline, Extended, Sequential, progressive? If you have progressive JPEG and and encoder that only does baseline, you are going to have a problem.
How many components does the JPEG stream have?
Some Adobe files have 4 components and decoders may only be able to handle 1 or 3.

matlab - VideoReader frames aren't decoded accurately

I am working with video in Matlab, and having trouble.
I'm using Matlab R2012a on a Mac OS X 10.8.2 (Mountain Lion).
I can load a video in using VideoReader and grab a frame like so:
vid = VideoReader('movie.mp4');
pic = read(vid, 20);
imshow(pic);
However, what I see in Matlab is..
Instead of this (in VLC)..
Not only is movement being garbled (the turquoise truck) but the green truck in the background is actually gone by that frame. I'm guessing the codec is compressing the movie in such a way that Matlab isn't compensating for. However, I can't find any other video format that Matlab will accept.
The video shown is mpeg4, yuv420p. I see Matlab mentions a lot about mpeg2 being supported and AVI being the preference. I've converted the video to all sorts of formats using ffmpeg but Matlab has given the following error for every other file format:
Error using VideoReader/init (line 447)
Failed to initialize internal resources.
Error in VideoReader (line 132)
obj.init(fileName);
Any thoughts?
Got it.
Thanks to #wakjah for the tip about QuickTime. A video editor friend suggested MPEG StreamClip to convert to the QuickTime format.
This tool took my mp4 file and let me Export as QuickTime.
Sure enough, Matlab loaded it up the mov file no problem and the artifacts are gone.
Cheers.

Where is the documentation for the Mjpeg codec used in mencoder, VLC and FFMpeg?

Mencoder has a lovely option for converting a mjpeg file into an avi file with an 'MJPG' codec that plays in VLC.
The command line to do this is:
mencoder filename.mjpeg -oac copy -ovc copy -o outputfile.avi -speed 0.3
where 0.3 is the ratio of the desired play framerate to the default 25 fps. All this does is make a copy of the mjpeg file, put an avi header on top and at the end, what seems to be an index of the frame positions in the file.
I want to replicate this in my own code, but I can't find documentation anywhere. What is the exact format of the index section? The header has extra filler bytes in it for some reason - whats this about?
Anyone know where I can find documentation? Both mencoder and vlc seem to have this codec built in.
After much work, study and fiddling around with HxD and RiffPad, I finally figured it out. It would take a long blog entry to explain it all, but basically there isn't really an 'MJPG' codec out there - mjpg just uses a few tricks and unusual parts of the avi standard to produce an indexed file.
The key is to place '00dc' and an Int32 length tag 8 bytes in front of each Jpeg open tag. If you want the avi to be random access, then you need an index at the end which points to each of the '00dc' tag positions.
VLC will play this natively. If you have ffmpeg installed, then Windows Media Player uses that to decode these types of mjpg files.

another sound as with subtitles

is it possible to get other sounds to a divx as it is with getting subtitles?
what is that format of that?
Yes, you can have multiple audio streams in your video file. Here's some more information (I'm guessing you're using AVI as your container format).

Resources