Kdenlive   bug tracker Home page

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000424KdenliveCapturepublic2008-12-02 07:072008-12-29 15:37
Reporterddennedy 
Assigned Tomadsdyd 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version0.7.0 
Target VersionFixed in Version0.7.1 
Summary0000424: file format for video4linux capture is wrong
DescriptionI was testing the V4L capture and noticed the duration of the captured file is wrong. It is defaulting to the MLT hardcoded fallback of 15000 frames instead of the actual 839 frames. Then, I noticed in the process listing the way kdenlive is launching a child process:

ffmpeg -f oss -i /dev/dsp -f video4linux2 -s 320x240 -r 15 -i /dev/video0 -f m4v -y /home/ddennedy/capture0000.mpg -f m4v -

'-f m4v' specifies a mpeg-4 elementary stream. However, the file extension .mpg is for MPEG-2 program stream or MPEG-1 systems streams. MPEG-4 video is not a valid codec for MPEG-2 program stream. It should use 'mp4' as the file extension and option to the -f option because mp4 is the MPEG-4 part 14 official file format for MPEG-4. Actually, -f is optional in this case as it is inferred from the file extension. Furthermore, audio was not captured because m4v can not be multiplexed with another stream.

TagsNo tags attached.
Build/Install MethodManual build from SVN
Attached Filespatch file icon kdenlive-424-v4l.patch [^] (3,144 bytes) 2008-12-04 08:36 [Show Content]

- Relationships
has duplicate 0000444closedmadsdyd captured files with video4linux2-device has a default length of 10 Minutes 

-  Notes
(0001508)
cinephiliac (updater)
2008-12-03 17:32

Acknowledged.
(0001519)
ddennedy (developer)
2008-12-04 07:21

I did some more research on what kdenlive is doing. Now, I understand why it is supply -f options and trying to use m4v - because it is piping the ffmpeg capture to a ffplay process for viewing. I recommend to use MPEG-2 Transport Stream (-f mpegts) for this because it can contain MPEG-4, is designed for streaming, and can be muxed with the audio. The dialog is rather tricky, however. You need to be able to specify "-vcodec mpeg4" and during capture, it needs to be applied to the file output part of the command line as well as the pipe.

Consider this patch:

Index: src/recmonitor.cpp
===================================================================
--- src/recmonitor.cpp (revision 2755)
+++ src/recmonitor.cpp (working copy)
@@ -362,7 +362,7 @@
     }
                                                                                          
     if (ui.device_selector->currentIndex() != SCREENGRAB) {
- kDebug() << "Capture: Running ffplay " << m_captureArgs.join(" ");
+ kDebug() << "Capture: Running ffplay " << m_displayArgs.join(" ");
         displayProcess->start("ffplay", m_displayArgs);
         ui.video_frame->setText(i18n("Initialising..."));
     } else {
@@ -406,7 +406,7 @@
     }
     if (captureProcess->state() == QProcess::NotRunning) {
         m_recAction->setChecked(true);
- QString extension = "mpg";
+ QString extension = "ts";
         if (ui.device_selector->currentIndex() == SCREENGRAB) extension = "ogv"; //KdenliveSettings::screengrabextension();
         QString path = KdenliveSettings::capturefolder() + "/capture0000." + extension;
         int i = 1;
@@ -431,7 +431,7 @@
             captureProcess->start(KdenliveSettings::dvgrab_path(), m_captureArgs);
             break;
         case VIDEO4LINUX:
- m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << "-y" << m_captureFile.path() << "-f" << KdenliveSettings::video4vencoding() << "-";
+ m_captureArgs << KdenliveSettings::video4capture().simplified().split(' ') << "-y" << m_captureFile.path() << "-f" << KdenliveSettings::video4vencoding().simplified().split(' ') << "-";
             m_displayArgs << KdenliveSettings::video4playback().simplified().split(' ') << "-x" << QString::number(ui.video_frame->width()) << "-y" << QString::number(ui.video_frame->height()) << "-";
             captureProcess->setStandardOutputProcess(displayProcess);
             kDebug() << "Capture: Running ffmpeg " << m_captureArgs.join(" ");

---

Next, in the Capture dialog, for the Video Encoding field, enter "mpegts -vcodec mpeg4". Then, you have to remove " -vcodec mpeg4" from the Playback params field because -vcodec is not a ffplay option. Now, it records audio and video and reports the correct duration.

The fact that kdenlive uses the Video Encoding to build m_captureArgs when capturing makes this dialog awkward because I have to put extra params like -vcodec or -b in the Video Encoding field to make it work whereas perhaps I only expect to add them to the Capture params field. Then, the fact that it copies them to Playback params making that field's value invalid presents another issue. OTOH, we don't want to copy all of Capture params to m_captureArgs twice, so I understand why the Video Encoding was used.

I have to think more about what to recommend here.
(0001520)
ddennedy (developer)
2008-12-04 07:44

Here is what I recommend. Remove the Video Encoding, Audio Encoding, and Playback params fields. Hardcode these as "-f mpegts -vcodec mpeg4 -acodec mp2".

Then, default the Capture params as "-f oss -i /dev/dsp -f video4linux2 -s 320x240 -r 30 -i /dev/video0".

Next, add an Encoding params field defaulted to "-qscale 1 -ab 224k" or something else.

Finally, construct your m_captureArgs and m_displayArgs from these, and always place the hard-coded "-f mpegts -vcodec mpeg4 -acodec mp2" after the Encoding params so it overrides any -f, -vcodec, or -acodec the user might put into Encoding params.
(0001521)
ddennedy (developer)
2008-12-04 07:48

One might be turned off by the hard-codec format and codecs, but when you are trying to pipe into ffplay and capture at the same time, support video and audio, and support odd framerates, your options are very limited! The above combination is known to work and to work very well.
(0001524)
ddennedy (developer)
2008-12-04 08:17

Let me refine that recommendation.
Use "-f mpegts -vcodec mpeg4 -acodec mp2" when the destination is the pipe, but use "-f mp4 -vcodec mpeg4 -acodec mp2" when the destination is the file, and use .mp4 as the file name extension. The MP4 seeks better than the TS.
(0001525)
ddennedy (developer)
2008-12-04 08:39

I prototyped this recommendation by using the Playback params as the Encoding params and with the attached kdenlive-424-v4l.patch.
Video Encoding: <blank>
Capture params: -f oss -i /dev/dsp -f video4linux2 -s 320x240 -r 15 -i /dev/video0
Playback params: -qscale 1 -ab 224k
(0001556)
madsdyd (administrator)
2008-12-07 10:53

There has been a commit addressing this, in SVN rev. 2756, partially based on a patch by ddennedy.

Unfortunately, I have no V4L devices to test with, but if you (ddennedy) could confirm that the commit fixes this issue, I would be more than happy to resolve it.

Thanks.
(0001566)
ddennedy (developer)
2008-12-08 06:53

I use the vivi module for testing V4L2. It is a color bar generator. :-)
(0001577)
ddennedy (developer)
2008-12-08 18:38

I took a look and it works. Existing users will have an incorrect value in the Capture params until Settings are reset by removing the line beginning with key "video4capture" in ~/.kde4/share/config/kdenliverc. Perhaps an easier fix is to just tell them to remove "-f m4v" from that field in the dialog.
(0001580)
madsdyd (administrator)
2008-12-08 21:13

Fixed in Kdenlive SVN rev. 2756 - please note that existing users should remove their kdenliverc to reset the setting to an usuable value.

- Issue History
Date Modified Username Field Change
2008-12-02 07:07 ddennedy New Issue
2008-12-02 07:07 ddennedy Build/Install Method => Manual build from SVN
2008-12-03 17:32 cinephiliac Note Added: 0001508
2008-12-03 17:32 cinephiliac Status new => acknowledged
2008-12-04 07:21 ddennedy Note Added: 0001519
2008-12-04 07:44 ddennedy Note Added: 0001520
2008-12-04 07:48 ddennedy Note Added: 0001521
2008-12-04 08:17 ddennedy Note Added: 0001524
2008-12-04 08:36 ddennedy File Added: kdenlive-424-v4l.patch
2008-12-04 08:39 ddennedy Note Added: 0001525
2008-12-07 10:53 madsdyd Note Added: 0001556
2008-12-08 06:53 ddennedy Note Added: 0001566
2008-12-08 18:38 ddennedy Note Added: 0001577
2008-12-08 21:13 madsdyd Note Added: 0001580
2008-12-08 21:13 madsdyd Status acknowledged => resolved
2008-12-08 21:13 madsdyd Fixed in Version => Recent git
2008-12-08 21:13 madsdyd Resolution open => fixed
2008-12-08 21:13 madsdyd Assigned To => madsdyd
2008-12-16 23:50 ddennedy Relationship added has duplicate 0000444
2008-12-29 15:36 madsdyd Fixed in Version Recent git => 0.7.1
2008-12-29 15:37 madsdyd Status resolved => closed


Copyright © 2000 - 2014 MantisBT Team
Powered by Mantis Bugtracker