Question / Help Couple questions for ffmpeg experts out there

belboz

Member
Hey all,

I am working on a GUI wrapper for ffmpeg to make it easier for me to extract the audio tracks from my OBS MP recordings.

It works well save a few things. One thing to make it more automated, and one thing which is probably my misunderstanding of ffmpeg to extract audio.

So I am hoping some experts out there with ffmpeg can give me some tips.

1) I first parse the video with ffmpeg -i filename.mp4 and look at the resulting output to determine how many audio tracks. This works well. But I was hoping there was a way to use ffmpeg to also show me the names of each audio track that OBS MP labels them with when it creates the mp4. VLC shows each audio track name as I configured it with OBS MP. So I was curious if there was anyway to get ffmpeg to parse the mp4 and dump the audio track names out?

I want to do this so I can automatically add that name to the end of the extracted audio file.

Any thoughts on how I can do this? I tried using "-f ffmetadata metadata.txt" but the resulting file contains nothing about the track names.

2) When I try to extract the audio tracks, I have to add a dummy wav file for the first track.

I want to do this.

Code:
ffmpeg -i filename.mp4 -c:a copy -vn -sn -map 0:1 "filename-game.wav" -map 0:2 "filename-comm.wav" -map 0:3 "filename-mic.wav"

But the first wav file is always bad. The others are fine.

If I do.

Code:
ffmpeg -i filename.mp4 -c:a copy -vn -sn -map 0:1 junk.wav -map 0:1 "filename-game.wav" -map 0:2 "filename-comm.wav" -map 0:3 "filename-mic.wav"

It works fine and I just toss the corrupt junk.wav

Any thoughts on what is wrong with my original attempt without the junk.wav?

Thanks in advance for any help.
 

belboz

Member
Guess nobody has any thoughts on proper ffmpeg command line usage?

I have the GUI app pretty much done, and have been using it for my own personal use for a month or so now. It works, but I still use the junk track method mentioned above.

Below is a screen shot of the app. You basically select your video file. It parses it and determines how many audio tracks it has, fills in the names of the tracks based on what you named them in OBS. Then you can check which ones you want to extract. Hit go and it extracts the audio tracks keeping the base file name and adding a "-trackname" to the end of the files base name. You can change those track names yourself before hitting go, but it pulls it from the mp4 for you.

So in my screen shot below it would be 2016-01-02 16-02-34-microphone.wav for the checked microphone track generated after hitting go.

App works fine. Needs a little polish, would love to figure out the ffmpeg command line thing so I don't have to create that junk track and delete it. If I make it available, the only issue I think I would have is bundling ffmpeg.exe with it.

2016-02-05.png
 

kaloc

Member
I made a test mp4 in ver 0.12.3 with 3 audio tracks to simulate your setup and I didn't have an issue extracting the audio ( without re-encoding ). I'm guessing you got the title extraction figured out for audio tracks.

So my sample mp4 has this :
Stream #0:0(und): Video: h264
Stream #0:1(und): Audio: aac
Stream #0:2(und): Audio: aac
Stream #0:3(und): Audio: aac

I used this command to extract each audio stream to their own file ( it's a very simple example ) and all tracks are working fine. It doesn't have to be a single long command, you could call ffmpeg 3 times sequentially to get the same result.
Code:
ffmpeg -i c:\sample.mp4 -c copy -map 0:1 c:\audio1.mkv -c copy -map 0:2 c:\audio2.mkv -c copy -map 0:3 c:\audio3.mkv

In your original command line, you don't really need the -vn -sn , but it doesn't really hurt anything. What you did miss is ffmpeg wants codec options before every output. If you don't supply any options to ffmpeg, it will re-encode the input based on your output file container. Since you are exporting the audio tracks to wav though, it may not be an issue.

Some multi output examples are here
https://trac.ffmpeg.org/wiki/Creating multiple outputs
 
Last edited:

NalaNosivad

Member
It's nowhere close to being tidy enough to release yet, but you can take a look at the bunch of batch files I'm working on to do pretty much the same thing, but with the context menu.

You should be able to see what I'm doing to get the audio out. It's nothing out of the ordinary, though. I've been using it for months as it's changed day by day, though.

Edit: Note I didn't include ffmpeg in that zip, since I assume you won't be running it!
 

belboz

Member
So my problem was not specifying the audio output format. I added specifying the proper audio output format and it works fine!

Thanks for the tips!

Code:
ffmpeg -i c:\sample.mp4 -c copy -map 0:1 c:\audio1.mkv -c copy -map 0:2 c:\audio2.mkv -c copy -map 0:3 c:\audio3.mkv
 
Last edited:

belboz

Member
Thanks for the samples.

Thankfully kaloc's post steered me in the right direction and I have it sorted now.

Just need to polish the app now. Don't know if there is any interest from anyone in this gui wrapper?
 
Last edited:
Top