I have a MPEG 2 file with several audio tracks and one video track.
I want to convert it into something smaller, much smaller than MPEG 2, using
ffmpeg. I try to create either ogv or mkv containers with good quality and
smallest filesize. And I only want to keep the first 2 audio tracks. These can
either stay as 6ch or be downmixed into 2ch.
My current ffmpeg version is:
__________
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64
--docdir=/usr/doc/ffmpeg-3.4.2/html --mandir=/usr/man --disable-debug
--enable-shared --disable-static --enable-pthreads --enable-libtheora
--enable-libvorbis --enable-gpl --enable-version3 --enable-postproc
--enable-swscale --enable-avfilter --enable-gnutls --enable-libcdio
--enable-opengl --arch=x86_64 --enable-libmp3lame --enable-libxvid
--enable-libx264 --enable-libspeex --enable-nonfree --enable-librtmp
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libbluray
--enable-libass --enable-libopus --enable-libtwolame --enable-libpulse
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
__________
System: slackware based x86-64 Linux.
This is the info when playing the original mpeg file using mpv (V 0.27.2)
__________
Playing: capture_V0.mpg
(+) Video --vid=1 (mpeg2video 720x576 25.000fps)
VO: [opengl] 720x576 => 1024x576 yuv420p
(+) Video --vid=1 (mpeg2video 720x576 25.000fps)
Audio --aid=1 (ac3 6ch 48000Hz)
Audio --aid=2 (ac3 6ch 48000Hz)
Audio --aid=3 (ac3 6ch 48000Hz)
Audio --aid=4 (ac3 2ch 48000Hz)
__________
I want to keep audio track 1 ("aid=1") and audio track 2 ("aid=2"), or how
ffmpeg usually addresses these: "audio0 audio1"
The other 2 audio tracks can be rejected / should not be added into the
resulting mkv or ogv.
To test if everything works okay I first created some 30 seconds sample video
(using stream copy and the same container format than the original, mpg),
deleting some video stuff at the beginning I don't want to keep ( thats what
the "-ss 1:15.500" is for )
But I don't seem to get it right at all. I read the ffmpeg documentation (
http://ffmpeg.org//ffmpeg.html ), and also some posts about mapping on
video.stackexchange.com and superuser.com, still I fail in adding the two audio
tracks.
Here is how I tried creating the 30 seconds test video:
__________
ffmpeg -y -v error -ss 1:15.500 -i capture_V0.mpg -map 0:0 -map 0:1 -c:a ac3
-codec copy -acodec copy -t 30 capture_V1_30s.mpg
[mpeg @ 0x2540de0] Invalid media type data for output stream #0
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
$ ffmpeg -y -v error -ss 1:15.500 -i capture_V0.mpg -map 0 -codec copy -acodec
copy -t 30 capture_V1_30s.mpg
[mpeg @ 0x1a71b20] Invalid media type data for output stream #0
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
$ ffmpeg -y -v error -ss 1:15.500 -i capture_V0.mpg -map 0:0 -map 0:1 -codec
copy -t 30 capture_V1_30s.mpg
[mpeg @ 0xe5fae0] Invalid media type data for output stream #0
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument
__________
All these attempts with mapping failed, so I tried one version without any
mapping:
__________
time ffmpeg -y -v error -ss 1:15.500 -i capture_V0.mpg -codec copy -t 30
capture_V1_30s.mpg
real 0m3.233s
user 0m0.911s
sys 0m0.811s
__________
That /looks/ like it did work… but there is no audio track in the resulting 30
seconds test video:
__________
$ mpv capture_V1_30s.mpg
Playing: capture_V1_30s.mpg
(+) Video --vid=1 (mpeg2video 720x576 25.000fps)
VO: [opengl] 720x576 => 1024x576 yuv420p
V: 00:00:10 / 00:00:30 (20%) Cache: 10s+11MB
__________
Unlike the ffmpeg documentation which says, unless you use the -map options,
one video and one audio track is used, the video with the largest resolution,
and the audio with the most tracks, and if there are more audio tracks, the one
with the lowest index. Which should be in this case: audio 0 (or Audio --aid=1
(ac3 6ch 48000Hz) as mpv calls it).
*Why is there no audio when using -codec copy ? Using -codec copy _and_ -acodec
copy has the same result: no audio, the resulting mpg only has video.*
*What do I do wrong trying to use -map to include the 1st and 2nd audio track
(aka audio0 and audio1) ?*
There seems to be some glitch in the original capture_V0.mpg file. Playing it
with mpv results in mpv updating the info it gives after some seconds at the
beginning, and the video played indeed shows some kind of repeat.
The video starts, and then it looks like the video starts again, seemingly
playing the same video from the start, but the 2nd time it not stopped and
results in the start of the actual video that I want to keep - all from "-ss
1:15.500" till the end.
Since all that is in the part of the video I want to cut off, it should not be
an issue creating the sample videos, and it also should not be an issue
creating the real ogv or mkv.
The resulting capture_V1_30s.mpg, the one with no sound as described above is
indeed the beginning of the video I want to have as ogv or mkv, with everything
at the beginning cut off, including the weird repeat-glitch.
Cheers
Yours truly, Rava
_______________________________________________
ffmpeg-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".