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 07-17-2013, 05:22 PM   #1
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Rep: Reputation: 30
help converting tv recordings to mp4


I'm trying to get my mythtv recordings onto my android phone and tablet so I can take some of them on the road. I want to get them to h264 mp4 files.

I threw a few of the video files and tried this script below:


for file in *mpg
do
avconv -i "$file" -vcodec libx264 -pre:v libx264-slow -b:v 1024k -pass 1 -an -f mp4 - &&
avconv -i "$file" -vcodec libx264 -pre:v libx264-slow -b:v 1024k -pass 2 -acodec aac -ab 128k "$file".mp4
done



However, I get the following errors as it tries to process the video:


[mpegts @ 0x82e8260] Continuity check failed for pid 48 expected 7 got 10
[mpegts @ 0x82e8260] Continuity check failed for pid 0 expected 14 got 1
[mpegts @ 0x82e8260] max_analyze_duration reached
[mpegts @ 0x82e8260] PES packet size mismatch


and:
[mp4 @ 0x82efdc0] muxer does not support non seekable output

and lastly:
Could not write header for output file #0 (incorrect codec parameters ?)


Please let me know if you have any idea where I have gone wrong. This happened with two different video files and both play just fine in their native mpg format. They're just huge and would fill my memory cards up quickly.

Thank you
 
Old 07-18-2013, 02:49 AM   #2
eklavya
Member
 
Registered: Mar 2013
Posts: 633

Rep: Reputation: 141Reputation: 141
What is the file format of your tv recordings? Are they wmv files because the error you mentioned, I got it once for wmv files.

You are trying to use input using file, have you tried it using path of the file? Are you getting same error?

Are you sure you want to do this using command line? You can use a GUI application like avidemux or Cinelerra or Kdenlive or LIVES
I think, there should be too many recordings that's why you thought to convert using command line but if you are comfortable you can use GUI, it will not too much time consuming.

But if you want to convert using command like using loops just like you are trying, you can use ffmpeg, it is best converter for command line.

If we talk about your error
Quote:
muxer does not support non seekable output
It appears that the muxer only supports one audio or one video stream, not an audio and a video stream.
 
Old 07-18-2013, 03:10 AM   #3
propofol
Member
 
Registered: Nov 2007
Location: Seattle
Distribution: Debian Wheezy & Jessie; Ubuntu
Posts: 334

Rep: Reputation: 60
If would like to try an alternative: I switched from ffmpeg to using HandBrakeCLI and found it works very well. If you are interested, I can post the script I use to do a batch conversion.

Regards,
Stefan
 
Old 07-18-2013, 07:09 AM   #4
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
These are recorded to my mythtv via my hdhomerun device. I'm very fine using handbrake and didn't realize they have a cli to use.

I'd prefer to use the command line since I have a lot of recordings, so any scripts you can post will be very appreciated.
I tried ffmpeg but it gave me different errors and actually recommened to use avconv, so that's why i went that route.
--Thanks
 
Old 07-18-2013, 09:18 AM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Post the specifications of the input files:
Code:
avconv -i input.mpg
If you need anything specific for the output, then also post that. x264 and aac is noted.

Currently I recommend something like:

Code:
ffmpeg -i input.mkv -vcodec libx264 -vpre special -crf 15 -s 640x272 -aspect 640:272 -r 23.976 -threads 4 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -scodec copy output.mp4
You can use whatever preset you want. Most of this should work with avconv as it is just a fork.
 
Old 07-18-2013, 12:16 PM   #6
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
H_TeXMeX_H:

avconv version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr 2 2013 17:00:59 with gcc 4.6.3
[mpegts @ 0x9c31260] Continuity check failed for pid 48 expected 7 got 10
[mpegts @ 0x9c31260] Continuity check failed for pid 0 expected 14 got 1
[mpegts @ 0x9c31260] max_analyze_duration reached
[mpegts @ 0x9c31260] PES packet size mismatch
Input #0, mpegts, from 'The Outlaw Josey Wales.mpg':
Duration: 03:00:10.80, start: 75202.222522, bitrate: 6354 kb/s
Program 1
Stream #0.0[0x31]: Video: mpeg2video (Main), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 19392 kb/s, 59.96 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x34]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s
At least one output file must be specified




Do you have any scripts to run it with the second pass? I'd like to specify the bitrate.
 
Old 07-18-2013, 12:26 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
I recommend variable bitrate over constant bitrate for better quality. However, if the devices are limited in their capabilities:
Code:
ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 2 output.mp4
Also, is the input interlaced ? In which case it would need de-interlacing to not tear, unless you have some hardware de-interlacing.

Last edited by H_TeXMeX_H; 07-18-2013 at 12:27 PM.
 
Old 07-18-2013, 12:35 PM   #8
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Thanks Texmex, it is processing right now. Variable is what I prefer, I guess I should have said I want a predetermined file size and that's what the second pass will let me do.

These recordings are HDTV broadcasts...so do i need to deinterlace them? Can I check somehow if the video is interlaced? If so, how would I do that and how would I deinterlace it?
-Thanks
 
Old 07-18-2013, 02:31 PM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
HDTV can be interlaced. Usually frame rates of 50 or 60 give it away, like it is here. You could try running it in mplayer on the command line, it should say. You can also tell when playing them that they have horizontal lines that tend to tear on non-CRT screens:
http://en.wikipedia.org/wiki/Interla...by_interlacing

You can use the '-deinterlace' option, but check the output, because there may be consequences. I usually use mencoder for deinterlacing, and the results are quite good.
 
Old 07-18-2013, 06:40 PM   #10
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Ok, so I tried:

ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 1 -an -f rawvideo -y /dev/null
ffmpeg -i input.mpg -vcodec libx264 -b:v 1024k -s 1280x720 -aspect 1280:720 -r 30 -acodec libvo_aacenc -ab 128k -ar 48000 -async 48000 -ac 2 -pass 2 output.mp4


And it goes through the first pass just fine, but for the second pass it errors out and says:


[libx264 @ 0x8af0fe0] constant rate-factor is incompatible with 2pass.
Output #0, mp4, to 'test.mp4':
Stream #0.0: Video: libx264, yuv420p, 528x480 [PAR 40:33 DAR 4:3], q=-1--1, pass 2, 90k tbn, 30 tbc
Stream #0.1(eng): Audio: libvo_aacenc, 48000 Hz, stereo, s16, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height



Any ideas?

-Thanks
 
Old 07-19-2013, 02:57 AM   #11
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
It doesn't make sense. I know the '-crf' option is not compatible with 2 pass encoding, but you are not using it. Two pass encoding is usually used with mpeg4/xvid not x264, where crf and quantizer based one pass encoding is preferred.
 
Old 07-19-2013, 02:34 PM   #12
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Ok I think I got it with this:


for file in *mpg
do

ffmpeg -y -i "$file" -vcodec libx264 -b 1024k -pass 1 -an -f mp4 /dev/null
ffmpeg -y -i "$file" -vcodec libx264 -b 1024k -pass 2 -acodec libvo_aacenc -ab 128k "$file".mp4

done



It's encoding now and seems to work. I will report back when it finishes. it will take a whole day or so as it's a huge file that is being encoded. The key I think was changing the -b:v to simply -b

This new script just leaves the resolution alone which is great because tv recodings come in all different recording sizes. HD has 2 different sizes and SD has about 5-6 different sizes and varies depends on the stations. I think the reason it thought I was doing crf is because I had used a preset. I just dropped the preset and stuck with putting in my bitrate.
 
Old 07-20-2013, 03:13 PM   #13
xmrkite
Member
 
Registered: Oct 2006
Location: California, USA
Distribution: Mint 16, Lubuntu 14.04, Mythbuntu 14.04, Kubuntu 13.10, Xubuntu 10.04
Posts: 554

Original Poster
Rep: Reputation: 30
Ok, this new script works perfectly. The videos look fantastic and I am in the process of converting about 70 recordings over to .mp4.

Thanks again for all help received.
 
  


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
frontend for converting AVI to MP4 in linux mint manoj57 Linux Mint 3 06-16-2012 10:12 AM
ffmpeg: converting mp4 to webm (vp8) hydraMax Linux - Software 3 09-24-2011 05:52 PM
Help converting MKV to MP4 to play on PS3 hedpe Linux - Software 1 09-19-2008 09:05 AM
Converting mp4 sound files to mp3? ceaseallfeeling Linux - Software 2 12-22-2007 06:45 PM
Need help converting MP4 files for PSP SolidSnakeX28 Linux - Software 13 03-11-2006 07:45 AM

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

All times are GMT -5. The time now is 05:21 AM.

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