Re-encode with ffmpeg - c

I am trying to do following work in C code with the help of ffmpeg library
Decode a mp2 audio file.
Write decoded data to a file named test.sw
Read data from test.sw and re-encode it to mp2 audio file.
For 1 and 2, i followed example given in decoding_encoding.c which is working fine. While reading and re-encoding, i can't understand how to read from test.sw file and encode it. Can anybody help me with that? It will help me a lot if anybody can provide me any tutorial regarding this topic.

As I understood your question you want to encode to mp2 format.I suggest to use the encoding technique used for mp2 format and use the library ,You have one library ffmpeg just check is it having for encoding .If yes then just use that function and pass your decoded file.
You can check it
http://ffmpeg.org/doxygen/trunk/encoding-example_8c-source.html

Related

Playing a Frequency in OpenAL in C

I am trying to write a program to play a frequency for a time. I can't find any way of simply just playing a certain frequency. How do I go about doing this in OpenAL?
I eventually found a video on properly reading form a WAV file (huge credit to this video) and how a WAV file is formatted (explained here in detail) and did some trial-and-error work until I figured out how to do it. I figured that if I could make a WAV-style file with the frequencies in them and set up the OpenAL buffer and source manually, it would work.
I ran into some trouble when I found that the format differed from the first explanation of WAV file format I found, as some apparently have additional meta-data, which I had to test for and skip over when trying to load a WAV file. Then I made a WAV file containing the frequencies and played it, which worked as well as I could have hoped for.
Here's another article about how bit-depth works that really helped me understand what I was doing.
Hopefully this helps anyone else who is trying to do something similar to this!

FFmpeg decoding .mp4 video file

I'm working on a project that needs to open .mp4 file format, read it's frames 1 by 1, decode them and encode them with better type of lossless compression and save them into a file.
Please correct me if i'm wrong with order of doing things, because i'm not 100% sure how this particular thing should be done. From my understanding it should go like this:
1. Open input .mp4 file
2. Find stream info -> find video stream index
3. Copy codec pointer of found video stream index into AVCodecContext type pointer
4. Find decoder -> allocate codec context -> open codec
5. Read frame by frame -> decode the frame -> encode the frame -> save it into a file
So far i encountered couple of problems. For example, if i want to save a frame using av_interleaved_write_frame() function, i can't open input .mp4 file using avformat_open_input() since it's gonna populate filename part of the AVFormatContext structure with input file name and therefore i can't "write" into that file. I've tried different solution using av_guess_format() but when i dump format using dump_format() i get nothing so i can't find stream information about which codec is it using.
So if anyone have any suggestions, i would really appreciate them. Thank you in advance.
See the "detailed description" in the muxing docs. You:
set ctx->oformat using av_guess_format
set ctx->pb using avio_open2
call avformat_new_stream for each stream in the output file. If you're re-encoding, this is by adding each stream of the input file into the output file.
call avformat_write_header
call av_interleaved_write_frame in a loop
call av_write_trailer
close the file (avio_close) and clear up all allocated memory
You can convert a video to a sequence of losses images with:
ffmpeg -i video.mp4 image-%05d.png
and then from a series of images back to a video with:
ffmpeg -i image-%05d.png video.mp4
The functionality is also available via wrappers.
You can see a similar question at: Extracting frames from MP4/FLV?

Getting all possible video file data using mediainfo in linux ( using C )

I need to extract all meta data along with play-length information from the video files in pure C .
I goggled and found MediaInfo Library but was not able to find any relevant c sample code .
Is there any other way to achieve this with / without MetaInfo ?
Or can somebody point me to a good sample code of MediaInfo in C
ffprobe which is part of ffmpeg can do a whole lot more.
ffprobe without switches will give some common information
It also has lot of switches of which you can use one at a time [exclusively]
-show_format show format/container info
-show_streams show streams info
-show_packets show packets info
-show_frames show frames info
-show_data show packets data
Try it out.

Reading colour value from png file in C

I have to load colours value from *.png file in c. Something like imread in matlab. I learned png file construction, tried to open file as binary and write to matrix, but I probably done something wrong. I alao tried to search, but I couldn't find suitable library.
Any advice how can I do that or which library should I use?
You're going to need to decompress the zlib compression on the PNG first (if there is any) before you can get to the raw color values. The easiest way to do this is through the free libpng. You will find many examples here and elsewhere on how to do just that.

What file format contents starts with "URES"?

I have a number of files that contain data in a format I am not familiar with. All of the data files begin with the same byte sequence, presumably a file header, and the sequence is "URES". I'm assuming that these files are some kind of resource file, perhaps a collection of data or other files all embedded into one file; that's just a guess however.
Does anyone know what format this is/might be?
If so, how would I interrogate the file? Are there applications that let me open these kind of files? Do you know of any libraries or APIs that I can use to gain programmatic access the data?
Have you tried running the unix file command on it?
I know of one file format that starts with URES. It's a data file used for Watchtower Library. I have yet to understand the format myself.
maybe its something from the Universal Resource Editor (URE) that comes with the OS/2 Toolkit? just a guess...
it is from the watchtower library files and they use meps to encode it which is thier own librarys and encryption software so to crack it would take you a long time.

Resources