LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-25-2011, 10:34 PM   #1
havok1977
Member
 
Registered: Apr 2005
Distribution: Mint KDE on the Desktop, Debian on the Server
Posts: 66

Rep: Reputation: 15
ffmpeg - Concatenating mpg + ac3 files into one


Hello,

I'm doing some more experimenting with ffmpeg, this time to merge a number of video files into one, they are mpg with ac3 audio and after looking around a bit I found this way of doing it:

Code:
cat PART1.mpg PART2.mpg PART3.mpg PART4.mpg PART5.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy Joined.mpg
And well, it does concatenate the files and merges it into one, but the audio is lost and I have no idea why..., by using -acodec copy it shouldn't do anything other than a plain transcription of the ac3 bits yet for some reason it doesn't.

Anyone has any ideas?
 
Old 02-27-2011, 07:45 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I have no idea with video files, but audio mp3 files can be simply concatenated:
cat file1 file2 >> file3
Could this be also the case with files containing a/v?

jlinkels
 
Old 02-27-2011, 08:32 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Concatenation works with some media formats and not with others. Usually only those that store the data in individualized packets within the stream can be catted. The .avi container, for example, does not; all its metadata is stored in a single section at the beginning of the file, so catting doesn't work properly.

Most, if not all, of the mpeg standard types are packetized, so in general the above should work. However, it's usually best to repackage the catted stream in a new container in any case, to ensure that all the metadata and timing info are accounted for properly. That's certainly why the above command is being piped through ffmpeg.

But another thing to watch out for is that most media encoders require that the input streams all have the same parameters before they will combine them. It could be that one of the catted streams has something different about it that is breaking the ffmpeg processing.

There may also be cases where ffmpeg considers certain combinations of bitrates and such to be "illegal" for the container used.

** What we really need to see is the actual output text of the commands, particularly for ffmpeg. Vague descriptions about how "it's not working" aren't enough. We need details. **

Also try breaking the command up into individual steps. First cat the files together into a single video, then run that video through ffmpeg separately. This should eliminate the possibility that the pipe itself is causing any trouble.

Edit: One more possibility I just remembered is that AC3 is usually handled by the external faac and faad libraries. One of these may not be installed on your system, or your version of ffmpeg may not have been compiled with support for them enabled (since the format is patent-encumbered). Again, the ffmpeg output should inform us if this is the case.

Last edited by David the H.; 02-27-2011 at 08:39 AM. Reason: as stated
 
Old 02-28-2011, 11:18 AM   #4
havok1977
Member
 
Registered: Apr 2005
Distribution: Mint KDE on the Desktop, Debian on the Server
Posts: 66

Original Poster
Rep: Reputation: 15
Hey David the H.

First of all thanks for your very thorough response, indeed it was my bad to overlook posting ffmpeg's output, of which I should let you know that I'm using the binaries provided on Marillat's Debian Multimedia repository.

All of the files I am working on are from the same source so encoding and quality should be consistent and I don't think are a problem for the encoding.

Anyway to the output:

Code:
cat PART1.mpg PART2.mpg PART3.mpg PART4.mpg PART5.mpg | ffmpeg -f mpeg -i - -vcodec copy -acodec copy Joined.mpg
FFmpeg version SVN-r25838, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jan 21 2011 08:21:58 with gcc 4.4.5
  configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
  libavutil     50.33. 0 / 50.33. 0
  libavcore      0.14. 0 /  0.14. 0
  libavcodec    52.97. 2 / 52.97. 2
  libavformat   52.87. 1 / 52.87. 1
  libavdevice   52. 2. 2 / 52. 2. 2
  libavfilter    1.65. 0 /  1.65. 0
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0
[mpeg @ 0x1ffe760] max_analyze_duration reached
[mpeg @ 0x1ffe760] Estimating duration from bitrate, this may be inaccurate
Input #0, mpeg, from 'pipe:':
  Duration: N/A, start: 1.000000, bitrate: 9448 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480 [PAR 221:150 DAR 221:100], 9000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
Output #0, mpeg, to 'Joined.mpg':                                                            
  Metadata:                                                                                  
    encoder         : Lavf52.87.1                                                            
    Stream #0.0: Video: mpeg2video, yuv420p, 720x480 [PAR 221:150 DAR 221:100], q=2-31, 9000 kb/s, 90k tbn, 29.97 tbc
    Stream #0.1: Audio: ac3, 48000 Hz, 5.1, 448 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
frame=207861 fps=780 q=-1.0 Lsize= 3251114kB time=6935.60 bitrate=3840.1kbits/s    
video:2854074kB audio:379232kB global headers:0kB muxing overhead 0.550771%

And well, the resulting file appears to include the audio track, but on playback it is completely mute.

Code:
Input #0, mpeg, from 'Joined.mpg':                                                           
  Duration: 01:55:35.63, start: 1.000000, bitrate: 3840 kb/s
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x480 [PAR 221:150 DAR 221:100], 9000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x80]: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
At least one output file must be specified

Last edited by havok1977; 02-28-2011 at 11:22 AM.
 
Old 03-03-2011, 08:22 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Well, that is an odd one. Everything does seem to be working. I'm guessing that libfaac is correctly installed on your system then.

The main possibility I can think of then is that ffmpeg is somehow choking on the audio. It may have something to do with ffmpeg's handling of ac3 decoding.

Try playing the separate source files with ffplay. Then cat them together and try it again. You might try them on a variety of other players as well, such as mplayer and vlc.

Next, try processing (codec copy) each of the individual source files through ffmpeg and test the output files again.


If possible, see if you can find a different video series you can process in the same way to confirm whether it's a problem with ffmpeg or with the video.


If nothing else works, you may have to demux the audio and video streams and combine them individually, then remux them back together. But that could lead to timing problems.

Or try a different program altogether. This page describes how to do it with mencoder:
http://www.misterhowto.com/index.php..._with_mencoder
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you split mpg files using a ffmpeg command? milkjerry3 Linux - Newbie 19 05-12-2011 08:09 AM
Video DVD, ffmpeg ERRORS: ac3 and /dev/null; makemenu MPEG-2 jiobo Linux - Newbie 2 12-13-2009 10:32 PM
Is there an issue with ffmpeg and Suse 10.3 (AC3 audio)? jroyce SUSE / openSUSE 4 11-24-2007 11:26 AM
ffmpeg not decoding AC3 audio jroyce Linux - Software 3 11-23-2007 09:32 AM
ffmpeg on slack 10.2 wmv to mpg Pier Slackware 2 01-05-2006 04:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration