Skip to content

Commit b8612d1

Browse files
committed
add ffmpeg tool for audio / video conversion
1 parent aaa9d49 commit b8612d1

10 files changed

+96
-0
lines changed

tools/ffmpeg/ffmpeg_converter.xml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<tool id="ffmpeg_converter" name="FFmpeg Format Converter" version="0.1.0" profile="21.09">
2+
<description>Convert between video and audio formats using FFmpeg</description>
3+
<requirements>
4+
<requirement type="package" version="7.1.1">ffmpeg</requirement>
5+
</requirements>
6+
<command detect_errors="exit_code">
7+
<![CDATA[
8+
ffmpeg -i '$input_file' output.${output_format} &&
9+
mv output.${output_format} '$output_file'
10+
]]>
11+
</command>
12+
<inputs>
13+
<param name="input_file" type="data" format="mp4,mov,avi,mkv,mp3,wav,flac,ogg" label="Input media file"/>
14+
<param name="output_format" type="select" label="Output format">
15+
<option value="mp4">MP4 (video)</option>
16+
<option value="mkv">MKV (video)</option>
17+
<option value="avi">AVI (video)</option>
18+
<option value="mov">MOV (video)</option>
19+
<option value="mp3">MP3 (audio)</option>
20+
<option value="wav">WAV (audio)</option>
21+
<option value="flac">FLAC (audio)</option>
22+
<option value="ogg">OGG (audio)</option>
23+
</param>
24+
</inputs>
25+
<outputs>
26+
<data name="output_file" format="ogg" from_work_dir="output.@output_format@" label="Converted file (${output_format})">
27+
<change_format>
28+
<when input="output_format" value="mp4" format="mp4"/>
29+
<when input="output_format" value="mkv" format="mkv"/>
30+
<when input="output_format" value="avi" format="avi"/>
31+
<when input="output_format" value="mov" format="mov"/>
32+
<when input="output_format" value="mp3" format="mp3"/>
33+
<when input="output_format" value="wav" format="wav"/>
34+
<when input="output_format" value="flac" format="flac"/>
35+
</change_format>
36+
</data>
37+
</outputs>
38+
<tests>
39+
<test expect_num_outputs="1">
40+
<param name="input_file" value="SampleVideo_360x240_cut.mp4" ftype="mp4"/>
41+
<param name="output_format" value="webm"/>
42+
<output name="output_file" file="SampleVideo_360x240_cut.webm" ftype="webm"/>
43+
</test>
44+
<test expect_num_outputs="1">
45+
<param name="input_file" value="SampleVideo_360x240_cut.mp4" ftype="mp4"/>
46+
<param name="output_format" value="flac"/>
47+
<output name="output_file" file="SampleVideo_360x240_cut.flac" ftype="flac"/>
48+
</test>
49+
<test expect_num_outputs="1">
50+
<param name="input_file" value="SampleVideo_360x240_cut.mp4" ftype="mp4"/>
51+
<param name="output_format" value="mp3"/>
52+
<output name="output_file" file="SampleVideo_360x240_cut.mp3" ftype="mp3"/>
53+
</test>
54+
<test expect_num_outputs="1">
55+
<param name="input_file" value="SampleVideo_360x240_cut.flac" ftype="flac"/>
56+
<param name="output_format" value="ogg"/>
57+
<output name="output_file" file="flac_to_ogg.ogg" ftype="ogg"/>
58+
</test>
59+
<test expect_num_outputs="1">
60+
<param name="input_file" value="SampleVideo_360x240_cut.mp4" ftype="mp4"/>
61+
<param name="output_format" value="mkv"/>
62+
<output name="output_file" file="SampleVideo_360x240_cut.webm" ftype="mkv"/>
63+
</test>
64+
</tests>
65+
<help>
66+
This tool uses FFmpeg to convert between common video and audio file formats.
67+
68+
Input formats:
69+
- Video: MP4, MOV, AVI, MKV
70+
- Audio: MP3, WAV, FLAC, AAC, OGG
71+
72+
Select the output format you want, and FFmpeg will handle the conversion.
73+
</help>
74+
<citations>
75+
<citation type="bibtex">
76+
@article{tomar2006converting,
77+
title={Converting video formats with FFmpeg},
78+
author={Tomar, Suramya},
79+
journal={Linux Journal},
80+
volume={2006},
81+
number={146},
82+
pages={10},
83+
year={2006},
84+
publisher={Belltown Media}
85+
}
86+
</citation>
87+
</citations>
88+
</tool>

tools/ffmpeg/test-data/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SampleVideo_360x240_1mb.mp4
616 KB
Binary file not shown.
105 KB
Binary file not shown.
32.2 KB
Binary file not shown.
375 KB
Binary file not shown.
98.1 KB
Binary file not shown.
215 KB
Binary file not shown.
65.8 KB
Binary file not shown.

tools/ffmpeg/test-data/readme.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ffmpeg -ss 00:00:02 -to 00:00:04 -i SampleVideo_360x240_1mb.mp4 -c copy SampleVideo_360x240_cut.mp4
2+
3+
ffmpeg -i SampleVideo_360x240_cut.mp4 SampleVideo_360x240_cut.webm
4+
ffmpeg -i SampleVideo_360x240_cut.mp4 SampleVideo_360x240_cut.flac
5+
ffmpeg -i SampleVideo_360x240_cut.mp4 SampleVideo_360x240_cut.mp3
6+
ffmpeg -i SampleVideo_360x240_cut.flac flac_to_ogg.ogg
7+
ffmpeg -i SampleVideo_360x240_cut.mp4 SampleVideo_360x240_cut.mkv

0 commit comments

Comments
 (0)