Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6645 closed defect (invalid)

Feature Request: Virtual Extension Parameter

Reported by: Thomas Johnson Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

This is more like feature request rather than an issue, but you may consider it an issue if you want.

A huge amount of users recently asked me similar questions, and because there is no official solution, I'm filing this issue here, and I hope it will be fixed (implemented) soon.

I'm writting an UI application which asks user to provide input file path and input format (separatelly) and output file path and output format (separatelly). So, for example, user may enter:

Input Path: "./1.exe"
Input Format: "mkv"
Output Path: "./1.bmp"
Output Format: "jpg"

And then my application should generate command line parameters for ffmpeg such that ffmpeg reads file "1.exe" like it is in "mkv" format, then converts it to "jpg" format and then save it to "1.bmp", but in "jpg" format. I though that it will not require a lot of work, but then i realized that it is not easy at all.

The main problem is because ffmpeg detects input/output format primarily by file extension. However, if the extension differs from the format, the things get very complicated. The main reason for it is because there is no official list (pattern) that describes which command line parameters need to be used in order to encode in specific extension (while the real extension may be different).

For most file formats, I've noticed that "-c:v ext -image2" will encode it in extension "ext" (assuming it is supported extension) no matter what real output file extenion is. However, there a lot of exceptions. For example, "jpg" requires "-c:v singlejpeg" instead of "-c:v jpg".

I also noticed that for video formats one should pass "-f ext" in order to encode it to specific extension "ext". However, there are also a lot of exceptions. For example, "mkv" file format requires "-f matroska" instead of "-f mkv".

This is the feature request I'm filing: please create and publish official list which will provide command line parameters for each extension. It may be a table with two collumns: first collumn containing extensions and the second column containing command line parameters required in order to ffmpeg encode file in that specific extension (no matter what real extension is).

Or, even better, implement a specific parameter (you may call it "virtual extension") which will allow users to override real extension (for input or output file) which will be used internally by ffmpeg while muxing/demuxing, and then save it to real file path.

Change History (3)

in reply to:  description comment:1 by Hendrik, 7 years ago

Replying to thomas_johnson:

The main problem is because ffmpeg detects input/output format primarily by file extension.

This is not the case. ffmpeg first and foremost detects the input format by its contents, the extension is only rarely used and only as a fallback.

comment:2 by Carl Eugen Hoyos, 7 years ago

Priority: importantnormal
Resolution: invalid
Status: newclosed
Type: enhancementdefect

Sorry but this has very little similarity with a valid ticket: Not only does FFmpeg for nearly no format use the file extension to detect input format (targa images and raw G.722 files are exceptions), an option to force an output (and an input) format for any extension already exists. It is even possible to force specific image formats if you prefer that over the image2 demuxer.
Please ask all usage questions on the user mailing list.

comment:3 by Thomas Johnson, 7 years ago

@cehoyos

I really have no idea why is this closed as invalid and I have no idea what are you saying (probably you misunderstood the issue). You are right about input formats (ffmpeg detects it by content, not by extension), but there is no simple way to override output extension. Input format is determined by file content, but output format cannot be determined by file content, instead it is determined by extension. So, definitelly, output format is primarily determined by output file extension.

But, the problem is because there is no simple way to determine which parameters one need to pass in order to override real extension to specific extension. As I said, there are a lot of exceptions (matroska for mkv, then singlejpeg for jpg, etc) which are not obvious and there is no official list which allows users to find the pattern.

You've also said "It is even possible to force specific image formats if you prefer that over the image2 demuxer." - I asked the question on stack overflow about how to override real output extension for *any* format. Experts responded and answered that what I'm trying to achieve is very hard because there is no official way to achieve it and that ffmpeg has no functionality for it. Some formats are easy to override (png, bmp, mp4, etc.) but others have specific pattern and not obvious.

On Stack Oveflow they suggested that I should create a feature request here because ffmpeg currently has no official list which connects demuxers with extension pattern. If I want to encode to specific extension (while real extension is different), there is no simple way to achieve it. I agree that for raw images I need to provide pixel format and similar details, but anyway, raw images doesn't even have official extension. But, Im talking about ordinary file formats.

I don't know if you will see this response, but in case you don't, I'll probably file a new request with better explanations. Ffmpeg experts from stack overflow know what they are talking about. I'm not ffmpeg expert and I just did what they suggested. Basically, there is no easy way to override any output extension, because ffmpeg detects output format primarily by its extenion. Not input format, but output format.

Note: See TracTickets for help on using tickets.